derrickaw commented on code in PR #35567:
URL: https://github.com/apache/beam/pull/35567#discussion_r2216877109


##########
sdks/java/io/google-cloud-platform/src/main/java/org/apache/beam/sdk/io/gcp/bigquery/BigQueryServicesImpl.java:
##########
@@ -1317,6 +1357,39 @@ <T> long insertAll(
       }
     }
 
+    /**
+     * Validates a {@link TableRow} for logging, comparing the provided row 
against a BigQuery
+     * schema. The formatted string shows the field names in the row 
indicating any mismatches
+     * unknown entries.
+     *
+     * <p>For example, a {@link TableRow} with a "names" and "age" fields, 
where the schema expects
+     * "name" and "age" would return "name".
+     *
+     * <pre>{@code {'name': java.lang.String, 'age': java.lang.Integer}}</pre>
+     *
+     * <p>If a field exists in the row but not in the schema, it's marked as 
"Unknown fields".

Review Comment:
   done, thanks



##########
sdks/java/io/google-cloud-platform/src/test/java/org/apache/beam/sdk/io/gcp/bigquery/BigQueryServicesImplTest.java:
##########
@@ -1164,7 +1164,73 @@ public void 
testInsertWithinRequestByteSizeLimitsErrorsOut() throws Exception {
                     false,
                     successfulRows));
 
-    assertThat(e.getMessage(), containsString("exceeded BigQueryIO limit of 
9MB."));
+    assertThat(e.getMessage(), containsString("exceeding the BigQueryIO 
limit"));
+  }
+
+  /**
+   * Tests that {@link DatasetServiceImpl#insertAll} does not go over limit of 
rows per request and
+   * schema difference check.
+   */
+  @SuppressWarnings("InlineMeInliner") // inline `Strings.repeat()` - Java 11+ 
API only
+  @Test
+  public void testInsertWithinRequestByteSizeLimitsWithBadSchemaErrorsOut() 
throws Exception {
+    TableReference ref =
+        new 
TableReference().setProjectId("project").setDatasetId("dataset").setTableId("tablersl");
+
+    TableSchema schema =
+        new TableSchema()
+            .setFields(ImmutableList.of(new 
TableFieldSchema().setName("rows").setType("STRING")));
+    Table testTable = new Table().setTableReference(ref).setSchema(schema);
+
+    List<FailsafeValueInSingleWindow<TableRow, TableRow>> rows =
+        ImmutableList.of(
+            wrapValue(new TableRow().set("row", Strings.repeat("abcdefghi", 
1024 * 1025))),
+            wrapValue(new TableRow().set("row", "a")),
+            wrapValue(new TableRow().set("row", "b")));

Review Comment:
   done, thanks



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscr...@beam.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to