sfc-gh-rxing commented on code in PR #14465:
URL: https://github.com/apache/iceberg/pull/14465#discussion_r2561888944


##########
core/src/test/java/org/apache/iceberg/rest/TestRESTCatalog.java:
##########
@@ -3066,6 +3074,113 @@ public void testCommitStateUnknownNotReconciled() {
         .satisfies(ex -> assertThat(((CommitStateUnknownException) 
ex).getSuppressed()).isEmpty());
   }
 
+  @Test
+  public void testCustomTableOperationsInjection() throws IOException {
+    AtomicBoolean customTableOps = new AtomicBoolean();
+    AtomicBoolean customTxnOps = new AtomicBoolean();
+    AtomicBoolean customViewOps = new AtomicBoolean();
+
+    // Custom RESTSessionCatalog that overrides table/view operations creation
+    class CustomRESTSessionCatalog extends RESTSessionCatalog {
+      CustomRESTSessionCatalog(
+          Function<Map<String, String>, RESTClient> clientBuilder,
+          BiFunction<SessionCatalog.SessionContext, Map<String, String>, 
FileIO> ioBuilder) {
+        super(clientBuilder, ioBuilder);
+      }
+
+      @Override
+      protected RESTTableOperations newTableOps(
+          RESTClient restClient,
+          String path,
+          Supplier<Map<String, String>> headers,
+          FileIO fileIO,
+          TableMetadata current,
+          Set<Endpoint> supportedEndpoints) {
+        customTableOps.set(true);
+        return super.newTableOps(restClient, path, headers, fileIO, current, 
supportedEndpoints);
+      }
+
+      @Override
+      protected RESTTableOperations newTableOpsForTransaction(
+          RESTClient restClient,
+          String path,
+          Supplier<Map<String, String>> headers,
+          FileIO fileIO,
+          RESTTableOperations.UpdateType updateType,
+          List<MetadataUpdate> createChanges,
+          TableMetadata current,
+          Set<Endpoint> supportedEndpoints) {
+        customTxnOps.set(true);
+        return super.newTableOpsForTransaction(
+            restClient,
+            path,
+            headers,
+            fileIO,
+            updateType,
+            createChanges,
+            current,
+            supportedEndpoints);
+      }
+
+      @Override
+      protected RESTViewOperations newViewOps(
+          RESTClient restClient,
+          String path,
+          Supplier<Map<String, String>> headers,
+          ViewMetadata current,
+          Set<Endpoint> supportedEndpoints) {
+        customViewOps.set(true);
+        return super.newViewOps(restClient, path, headers, current, 
supportedEndpoints);
+      }
+    }
+
+    // Custom RESTCatalog that provides the custom session catalog
+    class CustomRESTCatalog extends RESTCatalog {
+      CustomRESTCatalog(
+          SessionCatalog.SessionContext context,
+          Function<Map<String, String>, RESTClient> clientBuilder) {
+        super(context, clientBuilder);
+      }
+
+      @Override
+      protected RESTSessionCatalog newSessionCatalog(
+          Function<Map<String, String>, RESTClient> clientBuilder) {
+        return new CustomRESTSessionCatalog(clientBuilder, null);
+      }
+    }
+
+    try (CustomRESTCatalog catalog =
+        new CustomRESTCatalog(
+            SessionCatalog.SessionContext.createEmpty(),
+            (config) -> new RESTCatalogAdapter(backendCatalog))) {
+      catalog.setConf(new Configuration());
+      catalog.initialize(
+          "test",
+          ImmutableMap.of(
+              CatalogProperties.FILE_IO_IMPL, 
"org.apache.iceberg.inmemory.InMemoryFileIO"));
+
+      Namespace ns = Namespace.of("test_custom_ops");
+      catalog.createNamespace(ns);
+
+      catalog.createTable(TableIdentifier.of(ns, "table1"), SCHEMA);

Review Comment:
   Done!



##########
core/src/test/java/org/apache/iceberg/rest/TestRESTCatalog.java:
##########
@@ -3066,6 +3074,113 @@ public void testCommitStateUnknownNotReconciled() {
         .satisfies(ex -> assertThat(((CommitStateUnknownException) 
ex).getSuppressed()).isEmpty());
   }
 
+  @Test
+  public void testCustomTableOperationsInjection() throws IOException {
+    AtomicBoolean customTableOps = new AtomicBoolean();
+    AtomicBoolean customTxnOps = new AtomicBoolean();
+    AtomicBoolean customViewOps = new AtomicBoolean();
+
+    // Custom RESTSessionCatalog that overrides table/view operations creation
+    class CustomRESTSessionCatalog extends RESTSessionCatalog {
+      CustomRESTSessionCatalog(
+          Function<Map<String, String>, RESTClient> clientBuilder,
+          BiFunction<SessionCatalog.SessionContext, Map<String, String>, 
FileIO> ioBuilder) {
+        super(clientBuilder, ioBuilder);
+      }
+
+      @Override
+      protected RESTTableOperations newTableOps(
+          RESTClient restClient,
+          String path,
+          Supplier<Map<String, String>> headers,
+          FileIO fileIO,
+          TableMetadata current,
+          Set<Endpoint> supportedEndpoints) {
+        customTableOps.set(true);
+        return super.newTableOps(restClient, path, headers, fileIO, current, 
supportedEndpoints);
+      }
+
+      @Override
+      protected RESTTableOperations newTableOpsForTransaction(
+          RESTClient restClient,
+          String path,
+          Supplier<Map<String, String>> headers,
+          FileIO fileIO,
+          RESTTableOperations.UpdateType updateType,
+          List<MetadataUpdate> createChanges,
+          TableMetadata current,
+          Set<Endpoint> supportedEndpoints) {
+        customTxnOps.set(true);
+        return super.newTableOpsForTransaction(
+            restClient,
+            path,
+            headers,
+            fileIO,
+            updateType,
+            createChanges,
+            current,
+            supportedEndpoints);
+      }
+
+      @Override
+      protected RESTViewOperations newViewOps(
+          RESTClient restClient,
+          String path,
+          Supplier<Map<String, String>> headers,
+          ViewMetadata current,
+          Set<Endpoint> supportedEndpoints) {
+        customViewOps.set(true);
+        return super.newViewOps(restClient, path, headers, current, 
supportedEndpoints);
+      }
+    }
+
+    // Custom RESTCatalog that provides the custom session catalog
+    class CustomRESTCatalog extends RESTCatalog {
+      CustomRESTCatalog(
+          SessionCatalog.SessionContext context,
+          Function<Map<String, String>, RESTClient> clientBuilder) {
+        super(context, clientBuilder);
+      }
+
+      @Override
+      protected RESTSessionCatalog newSessionCatalog(
+          Function<Map<String, String>, RESTClient> clientBuilder) {
+        return new CustomRESTSessionCatalog(clientBuilder, null);
+      }
+    }
+
+    try (CustomRESTCatalog catalog =
+        new CustomRESTCatalog(
+            SessionCatalog.SessionContext.createEmpty(),
+            (config) -> new RESTCatalogAdapter(backendCatalog))) {
+      catalog.setConf(new Configuration());
+      catalog.initialize(
+          "test",
+          ImmutableMap.of(
+              CatalogProperties.FILE_IO_IMPL, 
"org.apache.iceberg.inmemory.InMemoryFileIO"));
+
+      Namespace ns = Namespace.of("test_custom_ops");
+      catalog.createNamespace(ns);
+
+      catalog.createTable(TableIdentifier.of(ns, "table1"), SCHEMA);

Review Comment:
   Done!



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