ebyhr commented on code in PR #17843:
URL: https://github.com/apache/iceberg/pull/17843#discussion_r3869569791
##########
core/src/test/java/org/apache/iceberg/rest/TestRESTCatalog.java:
##########
@@ -1123,6 +1125,75 @@ public void testTableSnapshotLoading() {
any());
}
+ @Test
+ public void testTableSnapshotLoadingWithStatisticsOnHistoricalSnapshot() {
+ RESTCatalogAdapter adapter = Mockito.spy(new
RESTCatalogAdapter(backendCatalog));
+
+ RESTCatalog catalog =
+ new RESTCatalog(SessionCatalog.SessionContext.createEmpty(), (config)
-> adapter);
+ catalog.initialize(
+ "test",
+ ImmutableMap.of(
+ CatalogProperties.URI,
+ "ignored",
+ CatalogProperties.FILE_IO_IMPL,
+ "org.apache.iceberg.inmemory.InMemoryFileIO",
+ // default loading to refs only
+ RESTCatalogProperties.SNAPSHOT_LOADING_MODE,
+ SnapshotMode.REFS.name()));
+
+ if (requiresNamespaceCreate()) {
+ catalog.createNamespace(TABLE.namespace());
+ }
+
+ Table table = catalog.createTable(TABLE, SCHEMA);
+ table
+ .newFastAppend()
+ .appendFile(
+ DataFiles.builder(PartitionSpec.unpartitioned())
+ .withPath("/path/to/data-a.parquet")
+ .withFileSizeInBytes(10)
+ .withRecordCount(2)
+ .build())
+ .commit();
+
+ long firstSnapshotId = table.currentSnapshot().snapshotId();
+
+ // add a statistics file to the first snapshot
+ table
+ .updateStatistics()
+ .setStatistics(
+ new GenericStatisticsFile(
+ firstSnapshotId,
+ "/path/to/stats.puffin",
+ 100,
+ 42,
+ ImmutableList.of(
+ new GenericBlobMetadata(
+ "some-stats", firstSnapshotId, 1, ImmutableList.of(1),
ImmutableMap.of()))))
+ .commit();
+
+ // second snapshot makes the first snapshot historical (unreferenced)
+ table
+ .newFastAppend()
+ .appendFile(
+ DataFiles.builder(PartitionSpec.unpartitioned())
+ .withPath("/path/to/data-b.parquet")
+ .withFileSizeInBytes(10)
+ .withRecordCount(2)
+ .build())
+ .commit();
+
+ Table refsTable = catalog.loadTable(TABLE);
Review Comment:
This line throws an exception if we revert `CatalogHandlers`'s change:
```
Cannot set metadata location with changes to table metadata: 1 changes
java.lang.IllegalArgumentException: Cannot set metadata location with
changes to table metadata: 1 changes
at
org.apache.iceberg.rest.ErrorHandlers$DefaultErrorHandler.accept(ErrorHandlers.java:339)
at
org.apache.iceberg.rest.ErrorHandlers$TableErrorHandler.accept(ErrorHandlers.java:160)
at
org.apache.iceberg.rest.ErrorHandlers$TableErrorHandler.accept(ErrorHandlers.java:142)
at
org.apache.iceberg.rest.RESTCatalogAdapter.execute(RESTCatalogAdapter.java:649)
at
java.base/java.lang.invoke.MethodHandle.invokeWithArguments(MethodHandle.java:732)
at
org.apache.iceberg.rest.RESTCatalogAdapter.execute(RESTCatalogAdapter.java:624)
at
java.base/java.lang.invoke.MethodHandle.invokeWithArguments(MethodHandle.java:732)
at
org.apache.iceberg.rest.RESTCatalogAdapter.execute(RESTCatalogAdapter.java:613)
at org.apache.iceberg.rest.BaseHTTPClient.get(BaseHTTPClient.java:101)
at
java.base/java.lang.invoke.MethodHandle.invokeWithArguments(MethodHandle.java:732)
at org.apache.iceberg.rest.BaseHTTPClient.get(BaseHTTPClient.java:100)
at
org.apache.iceberg.rest.RESTSessionCatalog.loadInternal(RESTSessionCatalog.java:453)
at
org.apache.iceberg.rest.RESTSessionCatalog.loadTable(RESTSessionCatalog.java:483)
at
org.apache.iceberg.catalog.BaseSessionCatalog$AsCatalog.loadTable(BaseSessionCatalog.java:105)
at org.apache.iceberg.rest.RESTCatalog.loadTable(RESTCatalog.java:124)
at
org.apache.iceberg.rest.TestRESTCatalog.testTableSnapshotLoadingWithStatisticsOnHistoricalSnapshot(TestRESTCatalog.java:1187)
at java.base/java.lang.reflect.Method.invoke(Method.java:569)
at java.base/java.util.ArrayList.forEach(ArrayList.java:1511)
at java.base/java.util.ArrayList.forEach(ArrayList.java:1511)
```
--
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]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]