rdblue commented on a change in pull request #2284:
URL: https://github.com/apache/iceberg/pull/2284#discussion_r625441337
##########
File path: core/src/test/java/org/apache/iceberg/TestTableMetadata.java
##########
@@ -593,6 +593,74 @@ public void testInvalidUpdatePartitionSpecForV1Table()
throws Exception {
() -> metadata.updatePartitionSpec(spec));
}
+ @Test
+ public void testBuildReplacementForV1Table() {
+ Schema schema = new Schema(
+ Types.NestedField.required(1, "x", Types.LongType.get()),
+ Types.NestedField.required(2, "y", Types.LongType.get())
+ );
+ PartitionSpec spec = PartitionSpec.builderFor(schema).withSpecId(0)
+ .identity("x")
+ .identity("y")
+ .build();
+ String location = "file://tmp/db/table";
+ TableMetadata metadata = TableMetadata.newTableMetadata(
+ schema, spec, SortOrder.unsorted(), location, ImmutableMap.of(), 1);
+ Assert.assertEquals(spec, metadata.spec());
+
+ Schema updatedSchema = new Schema(
+ Types.NestedField.required(1, "x", Types.LongType.get()),
+ Types.NestedField.required(2, "z", Types.StringType.get())
+ );
+ PartitionSpec updatedSpec =
PartitionSpec.builderFor(updatedSchema).withSpecId(0)
+ .bucket("z", 8)
+ .identity("x")
+ .build();
+ TableMetadata updated = metadata.buildReplacement(
+ updatedSchema, updatedSpec, SortOrder.unsorted(), location,
ImmutableMap.of());
+ PartitionSpec expected =
PartitionSpec.builderFor(updated.schema()).withSpecId(1)
+ .add(3, 1000, "z_bucket", "bucket[8]")
+ .add(1, 1001, "x", "identity")
+ .build();
Review comment:
I think that this needs to be this:
```java
PartitionSpec expected =
PartitionSpec.builderFor(updated.schema()).withSpecId(1)
.add(1, 1000, "x", "identity")
.add(2, 1001, "y", "void")
.add(3, 1002, "z_bucket", "bucket[8]")
.build();
```
We should be able to create that by updating the existing spec.
--
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]