mxm commented on code in PR #17437:
URL: https://github.com/apache/iceberg/pull/17437#discussion_r3718122762


##########
flink/v2.1/flink/src/test/java/org/apache/iceberg/flink/sink/dynamic/TestTableSerializerCache.java:
##########
@@ -121,4 +125,48 @@ void testCacheSize() {
     cache = new TableSerializerCache(CATALOG_EXTENSION.catalogLoader(), 1000);
     assertThat(cache.maximumSize()).isEqualTo(1000);
   }
+
+  @Test
+  void testClosesCatalogAfterSchemaLookup() {
+    CloseCountingInMemoryCatalog catalog = new CloseCountingInMemoryCatalog();
+    catalog.initialize("tracking", Map.of());
+    catalog.createNamespace(Namespace.of("db"));
+    Table table = catalog.createTable(TableIdentifier.of("db", "table"), 
schema1);
+    cache = new TableSerializerCache(new SingleCatalogLoader(catalog), 10);
+
+    // schema/spec ids are unknown, so this misses the cache and loads a 
catalog to resolve them
+    cache.serializerWithSchemaAndSpec(
+        "db.table", table.schema().schemaId(), 
PartitionSpec.unpartitioned().specId());
+
+    assertThat(catalog.closeCount).isEqualTo(1);
+  }
+
+  private static class CloseCountingInMemoryCatalog extends InMemoryCatalog {
+    private int closeCount = 0;
+
+    @Override
+    public void close() throws IOException {
+      super.close();
+      closeCount += 1;
+    }
+  }
+
+  private static class SingleCatalogLoader implements CatalogLoader {

Review Comment:
   Can we replace this with `HadoopCatalogExtension`?



-- 
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]

Reply via email to