@Experimental(value=SCHEMAS) public class ProtoSchemaTranslator extends java.lang.Object
The following proto primitive types map to the following Beam types:
The following proto numeric types do not have have native Beam primitive types. LogicalType objects were created to represent these types. Normal numeric types are used as the base type of each of these logical types, so SQL queries should work as normal.
Protobuf maps are mapped to Beam FieldType.MAP types. Protobuf repeated fields are mapped to Beam FieldType.ARRAY types.
Beam schemas include the EnumerationType logical type to represent enumerations, and protobuf enumerations are translated to this logical type. The base representation type for this logical type is an INT32.
Beam schemas include the OneOfType logical type to represent unions, and protobuf oneOfs are translated to this logical type. The base representation type for this logical type is a subrow containing an optional field for each oneof option.
google.com.protobuf.Timestamp messages cannot be translated to FieldType.DATETIME types, as the proto type represents nanonseconds and Beam's native type does not currently support that. a new TimestampNanos logical type has been introduced to allow representing nanosecond timestamp, as well as a DurationNanos logical type to represent google.com.protobuf.Duration types.
Protobuf wrapper classes are translated to nullable types, as follows.
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
PROTO_NUMBER_METADATA_TAG
This METADATA tag is used to store the field number of a proto tag.
|
Constructor and Description |
---|
ProtoSchemaTranslator() |
Modifier and Type | Method and Description |
---|---|
static int |
getFieldNumber(Schema.FieldType fieldType)
Return the proto field number for a type.
|
static Schema |
getSchema(java.lang.Class<? extends Message> clazz)
Return a Beam scheam representing a proto class.
|
static Schema.FieldType |
withFieldNumber(Schema.FieldType fieldType,
int index)
Attach a proto field number to a type.
|
public static final java.lang.String PROTO_NUMBER_METADATA_TAG
public static Schema.FieldType withFieldNumber(Schema.FieldType fieldType, int index)
public static int getFieldNumber(Schema.FieldType fieldType)