rdblue commented on a change in pull request #2465:
URL: https://github.com/apache/iceberg/pull/2465#discussion_r615320049
##########
File path: core/src/test/java/org/apache/iceberg/TestTableMetadata.java
##########
@@ -646,6 +646,34 @@ public void testUpdateSortOrder() {
NullOrder.NULLS_FIRST,
sortedByX.sortOrder().fields().get(0).nullOrder());
}
+ @Test
+ public void testParseSchemaIdentifierFields() throws Exception {
+ String data = readTableMetadataInputFile("TableMetadataV2Valid.json");
+ TableMetadata parsed = TableMetadataParser.fromJson(
+ ops.io(), null, JsonUtil.mapper().readValue(data, JsonNode.class));
+ Assert.assertEquals(Sets.newHashSet(),
parsed.schemasById().get(0).identifierFieldIds());
+ Assert.assertEquals(Sets.newHashSet(1, 2),
parsed.schemasById().get(1).identifierFieldIds());
+ }
+
+ @Test
+ public void testUpdateSchemaIdentifierFields() {
+ Schema schema = new Schema(
+ Types.NestedField.required(10, "x", Types.StringType.get())
+ );
+
+ TableMetadata meta = TableMetadata.newTableMetadata(
+ schema, PartitionSpec.unpartitioned(), null, ImmutableMap.of());
+ Assert.assertTrue("Should default to no identifier field",
meta.schema().identifierFieldIds().isEmpty());
Review comment:
I don't think this is correct, or if it is then it isn't testing
`TableMetadata`. The `newTableMetadata` result should use whatever identifier
fields were set in the schema. So this is really validating that the schema
didn't create identifier fields without them being passed in.
--
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.
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]