iting0321 commented on code in PR #3820:
URL: https://github.com/apache/polaris/pull/3820#discussion_r3256552015
##########
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:
Hi @dimas-b, I just deleted the integration test and update the PR title and
description. Looking forward to your feedback!
##########
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:
Hi @dimas-b, I just deleted the integration test and updated the PR title
and description. Looking forward to your feedback!
--
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]