public class BigQueryUtils
extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
static class |
BigQueryUtils.ConversionOptions
Options for how to convert BigQuery data to Beam data.
|
static class |
BigQueryUtils.SchemaConversionOptions
Options for how to convert BigQuery schemas to Beam schemas.
|
Constructor and Description |
---|
BigQueryUtils() |
Modifier and Type | Method and Description |
---|---|
static java.lang.Object |
convertAvroFormat(Schema.FieldType beamFieldType,
java.lang.Object avroValue,
BigQueryUtils.ConversionOptions options)
Tries to convert an Avro decoded value to a Beam field value based on the target type of the
Beam field.
|
static TableRow |
convertGenericRecordToTableRow(GenericRecord record,
TableSchema tableSchema) |
static Schema |
fromTableSchema(TableSchema tableSchema)
Convert a BigQuery
TableSchema to a Beam Schema . |
static Schema |
fromTableSchema(TableSchema tableSchema,
BigQueryUtils.SchemaConversionOptions options)
Convert a BigQuery
TableSchema to a Beam Schema . |
static org.apache.beam.sdk.io.gcp.bigquery.BigQueryIO.TypedRead.FromBeamRowFunction<TableRow> |
tableRowFromBeamRow() |
static org.apache.beam.sdk.io.gcp.bigquery.BigQueryIO.TypedRead.ToBeamRowFunction<TableRow> |
tableRowToBeamRow() |
static Row |
toBeamRow(GenericRecord record,
Schema schema,
BigQueryUtils.ConversionOptions options) |
static Row |
toBeamRow(Schema rowSchema,
TableRow jsonBqRow)
|
static Row |
toBeamRow(Schema rowSchema,
TableSchema bqSchema,
TableRow jsonBqRow)
Tries to parse the JSON
TableRow from BigQuery. |
static Schema |
toGenericAvroSchema(java.lang.String schemaName,
java.util.List<TableFieldSchema> fieldSchemas)
Convert a list of BigQuery
TableFieldSchema to Avro Schema . |
static SerializableFunction<Row,TableRow> |
toTableRow()
|
static TableRow |
toTableRow(Row row)
Convert a BigQuery TableRow to a Beam Row.
|
static <T> SerializableFunction<T,TableRow> |
toTableRow(SerializableFunction<T,Row> toRow)
Convert a Beam schema type to a BigQuery
TableRow . |
static TableSchema |
toTableSchema(Schema schema)
Convert a Beam
Schema to a BigQuery TableSchema . |
@Experimental(value=SCHEMAS) public static TableSchema toTableSchema(Schema schema)
Schema
to a BigQuery TableSchema
.@Experimental(value=SCHEMAS) public static Schema fromTableSchema(TableSchema tableSchema)
TableSchema
to a Beam Schema
.@Experimental(value=SCHEMAS) public static Schema fromTableSchema(TableSchema tableSchema, BigQueryUtils.SchemaConversionOptions options)
TableSchema
to a Beam Schema
.@Experimental(value=SCHEMAS) public static Schema toGenericAvroSchema(java.lang.String schemaName, java.util.List<TableFieldSchema> fieldSchemas)
TableFieldSchema
to Avro Schema
.public static final org.apache.beam.sdk.io.gcp.bigquery.BigQueryIO.TypedRead.ToBeamRowFunction<TableRow> tableRowToBeamRow()
public static final org.apache.beam.sdk.io.gcp.bigquery.BigQueryIO.TypedRead.FromBeamRowFunction<TableRow> tableRowFromBeamRow()
public static SerializableFunction<Row,TableRow> toTableRow()
public static <T> SerializableFunction<T,TableRow> toTableRow(SerializableFunction<T,Row> toRow)
TableRow
.@Experimental(value=SCHEMAS) public static Row toBeamRow(GenericRecord record, Schema schema, BigQueryUtils.ConversionOptions options)
public static TableRow convertGenericRecordToTableRow(GenericRecord record, TableSchema tableSchema)
@Experimental(value=SCHEMAS) public static Row toBeamRow(Schema rowSchema, TableRow jsonBqRow)
@Experimental(value=SCHEMAS) public static Row toBeamRow(Schema rowSchema, TableSchema bqSchema, TableRow jsonBqRow)
TableRow
from BigQuery.
Only supports basic types and arrays. Doesn't support date types.
public static java.lang.Object convertAvroFormat(Schema.FieldType beamFieldType, java.lang.Object avroValue, BigQueryUtils.ConversionOptions options)
For the Avro formats of BigQuery types, see https://cloud.google.com/bigquery/docs/exporting-data#avro_export_details and https://cloud.google.com/bigquery/docs/loading-data-cloud-storage-avro#avro_conversions