Class TableRowToStorageApiProto
java.lang.Object
org.apache.beam.sdk.io.gcp.bigquery.TableRowToStorageApiProto
Utility methods for converting JSON
TableRow objects to dynamic protocol message, for use
with the Storage write API.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classThis class collects errors encountered while attempting to convert a json message into its matching protocol-buffer message.static classstatic classstatic classstatic classstatic classstatic interfacestatic interface -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic Descriptors.DescriptorgetDescriptorFromTableSchema(com.google.api.services.bigquery.model.TableSchema jsonSchema, boolean respectRequired, boolean includeCdcColumns) static Descriptors.DescriptorgetDescriptorFromTableSchema(com.google.cloud.bigquery.storage.v1.TableSchema tableSchema, boolean respectRequired, boolean includeCdcColumns) Given a BigQuery TableSchema, returns a protocol-buffer Descriptor that can be used to write data using the BigQuery Storage API.static ObjectjsonValueFromMessageValue(TableRowToStorageApiProto.SchemaInformation schemaInformation, Descriptors.FieldDescriptor fieldDescriptor, Object fieldValue, boolean expandRepeated, Predicate<String> includeField, String prefix, boolean useSetF) static ByteStringmergeNewFields(ByteString tableRowProto, DescriptorProtos.DescriptorProto descriptorProto, com.google.cloud.bigquery.storage.v1.TableSchema tableSchema, TableRowToStorageApiProto.SchemaInformation schemaInformation, com.google.api.services.bigquery.model.TableRow unknownFields, boolean ignoreUnknownValues) static ByteStringmergeNewFields(ByteString tableRowProto, Descriptors.Descriptor descriptor, Descriptors.Descriptor descriptorIgnoreRequired, TableRowToStorageApiProto.SchemaInformation schemaInformation, com.google.api.services.bigquery.model.TableRow unknownFields, boolean ignoreUnknownValues) static @Nullable DynamicMessagemessageFromMap(TableRowToStorageApiProto.SchemaInformation schemaInformation, @Nullable Descriptors.Descriptor descriptor, AbstractMap<String, Object> map, boolean ignoreUnknownValues, boolean allowMissingRequiredFields, @Nullable com.google.api.services.bigquery.model.TableRow unknownFields, @Nullable String changeType, @Nullable String changeSequenceNum, TableRowToStorageApiProto.ErrorCollector collectedExceptions) Given a BigQuery row map, returns a protocol-buffer message for the BigQuery Storage API.static @Nullable DynamicMessagemessageFromTableRow(TableRowToStorageApiProto.SchemaInformation schemaInformation, @Nullable Descriptors.Descriptor descriptor, com.google.api.services.bigquery.model.TableRow tableRow, boolean ignoreUnknownValues, boolean allowMissingRequiredFields, @Nullable com.google.api.services.bigquery.model.TableRow unknownFields, @Nullable String changeType, long changeSequenceNum, TableRowToStorageApiProto.ErrorCollector collectedExceptions) ForwardschangeSequenceNumtomessageFromTableRow(SchemaInformation, Descriptor, TableRow, boolean, boolean, TableRow, String, String, ErrorCollector)viaLong.toHexString(long).static @Nullable DynamicMessagemessageFromTableRow(TableRowToStorageApiProto.SchemaInformation schemaInformation, @Nullable Descriptors.Descriptor descriptor, com.google.api.services.bigquery.model.TableRow tableRow, boolean ignoreUnknownValues, boolean allowMissingRequiredFields, @Nullable com.google.api.services.bigquery.model.TableRow unknownFields, @Nullable String changeType, @Nullable String changeSequenceNum, TableRowToStorageApiProto.ErrorCollector collectedExceptions) Given a BigQuery TableRow, returns a protocol-buffer message that can be used to write data using the BigQuery Storage API.static com.google.cloud.bigquery.storage.v1.TableFieldSchema.ModemodeToProtoMode(@Nullable String defaultValueExpression, String mode) static StringprotoModeToJsonMode(com.google.cloud.bigquery.storage.v1.TableFieldSchema.Mode protoMode) static com.google.api.services.bigquery.model.TableSchemaprotoSchemaToTableSchema(com.google.cloud.bigquery.storage.v1.TableSchema protoTableSchema) static com.google.api.services.bigquery.model.TableFieldSchemaprotoTableFieldToTableField(com.google.cloud.bigquery.storage.v1.TableFieldSchema protoTableField) static StringprotoTypeToJsonType(com.google.cloud.bigquery.storage.v1.TableFieldSchema.Type protoType) static com.google.cloud.bigquery.storage.v1.TableSchemaschemaToProtoTableSchema(com.google.api.services.bigquery.model.TableSchema tableSchema) static com.google.cloud.bigquery.storage.v1.TableFieldSchematableFieldToProtoTableField(com.google.api.services.bigquery.model.TableFieldSchema field) static com.google.api.services.bigquery.model.TableRowtableRowFromMessage(TableRowToStorageApiProto.SchemaInformation schemaInformation, Message message, boolean includeCdcColumns, Predicate<String> includeField) static com.google.api.services.bigquery.model.TableRowtableRowFromMessage(TableRowToStorageApiProto.SchemaInformation schemaInformation, Message message, boolean includeCdcColumns, Predicate<String> includeField, String namePrefix) static com.google.api.services.bigquery.model.TableRowtableRowFromMessageUseSetF(TableRowToStorageApiProto.SchemaInformation schemaInformation, Message message, boolean includeCdcColumns, Predicate<String> includeField, String namePrefix) static byte[]tableSchemaHash(com.google.cloud.bigquery.storage.v1.TableSchema tableSchema) static org.apache.beam.vendor.guava.v32_1_2_jre.com.google.common.hash.HashCodetableSchemaHash(String prefix, List<com.google.cloud.bigquery.storage.v1.TableFieldSchema> fields) static com.google.cloud.bigquery.storage.v1.TableFieldSchema.TypetypeToProtoType(String type) static Descriptors.DescriptorwrapDescriptorProto(DescriptorProtos.DescriptorProto descriptorProto)
-
Constructor Details
-
TableRowToStorageApiProto
public TableRowToStorageApiProto()
-
-
Method Details
-
tableSchemaHash
public static byte[] tableSchemaHash(com.google.cloud.bigquery.storage.v1.TableSchema tableSchema) -
tableSchemaHash
-
modeToProtoMode
-
protoModeToJsonMode
public static String protoModeToJsonMode(com.google.cloud.bigquery.storage.v1.TableFieldSchema.Mode protoMode) -
protoTypeToJsonType
public static String protoTypeToJsonType(com.google.cloud.bigquery.storage.v1.TableFieldSchema.Type protoType) -
typeToProtoType
public static com.google.cloud.bigquery.storage.v1.TableFieldSchema.Type typeToProtoType(String type) -
protoSchemaToTableSchema
public static com.google.api.services.bigquery.model.TableSchema protoSchemaToTableSchema(com.google.cloud.bigquery.storage.v1.TableSchema protoTableSchema) -
protoTableFieldToTableField
public static com.google.api.services.bigquery.model.TableFieldSchema protoTableFieldToTableField(com.google.cloud.bigquery.storage.v1.TableFieldSchema protoTableField) -
schemaToProtoTableSchema
public static com.google.cloud.bigquery.storage.v1.TableSchema schemaToProtoTableSchema(com.google.api.services.bigquery.model.TableSchema tableSchema) -
tableFieldToProtoTableField
public static com.google.cloud.bigquery.storage.v1.TableFieldSchema tableFieldToProtoTableField(com.google.api.services.bigquery.model.TableFieldSchema field) -
getDescriptorFromTableSchema
public static Descriptors.Descriptor getDescriptorFromTableSchema(com.google.api.services.bigquery.model.TableSchema jsonSchema, boolean respectRequired, boolean includeCdcColumns) throws Descriptors.DescriptorValidationException -
getDescriptorFromTableSchema
public static Descriptors.Descriptor getDescriptorFromTableSchema(com.google.cloud.bigquery.storage.v1.TableSchema tableSchema, boolean respectRequired, boolean includeCdcColumns) throws Descriptors.DescriptorValidationException Given a BigQuery TableSchema, returns a protocol-buffer Descriptor that can be used to write data using the BigQuery Storage API. -
wrapDescriptorProto
public static Descriptors.Descriptor wrapDescriptorProto(DescriptorProtos.DescriptorProto descriptorProto) throws Descriptors.DescriptorValidationException -
messageFromMap
public static @Nullable DynamicMessage messageFromMap(TableRowToStorageApiProto.SchemaInformation schemaInformation, @Nullable Descriptors.Descriptor descriptor, AbstractMap<String, Object> map, boolean ignoreUnknownValues, boolean allowMissingRequiredFields, @Nullable com.google.api.services.bigquery.model.TableRow unknownFields, @Nullable String changeType, @Nullable String changeSequenceNum, TableRowToStorageApiProto.ErrorCollector collectedExceptions) throws org.apache.beam.sdk.io.gcp.bigquery.TableRowToStorageApiProto.SchemaConversionExceptionGiven a BigQuery row map, returns a protocol-buffer message for the BigQuery Storage API.When
allowMissingRequiredFieldsis true, this method returns a partial protocol-buffer message if required fields are absent. When it is false, required-field validation and its conversion errors remain unchanged.- Throws:
org.apache.beam.sdk.io.gcp.bigquery.TableRowToStorageApiProto.SchemaConversionException
-
messageFromTableRow
public static @Nullable DynamicMessage messageFromTableRow(TableRowToStorageApiProto.SchemaInformation schemaInformation, @Nullable Descriptors.Descriptor descriptor, com.google.api.services.bigquery.model.TableRow tableRow, boolean ignoreUnknownValues, boolean allowMissingRequiredFields, @Nullable com.google.api.services.bigquery.model.TableRow unknownFields, @Nullable String changeType, long changeSequenceNum, TableRowToStorageApiProto.ErrorCollector collectedExceptions) throws org.apache.beam.sdk.io.gcp.bigquery.TableRowToStorageApiProto.SchemaConversionException ForwardschangeSequenceNumtomessageFromTableRow(SchemaInformation, Descriptor, TableRow, boolean, boolean, TableRow, String, String, ErrorCollector)viaLong.toHexString(long).When
allowMissingRequiredFieldsis true, this method returns a partial protocol-buffer message if required fields are absent. When it is false, required-field validation and its conversion errors remain unchanged.- Throws:
org.apache.beam.sdk.io.gcp.bigquery.TableRowToStorageApiProto.SchemaConversionException
-
messageFromTableRow
public static @Nullable DynamicMessage messageFromTableRow(TableRowToStorageApiProto.SchemaInformation schemaInformation, @Nullable Descriptors.Descriptor descriptor, com.google.api.services.bigquery.model.TableRow tableRow, boolean ignoreUnknownValues, boolean allowMissingRequiredFields, @Nullable com.google.api.services.bigquery.model.TableRow unknownFields, @Nullable String changeType, @Nullable String changeSequenceNum, TableRowToStorageApiProto.ErrorCollector collectedExceptions) throws org.apache.beam.sdk.io.gcp.bigquery.TableRowToStorageApiProto.SchemaConversionException Given a BigQuery TableRow, returns a protocol-buffer message that can be used to write data using the BigQuery Storage API.When
allowMissingRequiredFieldsis true, this method returns a partial protocol-buffer message if required fields are absent. When it is false, required-field validation and its conversion errors remain unchanged.- Throws:
org.apache.beam.sdk.io.gcp.bigquery.TableRowToStorageApiProto.SchemaConversionException
-
mergeNewFields
public static ByteString mergeNewFields(ByteString tableRowProto, DescriptorProtos.DescriptorProto descriptorProto, com.google.cloud.bigquery.storage.v1.TableSchema tableSchema, TableRowToStorageApiProto.SchemaInformation schemaInformation, com.google.api.services.bigquery.model.TableRow unknownFields, boolean ignoreUnknownValues) throws org.apache.beam.sdk.io.gcp.bigquery.TableRowToStorageApiProto.SchemaConversionException - Throws:
org.apache.beam.sdk.io.gcp.bigquery.TableRowToStorageApiProto.SchemaConversionException
-
mergeNewFields
public static ByteString mergeNewFields(ByteString tableRowProto, Descriptors.Descriptor descriptor, Descriptors.Descriptor descriptorIgnoreRequired, TableRowToStorageApiProto.SchemaInformation schemaInformation, com.google.api.services.bigquery.model.TableRow unknownFields, boolean ignoreUnknownValues) throws org.apache.beam.sdk.io.gcp.bigquery.TableRowToStorageApiProto.SchemaConversionException - Throws:
org.apache.beam.sdk.io.gcp.bigquery.TableRowToStorageApiProto.SchemaConversionException
-
tableRowFromMessage
public static com.google.api.services.bigquery.model.TableRow tableRowFromMessage(TableRowToStorageApiProto.SchemaInformation schemaInformation, Message message, boolean includeCdcColumns, Predicate<String> includeField) -
tableRowFromMessage
public static com.google.api.services.bigquery.model.TableRow tableRowFromMessage(TableRowToStorageApiProto.SchemaInformation schemaInformation, Message message, boolean includeCdcColumns, Predicate<String> includeField, String namePrefix) -
tableRowFromMessageUseSetF
public static com.google.api.services.bigquery.model.TableRow tableRowFromMessageUseSetF(TableRowToStorageApiProto.SchemaInformation schemaInformation, Message message, boolean includeCdcColumns, Predicate<String> includeField, String namePrefix) -
jsonValueFromMessageValue
public static Object jsonValueFromMessageValue(TableRowToStorageApiProto.SchemaInformation schemaInformation, Descriptors.FieldDescriptor fieldDescriptor, Object fieldValue, boolean expandRepeated, Predicate<String> includeField, String prefix, boolean useSetF)
-