public class BigQueryUtils
extends java.lang.Object
Example: Writing to BigQuery
PCollection<Row> rows = ...;
rows.apply(BigQueryIO.<Row>write()
.withSchema(BigQueryUtils.toTableSchema(rows))
.withFormatFunction(BigQueryUtils.toTableRow())
.to("my-project:my_dataset.my_table"));
Constructor and Description |
---|
BigQueryUtils() |
Modifier and Type | Method and Description |
---|---|
static Row |
toBeamRow(GenericRecord record,
Schema schema) |
static SerializableFunction<SchemaAndRecord,Row> |
toBeamRow(Schema schema)
Convert
SchemaAndRecord to a Beam Row . |
static Row |
toBeamRow(Schema rowSchema,
TableSchema bqSchema,
TableRow jsonBqRow)
Tries to parse the JSON
TableRow from BigQuery. |
static SerializableFunction<Row,TableRow> |
toTableRow()
|
static TableRow |
toTableRow(Row row) |
static TableSchema |
toTableSchema(PCollection<Row> rows)
Convert a Beam
PCollection to a BigQuery TableSchema . |
static TableSchema |
toTableSchema(Schema schema)
Convert a Beam
Schema to a BigQuery TableSchema . |
public static TableSchema toTableSchema(Schema schema)
Schema
to a BigQuery TableSchema
.public static TableSchema toTableSchema(PCollection<Row> rows)
PCollection
to a BigQuery TableSchema
.public static SerializableFunction<Row,TableRow> toTableRow()
public static SerializableFunction<SchemaAndRecord,Row> toBeamRow(Schema schema)
SchemaAndRecord
to a Beam Row
.public static Row toBeamRow(GenericRecord record, Schema schema)
public static Row toBeamRow(Schema rowSchema, TableSchema bqSchema, TableRow jsonBqRow)
TableRow
from BigQuery.
Only supports basic types and arrays. Doesn't support date types.