@PublicEvolving public abstract class DataType extends Object implements Serializable
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 using LocalDateTime
.
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.
Modifier and Type | Field and Description |
---|---|
protected Class<?> |
conversionClass |
protected LogicalType |
logicalType |
Modifier and Type | Method and Description |
---|---|
abstract <R> R |
accept(DataTypeVisitor<R> visitor) |
abstract DataType |
bridgedTo(Class<?> newConversionClass)
Adds a hint that data should be represented using the given class when entering or leaving
the table ecosystem.
|
boolean |
equals(Object o) |
Class<?> |
getConversionClass()
Returns the corresponding conversion class for representing values.
|
LogicalType |
getLogicalType()
Returns the corresponding logical type.
|
int |
hashCode() |
abstract DataType |
notNull()
Adds a hint that null values are not expected in the data for this type.
|
abstract DataType |
nullable()
Adds a hint that null values are expected in the data for this type (default behavior).
|
String |
toString() |
protected final LogicalType logicalType
protected final Class<?> conversionClass
public LogicalType getLogicalType()
LogicalType
public Class<?> getConversionClass()
LogicalType.getDefaultConversion()
public abstract DataType notNull()
public abstract DataType nullable()
This method exists for explicit declaration of the default behavior or for invalidation of
a previous call to notNull()
.
public abstract DataType bridgedTo(Class<?> newConversionClass)
A supported conversion class depends on the logical type and its nullability property.
Please see the implementation of LogicalType.supportsInputConversion(Class)
,
LogicalType.supportsOutputConversion(Class)
, or the documentation for more information
about supported conversions.
public abstract <R> R accept(DataTypeVisitor<R> visitor)
Copyright © 2014–2020 The Apache Software Foundation. All rights reserved.