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:
java.io.Serializable
- All Known Implementing Classes:
Date
,DateTime
,EnumerationType
,FixedBytes
,FixedPrecisionNumeric
,FixedString
,MicrosInstant
,NanosDuration
,NanosInstant
,OneOfType
,PassThroughLogicalType
,PythonCallable
,SchemaLogicalType
,Time
,UnknownLogicalType
,UuidLogicalType
,VariableBytes
,VariableString
- Enclosing class:
- Schema
public static interface Schema.LogicalType<InputT,BaseT> extends java.io.Serializable
A LogicalType allows users to define a custom schema type.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. ThetoBaseType(InputT)
andtoInputType(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)
andtoInputType(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 usinggetArgument()
. 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 ofgetIdentifier()
andgetArgument()
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
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description default <T> @Nullable T
getArgument()
An optional argument to configure the type.@Nullable Schema.FieldType
getArgumentType()
A schema type representing how to interpret the argument.Schema.FieldType
getBaseType()
The baseSchema.FieldType
used to store values of this type.java.lang.String
getIdentifier()
The unique identifier for this type.@NonNull BaseT
toBaseType(@NonNull InputT input)
Convert the input type to the type Java type used by the baseSchema.FieldType
.@NonNull InputT
toInputType(@NonNull BaseT base)
Convert the Java type used by the baseSchema.FieldType
to the input type.
-
-
-
Method Detail
-
getIdentifier
java.lang.String getIdentifier()
The unique identifier for this type.
-
getArgumentType
@Nullable Schema.FieldType getArgumentType()
A schema type representing how to interpret the argument.null
indicates this logical type is not parameterized by an argument.
-
getArgument
default <T> @Nullable T getArgument()
An optional argument to configure the type.
-
getBaseType
Schema.FieldType getBaseType()
The baseSchema.FieldType
used to store values of this type.
-
toBaseType
@NonNull BaseT toBaseType(@NonNull InputT input)
Convert the input type to the type Java type used by the baseSchema.FieldType
.
-
toInputType
@NonNull InputT toInputType(@NonNull BaseT base)
Convert the Java type used by the baseSchema.FieldType
to the input type.
-
-