public class BigQueryTableInserter extends Object
| Constructor and Description |
|---|
BigQueryTableInserter(com.google.api.services.bigquery.Bigquery client,
com.google.api.services.bigquery.model.TableReference ref)
Constructs a new row inserter.
|
BigQueryTableInserter(com.google.api.services.bigquery.Bigquery client,
com.google.api.services.bigquery.model.TableReference ref,
int maxRowsPerBatch)
Constructs a new row inserter.
|
| Modifier and Type | Method and Description |
|---|---|
com.google.api.services.bigquery.model.Table |
getOrCreateTable(BigQueryIO.Write.WriteDisposition writeDisposition,
BigQueryIO.Write.CreateDisposition createDisposition,
com.google.api.services.bigquery.model.TableSchema schema)
Retrieves or creates the table.
|
void |
insertAll(List<com.google.api.services.bigquery.model.TableRow> rowList)
Insert all rows from the given list.
|
void |
insertAll(List<com.google.api.services.bigquery.model.TableRow> rowList,
List<String> insertIdList)
Insert all rows from the given list using specified insertIds if not null.
|
boolean |
isEmpty()
Checks if a table is empty.
|
com.google.api.services.bigquery.model.Table |
tryCreateTable(com.google.api.services.bigquery.model.TableSchema schema)
Tries to create the BigQuery table.
|
public BigQueryTableInserter(com.google.api.services.bigquery.Bigquery client,
com.google.api.services.bigquery.model.TableReference ref)
client - a BigQuery clientref - identifies the table to insert intopublic BigQueryTableInserter(com.google.api.services.bigquery.Bigquery client,
com.google.api.services.bigquery.model.TableReference ref,
int maxRowsPerBatch)
client - a BigQuery clientref - identifies the table to insert intopublic void insertAll(List<com.google.api.services.bigquery.model.TableRow> rowList) throws IOException
IOExceptionpublic void insertAll(List<com.google.api.services.bigquery.model.TableRow> rowList, @Nullable List<String> insertIdList) throws IOException
IOExceptionpublic com.google.api.services.bigquery.model.Table getOrCreateTable(BigQueryIO.Write.WriteDisposition writeDisposition, BigQueryIO.Write.CreateDisposition createDisposition, @Nullable com.google.api.services.bigquery.model.TableSchema schema) throws IOException
The table is checked to conform to insertion requirements as specified by WriteDisposition and CreateDisposition.
If table truncation is requested (WriteDisposition.WRITE_TRUNCATE), then this will re-create the table if necessary to ensure it is empty.
If an empty table is required (WriteDisposition.WRITE_EMPTY), then this will fail if the table exists and is not empty.
When constructing a table, a TableSchema must be available. If a
schema is provided, then it will be used. If no schema is provided, but
an existing table is being cleared (WRITE_TRUNCATE option above), then
the existing schema will be re-used. If no schema is available, then an
IOException is thrown.
IOExceptionpublic boolean isEmpty()
throws IOException
IOException@Nullable public com.google.api.services.bigquery.model.Table tryCreateTable(com.google.api.services.bigquery.model.TableSchema schema) throws IOException
schema - Schema of the new BigQuery table.IOException - if other error than already existing table occurs.