Skip to content
This repository was archived by the owner on Mar 23, 2026. It is now read-only.

Commit f94d5be

Browse files
committed
fix: update TableInsertRows.java
Make the example set row id in `addRow`. If row id is missed, it disable the retry b/280865468, which I believe an unexpected behavior to users.
1 parent 19b7c3a commit f94d5be

1 file changed

Lines changed: 5 additions & 5 deletions

File tree

samples/snippets/src/main/java/com/example/bigquery/TableInsertRows.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,13 @@ public static void main(String[] args) {
3939
Map<String, Object> rowContent = new HashMap<>();
4040
rowContent.put("booleanField", true);
4141
rowContent.put("numericField", "3.14");
42-
42+
// TODO(developer): Replace the row id with a unique value for each row.
43+
String rowId = "ROW_ID";
4344
tableInsertRows(datasetName, tableName, rowContent);
4445
}
4546

4647
public static void tableInsertRows(
47-
String datasetName, String tableName, Map<String, Object> rowContent) {
48+
String datasetName, String tableName, String rowId, Map<String, Object> rowContent) {
4849
try {
4950
// Initialize client that will be used to send requests. This client only needs to be created
5051
// once, and can be reused for multiple requests.
@@ -58,9 +59,8 @@ public static void tableInsertRows(
5859
bigquery.insertAll(
5960
InsertAllRequest.newBuilder(tableId)
6061
// More rows can be added in the same RPC by invoking .addRow() on the builder.
61-
// You can also supply optional unique row keys to support de-duplication
62-
// scenarios.
63-
.addRow(rowContent)
62+
// You can omit the unique row ids to disable de-duplication.
63+
.addRow(rowId, rowContent)
6464
.build());
6565

6666
if (response.hasErrors()) {

0 commit comments

Comments
 (0)