public static final class InsertAllRequest.Builder
Methods
addRow(InsertAllRequest.RowToInsert rowToInsert)
public InsertAllRequest.Builder addRow(InsertAllRequest.RowToInsert rowToInsert)
Adds a row to be inserted.
Name | Description |
rowToInsert | InsertAllRequest.RowToInsert |
Type | Description |
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);
Name | Description |
id | String |
content | Map<String,?> |
Type | Description |
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);
Name | Description |
content | Map<String,?> |
Type | Description |
InsertAllRequest.Builder |
build()
public InsertAllRequest build()
Creates an InsertAllRequest
object.
Type | Description |
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.
Name | Description |
ignoreUnknownValues | boolean |
Type | Description |
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.
Name | Description |
rows | Iterable<RowToInsert> |
Type | Description |
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.
Name | Description |
skipInvalidRows | boolean |
Type | Description |
InsertAllRequest.Builder |
setTable(TableId table)
public InsertAllRequest.Builder setTable(TableId table)
Sets the destination table for rows insert request.
Name | Description |
table | TableId |
Type | Description |
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
Name | Description |
templateSuffix | String |
Type | Description |
InsertAllRequest.Builder |