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 @Nullable org.apache.beam.runners.core.metrics.ServiceCallMetric |
readCallMetric(@Nullable TableReference tableReference) |
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 @Nullable TableReference |
toTableReference(java.lang.String fullTableId) |
static SerializableFunction<Row,TableRow> |
toTableRow()
|
static TableRow |
toTableRow(Row row)
Convert a Beam Row to a BigQuery TableRow.
|
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 . |
static @Nullable java.lang.String |
toTableSpec(TableReference tableReference) |
static org.apache.beam.runners.core.metrics.ServiceCallMetric |
writeCallMetric(TableReference tableReference) |
public static TableSchema toTableSchema(Schema schema)
Schema
to a BigQuery TableSchema
.public static Schema fromTableSchema(TableSchema tableSchema)
TableSchema
to a Beam Schema
.public static Schema fromTableSchema(TableSchema tableSchema, BigQueryUtils.SchemaConversionOptions options)
TableSchema
to a Beam Schema
.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
.public static Row toBeamRow(GenericRecord record, Schema schema, BigQueryUtils.ConversionOptions options)
public static TableRow convertGenericRecordToTableRow(GenericRecord record, TableSchema tableSchema)
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
public static @Nullable TableReference toTableReference(java.lang.String fullTableId)
fullTableId
- - Is one of the two forms commonly used to refer to bigquery tables in the
beam codebase:
public static @Nullable java.lang.String toTableSpec(TableReference tableReference)
tableReference
- - a BigQueryTableIdentifier that may or may not include the project.public static @Nullable org.apache.beam.runners.core.metrics.ServiceCallMetric readCallMetric(@Nullable TableReference tableReference)
tableReference
- - The table being read from. Can be a temporary BQ table used to read
from a SQL query.public static org.apache.beam.runners.core.metrics.ServiceCallMetric writeCallMetric(TableReference tableReference)
tableReference
- - The table being written to.