Package com.google.cloud.bigquery
Class InsertAllRequest.Builder
- java.lang.Object
-
- com.google.cloud.bigquery.InsertAllRequest.Builder
-
- Enclosing class:
- InsertAllRequest
public static final class InsertAllRequest.Builder extends Object
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description InsertAllRequest.Builder
addRow(InsertAllRequest.RowToInsert rowToInsert)
Adds a row to be inserted.InsertAllRequest.Builder
addRow(String id, Map<String,?> content)
Adds a row to be inserted with associated id.InsertAllRequest.Builder
addRow(Map<String,?> content)
Adds a row to be inserted without an associated id.InsertAllRequest
build()
Creates anInsertAllRequest
object.InsertAllRequest.Builder
setIgnoreUnknownValues(boolean ignoreUnknownValues)
Sets whether to accept rows that contain values that do not match the schema.InsertAllRequest.Builder
setRows(Iterable<InsertAllRequest.RowToInsert> rows)
Sets the rows to insert as a list ofInsertAllRequest.RowToInsert
objects.InsertAllRequest.Builder
setSkipInvalidRows(boolean skipInvalidRows)
Sets whether to insert all valid rows of a request, even if invalid rows exist.InsertAllRequest.Builder
setTable(TableId table)
Sets the destination table for rows insert request.InsertAllRequest.Builder
setTemplateSuffix(String templateSuffix)
If specified, the destination table is treated as a base template.
-
-
-
Method Detail
-
setTable
public InsertAllRequest.Builder setTable(TableId table)
Sets the destination table for rows insert request.
-
setRows
public InsertAllRequest.Builder setRows(Iterable<InsertAllRequest.RowToInsert> rows)
Sets the rows to insert as a list ofInsertAllRequest.RowToInsert
objects.
-
addRow
public InsertAllRequest.Builder addRow(InsertAllRequest.RowToInsert rowToInsert)
Adds a row to be inserted.
-
addRow
public InsertAllRequest.Builder addRow(String id, Map<String,?> content)
Adds a row to be inserted with associated id.To ensure proper serialization of numeric data, supply values using a string-typed representation. Additionally, data for fields of
LegacySQLTypeName.BYTES
must be provided as a base64 encoded string.Example usage of adding a row with associated id:
InsertAllRequest.Builder builder = InsertAllRequest.builder(tableId); List<Long> repeatedFieldValue = Arrays.asList(1L, 2L); Map<String, Object> recordContent = new HashMap<String, Object>(); recordContent.put("subfieldName1", "value"); recordContent.put("subfieldName2", repeatedFieldValue); Map<String, Object> rowContent = new HashMap<String, Object>(); rowContent.put("booleanFieldName", true); rowContent.put("bytesFieldName", "DQ4KDQ=="); rowContent.put("recordFieldName", recordContent); rowContent.put("numericFieldName", "1298930929292.129593272"); builder.addRow("rowId", rowContent);
-
addRow
public InsertAllRequest.Builder addRow(Map<String,?> content)
Adds a row to be inserted without an associated id.To ensure proper serialization of numeric data, it is recommended to supply values using a string-typed representation. Additionally, data for fields of type
LegacySQLTypeName.BYTES
must be provided as a base64 encoded string.Example usage of adding a row without an associated id:
InsertAllRequest.Builder builder = InsertAllRequest.builder(tableId); List<Long> repeatedFieldValue = Arrays.asList(1L, 2L); Map<String, Object> recordContent = new HashMap<String, Object>(); recordContent.put("subfieldName1", "value"); recordContent.put("subfieldName2", repeatedFieldValue); Map<String, Object> rowContent = new HashMap<String, Object>(); rowContent.put("booleanFieldName", true); rowContent.put("bytesFieldName", "DQ4KDQ=="); rowContent.put("recordFieldName", recordContent); rowContent.put("numericFieldName", "1298930929292.129593272"); builder.addRow(rowContent);
-
setSkipInvalidRows
public InsertAllRequest.Builder setSkipInvalidRows(boolean skipInvalidRows)
Sets whether to insert all valid rows of a request, even if invalid rows exist. If not set the entire insert request will fail if it contains an invalid row.
-
setIgnoreUnknownValues
public InsertAllRequest.Builder setIgnoreUnknownValues(boolean ignoreUnknownValues)
Sets whether to accept rows that contain values that do not match the schema. The unknown values are ignored. If not set, rows with unknown values are considered to be invalid.
-
setTemplateSuffix
public InsertAllRequest.Builder setTemplateSuffix(String templateSuffix)
If specified, the destination table is treated as a base template. Rows are inserted into an instance table named "{destination}{templateSuffix}". BigQuery will manage the creation of the instance table, using the schema of the base template table. Table creation might take some time. To obtain table's information afterBigQuery.insertAll(InsertAllRequest)
is called use:String suffixTableId = ...; TableInfo suffixTable = bigquery.getTable(DATASET, suffixTableId); while (suffixTable == null) { Thread.sleep(1000L); suffixTable = bigquery.getTable(DATASET, suffixTableId); }
- See Also:
- Template Tables
-
build
public InsertAllRequest build()
Creates anInsertAllRequest
object.
-
-