Package com.google.cloud.bigquery
Class InsertAllRequest.Builder
java.lang.Object
com.google.cloud.bigquery.InsertAllRequest.Builder
- Enclosing class:
- InsertAllRequest
-
Method Summary
Modifier and TypeMethodDescriptionaddRow
(InsertAllRequest.RowToInsert rowToInsert) Adds a row to be inserted.Adds a row to be inserted with associated id.Adds a row to be inserted without an associated id.build()
Creates anInsertAllRequest
object.setIgnoreUnknownValues
(boolean ignoreUnknownValues) Sets whether to accept rows that contain values that do not match the schema.Sets the rows to insert as a list ofInsertAllRequest.RowToInsert
objects.setSkipInvalidRows
(boolean skipInvalidRows) Sets whether to insert all valid rows of a request, even if invalid rows exist.Sets the destination table for rows insert request.setTemplateSuffix
(String templateSuffix) If specified, the destination table is treated as a base template.
-
Method Details
-
setTable
Sets the destination table for rows insert request. -
setRows
Sets the rows to insert as a list ofInsertAllRequest.RowToInsert
objects. -
addRow
Adds a row to be inserted. -
addRow
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
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
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
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
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:
-
build
Creates anInsertAllRequest
object.
-