jerryshao commented on code in PR #14313:
URL: https://github.com/apache/gravitino/pull/14313#discussion_r4509211457
##########
catalogs/catalog-lakehouse-iceberg/src/test/java/org/apache/gravitino/catalog/lakehouse/iceberg/TestIcebergViewCatalogOperations.java:
##########
@@ -504,6 +516,133 @@ public void
testAlterViewBuildsOptimisticConcurrencyRequirements() throws Except
verify(wrapper).updateView(any(TableIdentifier.class),
any(UpdateTableRequest.class));
}
+ @Test
+ public void testAlterViewAddsVersionsForRepeatedDefinitions() throws
InterruptedException {
+ Column[] columnsA = {Column.of("id", Types.IntegerType.get(), null)};
+ Column[] columnsB = {
+ Column.of("id", Types.IntegerType.get(), null),
+ Column.of("name", Types.StringType.get(), null)
+ };
+ String sqlA = "SELECT id FROM source WHERE age > 10";
+ String sqlB = "SELECT id, name FROM source WHERE age > 20";
+ AtomicReference<ViewMetadata> metadata = new
AtomicReference<>(newViewMetadata(columnsA, sqlA));
+ IcebergViewCatalogOperations operations =
+ new IcebergViewCatalogOperations(mockCommittingViewCatalog(metadata));
+ NameIdentifier ident = NameIdentifier.of("schema1", "view1");
+
+ operations.alterView(ident, replacement(columnsB, sqlB));
+ operations.alterView(ident, replacement(columnsA, sqlA));
+ Thread.sleep(2L);
Review Comment:
Thread.sleep(2L) makes the test depend on the clock to avoid the very
collision being fixed, and it hides the same-millisecond case. Remove the
sleeps once the summary value is unique per call, and add a test that does
back-to-back identical replacements.
##########
catalogs/catalog-lakehouse-iceberg/src/main/java/org/apache/gravitino/catalog/lakehouse/iceberg/IcebergViewCatalogOperations.java:
##########
@@ -404,14 +404,16 @@ private static List<MetadataUpdate>
buildNewViewVersionUpdates(
newRepresentations.add(toSqlViewRepresentation(representation));
}
+ long timestampMillis = System.currentTimeMillis();
ViewVersion newVersion =
ImmutableViewVersion.builder()
.versionId(newVersionId)
- .timestampMillis(System.currentTimeMillis())
+ .timestampMillis(timestampMillis)
.schemaId(schemaId)
.defaultNamespace(defaultNamespace)
.representations(newRepresentations)
.putSummary("operation", "alter")
+ .putSummary("timestamp-ms", Long.toString(timestampMillis))
Review Comment:
Is a custom summary key named timestamp-ms acceptable to other Iceberg
readers and engines that inspect view version summaries? Consider whether a
clearly Gravitino-specific key name is safer.
--
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]