Class InsertAllRequest.Builder (2.36.0)

public static final class InsertAllRequest.Builder

Inheritance

java.lang.Object > InsertAllRequest.Builder

Methods

addRow(InsertAllRequest.RowToInsert rowToInsert)

public InsertAllRequest.Builder addRow(InsertAllRequest.RowToInsert rowToInsert)

Adds a row to be inserted.

Parameter
NameDescription
rowToInsertInsertAllRequest.RowToInsert
Returns
TypeDescription
InsertAllRequest.Builder

addRow(String id, Map<String,?> content)

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);
 
Parameters
NameDescription
idString
contentMap<String,?>
Returns
TypeDescription
InsertAllRequest.Builder

addRow(Map<String,?> content)

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);
 
Parameter
NameDescription
contentMap<String,?>
Returns
TypeDescription
InsertAllRequest.Builder

build()

public InsertAllRequest build()

Creates an InsertAllRequest object.

Returns
TypeDescription
InsertAllRequest

setIgnoreUnknownValues(boolean ignoreUnknownValues)

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.

Parameter
NameDescription
ignoreUnknownValuesboolean
Returns
TypeDescription
InsertAllRequest.Builder

setRows(Iterable<InsertAllRequest.RowToInsert> rows)

public InsertAllRequest.Builder setRows(Iterable<InsertAllRequest.RowToInsert> rows)

Sets the rows to insert as a list of RowToInsert objects.

Parameter
NameDescription
rowsIterable<RowToInsert>
Returns
TypeDescription
InsertAllRequest.Builder

setSkipInvalidRows(boolean skipInvalidRows)

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.

Parameter
NameDescription
skipInvalidRowsboolean
Returns
TypeDescription
InsertAllRequest.Builder

setTable(TableId table)

public InsertAllRequest.Builder setTable(TableId table)

Sets the destination table for rows insert request.

Parameter
NameDescription
tableTableId
Returns
TypeDescription
InsertAllRequest.Builder

setTemplateSuffix(String templateSuffix)

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 after BigQuery#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

Parameter
NameDescription
templateSuffixString
Returns
TypeDescription
InsertAllRequest.Builder