iting0321 commented on code in PR #3820:
URL: https://github.com/apache/polaris/pull/3820#discussion_r3214481626


##########
plugins/spark/v3.5/spark/src/main/java/org/apache/polaris/spark/SparkCatalog.java:
##########
@@ -135,16 +145,42 @@ public void initialize(String name, 
CaseInsensitiveStringMap options) {
     initRESTCatalog(name, options);
     this.deltaHelper = new DeltaHelper(options);
     this.hudiHelper = new HudiHelper(options);
-    this.paimonHelper = new PaimonHelper(options);
+    this.paimonHelper = new PaimonHelper(name, options);
   }
 
   @Override
   public Table loadTable(Identifier ident) throws NoSuchTableException {
+    // First, try to load as an Iceberg table
     try {
       return this.icebergsSparkCatalog.loadTable(ident);
     } catch (NoSuchTableException e) {
-      return this.polarisSparkCatalog.loadTable(ident);
+      // Not an Iceberg table, fall through to handle as generic table
     }
+
+    // For generic tables, check the format/provider to decide delegation
+    // Use getTableFormat to avoid triggering Spark DataSource resolution for 
routing decisions
+    String provider = this.polarisSparkCatalog.getTableFormat(ident);
+
+    // Delegate to the appropriate catalog based on the provider
+    if (PolarisCatalogUtils.usePaimon(provider)) {
+      try {
+        // For Paimon tables, use Paimon's SparkCatalog to load the table
+        // This ensures proper handling of Paimon's metadata and schema files
+        TableCatalog paimonCatalog = paimonHelper.loadPaimonCatalog();
+        return paimonCatalog.loadTable(ident);

Review Comment:
   I agree this PR has become a mix of Paimon implementation changes and 
integration test work, so the current title and scope are misleading. I’m 
planning to remove the integration-test-specific changes from this PR and 
narrow it to aligning the Paimon implementation with its non-delegation 
behavior. Once that implementation is settled, I’ll open a follow-up PR for the 
Paimon integration tests. If you think that sounds like the better approach, 
I’m happy to proceed that way.



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

Reply via email to