From b72015f71ec21255e6e863058569107bd93ca06e Mon Sep 17 00:00:00 2001 From: Veronica Wasson <3992422+MikeWasson@users.noreply.github.com> Date: Tue, 28 Sep 2021 21:17:55 +0000 Subject: [PATCH 1/6] fix: Sample should show sending multiple rows in one request --- .../bigquerystorage/WriteCommittedStream.java | 14 ++++++++------ .../bigquerystorage/WritePendingStream.java | 13 +++++++------ .../bigquerystorage/WriteToDefaultStream.java | 13 +++++++------ 3 files changed, 22 insertions(+), 18 deletions(-) diff --git a/samples/snippets/src/main/java/com/example/bigquerystorage/WriteCommittedStream.java b/samples/snippets/src/main/java/com/example/bigquerystorage/WriteCommittedStream.java index ea1ac9ccd1..63ff782924 100644 --- a/samples/snippets/src/main/java/com/example/bigquerystorage/WriteCommittedStream.java +++ b/samples/snippets/src/main/java/com/example/bigquerystorage/WriteCommittedStream.java @@ -64,17 +64,19 @@ public static void writeCommittedStream(String projectId, String datasetName, St try (JsonStreamWriter writer = JsonStreamWriter.newBuilder(writeStream.getName(), writeStream.getTableSchema()) .build()) { - // Append 10 JSON objects to the stream. - for (int i = 0; i < 10; i++) { + // Write two batches to the stream, each with 10 JSON records. + for (int i = 0; i < 2; i++) { // Create a JSON object that is compatible with the table schema. - JSONObject record = new JSONObject(); - record.put("col1", String.format("record %03d", i)); JSONArray jsonArr = new JSONArray(); - jsonArr.put(record); + for (int j = 0; j < 10; j++) { + JSONObject record = new JSONObject(); + record.put("col1", String.format("record %03d-%03d", i, j)); + jsonArr.put(record); + } // To detect duplicate records, pass the index as the record offset. // To disable deduplication, omit the offset or use WriteStream.Type.DEFAULT. - ApiFuture future = writer.append(jsonArr, /*offset=*/ i); + ApiFuture future = writer.append(jsonArr, /*offset=*/ i * 10); AppendRowsResponse response = future.get(); } } diff --git a/samples/snippets/src/main/java/com/example/bigquerystorage/WritePendingStream.java b/samples/snippets/src/main/java/com/example/bigquerystorage/WritePendingStream.java index fc7b4c1af5..386f08a5d0 100644 --- a/samples/snippets/src/main/java/com/example/bigquerystorage/WritePendingStream.java +++ b/samples/snippets/src/main/java/com/example/bigquerystorage/WritePendingStream.java @@ -67,14 +67,15 @@ public static void writePendingStream(String projectId, String datasetName, Stri try (JsonStreamWriter writer = JsonStreamWriter.newBuilder(writeStream.getName(), writeStream.getTableSchema()) .build()) { - // Append 10 JSON objects to the stream. - for (int i = 0; i < 10; i++) { + // Write two batches to the stream, each with 10 JSON records. + for (int i = 0; i < 2; i++) { // Create a JSON object that is compatible with the table schema. - JSONObject record = new JSONObject(); - record.put("col1", String.format("batch-record %03d", i)); JSONArray jsonArr = new JSONArray(); - jsonArr.put(record); - + for (int j = 0; j < 10; j++) { + JSONObject record = new JSONObject(); + record.put("col1", String.format("batch-record %03d-%03d", i, j)); + jsonArr.put(record); + } ApiFuture future = writer.append(jsonArr); AppendRowsResponse response = future.get(); } diff --git a/samples/snippets/src/main/java/com/example/bigquerystorage/WriteToDefaultStream.java b/samples/snippets/src/main/java/com/example/bigquerystorage/WriteToDefaultStream.java index 2241c91bba..a06b113b3b 100644 --- a/samples/snippets/src/main/java/com/example/bigquerystorage/WriteToDefaultStream.java +++ b/samples/snippets/src/main/java/com/example/bigquerystorage/WriteToDefaultStream.java @@ -56,14 +56,15 @@ public static void writeToDefaultStream(String projectId, String datasetName, St // https://googleapis.dev/java/google-cloud-bigquerystorage/latest/com/google/cloud/bigquery/storage/v1beta2/JsonStreamWriter.html try (JsonStreamWriter writer = JsonStreamWriter.newBuilder(parentTable.toString(), tableSchema).build()) { - // Append 10 JSON objects to the stream. - for (int i = 0; i < 10; i++) { + // Write two batches to the stream, each with 10 JSON records. + for (int i = 0; i < 2; i++) { // Create a JSON object that is compatible with the table schema. - JSONObject record = new JSONObject(); - record.put("test_string", String.format("record %03d", i)); JSONArray jsonArr = new JSONArray(); - jsonArr.put(record); - + for (int j = 0; j < 10; j++) { + JSONObject record = new JSONObject(); + record.put("test_string", String.format("record %03d-%03d", i, j)); + jsonArr.put(record); + } ApiFuture future = writer.append(jsonArr); AppendRowsResponse response = future.get(); } From fb06c6db1684b958eb232ce629c57e7522b78c24 Mon Sep 17 00:00:00 2001 From: Owl Bot Date: Thu, 30 Sep 2021 16:37:48 +0000 Subject: [PATCH 2/6] =?UTF-8?q?=F0=9F=A6=89=20Updates=20from=20OwlBot?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index f1c0fd65dd..7d33937c41 100644 --- a/README.md +++ b/README.md @@ -49,7 +49,7 @@ If you are using Maven without BOM, add this to your dependencies: If you are using Gradle 5.x or later, add this to your dependencies ```Groovy -implementation platform('com.google.cloud:libraries-bom:23.0.0') +implementation platform('com.google.cloud:libraries-bom:23.1.0') implementation 'com.google.cloud:google-cloud-bigquerystorage' ``` From c82def18ac984403b48ecf46aa017476db0e278e Mon Sep 17 00:00:00 2001 From: Stephanie Wang Date: Mon, 4 Oct 2021 10:09:29 -0400 Subject: [PATCH 3/6] Update README.md From 8016ba8edbede226a6416a1601129d23cf89ada7 Mon Sep 17 00:00:00 2001 From: Owl Bot Date: Mon, 4 Oct 2021 18:13:32 +0000 Subject: [PATCH 4/6] =?UTF-8?q?=F0=9F=A6=89=20Updates=20from=20OwlBot?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 7d33937c41..952eba4877 100644 --- a/README.md +++ b/README.md @@ -56,13 +56,13 @@ implementation 'com.google.cloud:google-cloud-bigquerystorage' If you are using Gradle without BOM, add this to your dependencies ```Groovy -implementation 'com.google.cloud:google-cloud-bigquerystorage:2.3.1' +implementation 'com.google.cloud:google-cloud-bigquerystorage:2.3.2' ``` If you are using SBT, add this to your dependencies ```Scala -libraryDependencies += "com.google.cloud" % "google-cloud-bigquerystorage" % "2.3.1" +libraryDependencies += "com.google.cloud" % "google-cloud-bigquerystorage" % "2.3.2" ``` ## Authentication From f5a9e9b32bc291f9db00173d996d2cff1ae353c8 Mon Sep 17 00:00:00 2001 From: Owl Bot Date: Mon, 4 Oct 2021 18:13:45 +0000 Subject: [PATCH 5/6] =?UTF-8?q?=F0=9F=A6=89=20Updates=20from=20OwlBot?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 7d33937c41..952eba4877 100644 --- a/README.md +++ b/README.md @@ -56,13 +56,13 @@ implementation 'com.google.cloud:google-cloud-bigquerystorage' If you are using Gradle without BOM, add this to your dependencies ```Groovy -implementation 'com.google.cloud:google-cloud-bigquerystorage:2.3.1' +implementation 'com.google.cloud:google-cloud-bigquerystorage:2.3.2' ``` If you are using SBT, add this to your dependencies ```Scala -libraryDependencies += "com.google.cloud" % "google-cloud-bigquerystorage" % "2.3.1" +libraryDependencies += "com.google.cloud" % "google-cloud-bigquerystorage" % "2.3.2" ``` ## Authentication From c1e8f61df5a968d4b8ca782484e2a9f819537041 Mon Sep 17 00:00:00 2001 From: Owl Bot Date: Mon, 4 Oct 2021 18:13:51 +0000 Subject: [PATCH 6/6] =?UTF-8?q?=F0=9F=A6=89=20Updates=20from=20OwlBot?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 7d33937c41..952eba4877 100644 --- a/README.md +++ b/README.md @@ -56,13 +56,13 @@ implementation 'com.google.cloud:google-cloud-bigquerystorage' If you are using Gradle without BOM, add this to your dependencies ```Groovy -implementation 'com.google.cloud:google-cloud-bigquerystorage:2.3.1' +implementation 'com.google.cloud:google-cloud-bigquerystorage:2.3.2' ``` If you are using SBT, add this to your dependencies ```Scala -libraryDependencies += "com.google.cloud" % "google-cloud-bigquerystorage" % "2.3.1" +libraryDependencies += "com.google.cloud" % "google-cloud-bigquerystorage" % "2.3.2" ``` ## Authentication