ahmedabu98 commented on code in PR #34102:
URL: https://github.com/apache/beam/pull/34102#discussion_r1977311213
##########
sdks/java/io/google-cloud-platform/src/test/java/org/apache/beam/sdk/io/gcp/bigquery/TableRowToStorageApiProtoTest.java:
##########
@@ -1671,6 +1672,44 @@ public void testIgnoreUnknownRepeatedNestedField()
throws Exception {
assertEquals("foobar_doubly_nested",
unknownDoublyNestedStruct.get("unknown_doubly_nested"));
}
+ @Test
+ public void testIgnoreUnknownRepeatedNestedField2() throws Exception {
+
+ List<TableFieldSchema> fields = new ArrayList<>();
+ fields.add(new TableFieldSchema().setName("foo").setType("STRING"));
+ fields.add(
+ new TableFieldSchema()
+ .setName("repeated1")
+ .setMode("REPEATED")
+ .setType("RECORD")
+ .setFields(
+ ImmutableList.of(
+ new
TableFieldSchema().setName("key1").setType("STRING").setMode("REQUIRED"),
+ new
TableFieldSchema().setName("key2").setType("STRING"))));
+ TableSchema schema = new TableSchema().setFields(fields);
+ TableRow tableRow =
+ new TableRow()
+ .set("foo", "bar")
+ .set(
+ "repeated1",
+ ImmutableList.of(
+ new TableCell().set("key1", "valueA").set("key2",
"valueC"),
+ new TableCell().set("key1", "valueB").set("key2",
"valueD")));
+
+ Descriptor descriptor =
+ TableRowToStorageApiProto.getDescriptorFromTableSchema(schema, true,
false);
+ TableRowToStorageApiProto.SchemaInformation schemaInformation =
+ TableRowToStorageApiProto.SchemaInformation.fromTableSchema(schema);
+ TableRow unknown = new TableRow();
+ DynamicMessage msg =
+ TableRowToStorageApiProto.messageFromTableRow(
+ schemaInformation, descriptor, tableRow, true, false, unknown,
null, -1);
+ assertEquals(2, msg.getAllFields().size());
+
+ System.out.println(unknown);
Review Comment:
p.s. cleanup
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]