bigquery.insertAll( InsertAllRequest.newBuilder(tableId) .addRow("rowId", rowContent)
/** * Adds a row to be inserted without an associated id. Please notice that data for fields of * type {@link LegacySQLTypeName#BYTES} must be provided as a base64 encoded string. * * <p>Example usage of adding a row without an associated id: * * <pre>{@code * 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); * builder.addRow(rowContent); * }</pre> */ public Builder addRow(Map<String, ?> content) { addRow(new RowToInsert(null, content)); return this; }
/** * Adds a row to be inserted with associated id. Please notice that data for fields of type * {@link Field.Type#bytes()} must be provided as a base64 encoded string. * * <p>Example usage of adding a row with associated id: * <pre> {@code * 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); * builder.addRow("rowId", rowContent); * }</pre> */ public Builder addRow(String id, Map<String, Object> content) { addRow(new RowToInsert(id, content)); return this; }
/** * Adds a row to be inserted without an associated id. Please notice that data for fields of * type {@link Field.Type#bytes()} must be provided as a base64 encoded string. * * <p>Example usage of adding a row without an associated id: * <pre> {@code * 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); * builder.addRow(rowContent); * }</pre> */ public Builder addRow(Map<String, Object> content) { addRow(new RowToInsert(null, content)); return this; }
/** * Adds a row to be inserted with associated id. Please notice that data for fields of type * {@link LegacySQLTypeName#BYTES} must be provided as a base64 encoded string. * * <p>Example usage of adding a row with associated id: * * <pre>{@code * 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); * builder.addRow("rowId", rowContent); * }</pre> */ public Builder addRow(String id, Map<String, ?> content) { addRow(new RowToInsert(id, content)); return this; }
/** Inserts multiple rows of the same schema to a BigQuery table. */ public void insertAll(Collection<Map<String, ?>> rows, String table) { TableId tableId = TableId.of(projectId, dataset, table); InsertAllRequest.Builder builder = InsertAllRequest.newBuilder(tableId); for (Map<String, ?> row : rows) { builder.addRow(row); } InsertAllResponse response = client.insertAll(builder.build()); handleBigQueryResponseExceptions(response); }
/** * Adds a row to be inserted with associated id. Please notice that data for fields of type * {@link LegacySQLTypeName#BYTES} must be provided as a base64 encoded string. * * <p>Example usage of adding a row with associated id: * * <pre>{@code * 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); * builder.addRow("rowId", rowContent); * }</pre> */ public Builder addRow(String id, Map<String, ?> content) { addRow(new RowToInsert(id, content)); return this; }
/** * Adds a row to be inserted without an associated id. Please notice that data for fields of * type {@link LegacySQLTypeName#BYTES} must be provided as a base64 encoded string. * * <p>Example usage of adding a row without an associated id: * * <pre>{@code * 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); * builder.addRow(rowContent); * }</pre> */ public Builder addRow(Map<String, ?> content) { addRow(new RowToInsert(null, content)); return this; }