Class DataType
- java.lang.Object
-
- org.apache.flink.table.types.DataType
-
- All Implemented Interfaces:
Serializable
,AbstractDataType<DataType>
- Direct Known Subclasses:
AtomicDataType
,CollectionDataType
,FieldsDataType
,KeyValueDataType
@PublicEvolving public abstract class DataType extends Object implements AbstractDataType<DataType>, Serializable
Describes the data type of a value in the table ecosystem. Instances of this class can be used to declare input and/or output types of operations.The
DataType
class has two responsibilities: declaring a logical type and giving hints about the physical representation of data to the planner. While the logical type is mandatory, hints are optional but useful at the edges to other APIs.The logical type is independent of any physical representation and is close to the "data type" terminology of the SQL standard. See
LogicalType
and its subclasses for more information about available logical types and their properties.Physical hints are required at the edges of the table ecosystem. Hints indicate the data format that an implementation expects. For example, a data source could express that it produces values for logical timestamps using a
Timestamp
class instead of usingLocalDateTime
. With this information, the runtime is able to convert the produced class into its internal data format. In return, a data sink can declare the data format it consumes from the runtime.
-
-
Field Summary
Fields Modifier and Type Field Description protected Class<?>
conversionClass
protected LogicalType
logicalType
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description abstract <R> R
accept(DataTypeVisitor<R> visitor)
boolean
equals(Object o)
abstract List<DataType>
getChildren()
Returns the children of this data type, if any.Class<?>
getConversionClass()
Returns the corresponding conversion class for representing values.static int
getFieldCount(DataType dataType)
Returns the count of the first-level fields for the providedDataType
.static List<DataType>
getFieldDataTypes(DataType dataType)
Returns the first-level field data types for the providedDataType
.static List<String>
getFieldNames(DataType dataType)
Returns the first-level field names for the providedDataType
.static List<DataTypes.Field>
getFields(DataType dataType)
Returns an ordered list of fields starting from the providedDataType
.LogicalType
getLogicalType()
Returns the corresponding logical type.int
hashCode()
DataType
toInternal()
Creates a copy of thisDataType
instance with the internal data type conversion classes.String
toString()
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.apache.flink.table.types.AbstractDataType
bridgedTo, notNull, nullable
-
-
-
-
Field Detail
-
logicalType
protected final LogicalType logicalType
-
conversionClass
protected final Class<?> conversionClass
-
-
Method Detail
-
getLogicalType
public LogicalType getLogicalType()
Returns the corresponding logical type.- Returns:
- a parameterized instance of
LogicalType
-
getConversionClass
public Class<?> getConversionClass()
Returns the corresponding conversion class for representing values. If no conversion class was defined manually, the default conversion defined by the logical type is used.- Returns:
- the expected conversion class
- See Also:
LogicalType.getDefaultConversion()
-
getChildren
public abstract List<DataType> getChildren()
Returns the children of this data type, if any. Returns an empty list if this data type is atomic.- Returns:
- the children data types
-
accept
public abstract <R> R accept(DataTypeVisitor<R> visitor)
-
toInternal
public DataType toInternal()
Creates a copy of thisDataType
instance with the internal data type conversion classes. This method performs the transformation deeply through its children. For example, for aDataType
instance representing a row type with a timestamp field, this method returns a newDataType
, with the conversion class toRowData
and the children data type with the conversion class toTimestampData
.For a comprehensive list of internal data types, check
RowData
.- See Also:
RowData
-
getFieldCount
public static int getFieldCount(DataType dataType)
-
getFields
public static List<DataTypes.Field> getFields(DataType dataType)
-
-