dawidwys commented on a change in pull request #8335: [FLINK-12253][table-common] Setup a class hierarchy for the new logical type system URL: https://github.com/apache/flink/pull/8335#discussion_r280487361
########## File path: flink-table/flink-table-common/src/main/java/org/apache/flink/table/types/logical/LogicalType.java ########## @@ -0,0 +1,210 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.flink.table.types.logical; + +import org.apache.flink.annotation.PublicEvolving; +import org.apache.flink.util.Preconditions; + +import java.io.Serializable; +import java.util.Arrays; +import java.util.HashSet; +import java.util.List; +import java.util.Objects; +import java.util.Set; + +/** + * A logical type that describes the data type of a value. It does not imply a concrete physical + * representation for transmission or storage but defines the boundaries between JVM-based languages + * and the table ecosystem. + * + * <p>The definition of a logical type is similar to the SQL standard's "data type" terminology but + * also contains information about the nullability of a value for efficient handling of scalar + * expressions. + * + * <p>Subclasses of this class define characteristics of built-in or user-defined types. + * + * <p>Instances of this class describe the fully parameterized, immutable type with additional + * information such as numeric precision or expected length. + * + * <p>NOTE: A logical type is just a description of a type, a planner or runtime might not support + * every type in every logical precision yet! + */ +@PublicEvolving +public abstract class LogicalType implements Serializable { + + private final boolean isNullable; + + private final LogicalTypeRoot typeRoot; + + public LogicalType(boolean isNullable, LogicalTypeRoot typeRoot) { + this.isNullable = isNullable; + this.typeRoot = Preconditions.checkNotNull(typeRoot); + } + + /** + * Returns whether a value of this type can be {@code null}. + */ + public boolean isNullable() { + return isNullable; + } + + /** + * Returns the root of this type. It is an essential description without additional parameters. + */ + public LogicalTypeRoot getTypeRoot() { + return typeRoot; + } + + /** + * Returns a deep copy of this type with possibly different nullability. + * + * @param isNullable the intended nullability of the copied type + * @return a deep copy + */ + public abstract LogicalType copy(boolean isNullable); + + /** + * Returns a deep copy of this type. + * + * @return a deep copy + */ + public LogicalType copy() { Review comment: Make this method `final` with a comment to implement `LogicalType copy(boolean isNullable)` instead? ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: [email protected] With regards, Apache Git Services
