Interface Schema.LogicalType<InputT,BaseT>
- Type Parameters:
InputT- The Java type used to set the type when usingRow.Builder.addValue(java.lang.Object).BaseT- The Java type for the underlying storage.
- All Superinterfaces:
Serializable
- All Known Implementing Classes:
CalciteUtils.TimeWithLocalTzType,Date,DateTime,EnumerationType,FixedBytes,FixedPrecisionNumeric,FixedString,MicrosInstant,NanosDuration,NanosInstant,OneOfType,PassThroughLogicalType,ProtoSchemaLogicalTypes.Fixed32,ProtoSchemaLogicalTypes.Fixed64,ProtoSchemaLogicalTypes.SFixed32,ProtoSchemaLogicalTypes.SFixed64,ProtoSchemaLogicalTypes.SInt32,ProtoSchemaLogicalTypes.SInt64,ProtoSchemaLogicalTypes.UInt32,ProtoSchemaLogicalTypes.UInt64,PythonCallable,SbeLogicalTypes.LocalMktDate,SbeLogicalTypes.TZTimeOnly,SbeLogicalTypes.TZTimestamp,SbeLogicalTypes.Uint16,SbeLogicalTypes.Uint32,SbeLogicalTypes.Uint64,SbeLogicalTypes.Uint8,SbeLogicalTypes.UTCDateOnly,SbeLogicalTypes.UTCTimeOnly,SbeLogicalTypes.UTCTimestamp,SchemaLogicalType,Time,UnknownLogicalType,UuidLogicalType,VariableBytes,VariableString
- Enclosing class:
Schema
A LogicalType is a way to define a new type that can be stored in a schema field using an
underlying FieldType as storage. A LogicalType must specify a base FieldType used to store the
data by overriding the getBaseType() method. Usually the FieldType returned will be
one of the standard ones implemented by Schema. It is legal to return another LogicalType, but
the storage types must eventually resolve to one of the standard Schema types; it is not
allowed to have LogicalTypes reference each other recursively via getBaseType. The toBaseType(InputT) and toInputType(BaseT) should convert back and forth between the Java type for
the LogicalType (InputT) and the Java type appropriate for the underlying base type (BaseT).
Note for nullable types, null checking is always done externally. toBaseType(InputT) and
toInputType(BaseT) may assume their inputs are never null.
getIdentifier() must define a globally unique identifier for this LogicalType. A
LogicalType can optionally provide an identifying argument as well using getArgument().
An example is a LogicalType that represents a fixed-size byte array. The identifier
"FixedBytes" uniquely identifies this LogicalType (or specifically, this class of
LogicalTypes), while the argument returned will be the length of the fixed-size byte array. The
combination of getIdentifier() and getArgument() must completely identify a
LogicalType.
A LogicalType can be added to a schema using Schema.Builder.addLogicalTypeField(java.lang.String, org.apache.beam.sdk.schemas.Schema.LogicalType<InputT, BaseT>).
-
Method Summary
Modifier and TypeMethodDescriptiondefault <T> @Nullable TAn optional argument to configure the type.A schema type representing how to interpret the argument.The baseSchema.FieldTypeused to store values of this type.The unique identifier for this type.toBaseType(@NonNull InputT input) Convert the input type to the type Java type used by the baseSchema.FieldType.toInputType(@NonNull BaseT base) Convert the Java type used by the baseSchema.FieldTypeto the input type.
-
Method Details
-
getIdentifier
String getIdentifier()The unique identifier for this type. -
getArgumentType
@Nullable Schema.FieldType getArgumentType()A schema type representing how to interpret the argument.nullindicates this logical type is not parameterized by an argument. -
getArgument
An optional argument to configure the type. -
getBaseType
Schema.FieldType getBaseType()The baseSchema.FieldTypeused to store values of this type. -
toBaseType
Convert the input type to the type Java type used by the baseSchema.FieldType. -
toInputType
Convert the Java type used by the baseSchema.FieldTypeto the input type.
-