This is an automated email from the ASF dual-hosted git repository.
lzljs3620320 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/paimon.git
The following commit(s) were added to refs/heads/master by this push:
new 9393a9430 [spark] Add error message when sessionCatalog is null (#4161)
9393a9430 is described below
commit 9393a9430dadad614ee2a3f72890809d8a343dc4
Author: Zouxxyy <[email protected]>
AuthorDate: Tue Sep 10 19:01:35 2024 +0800
[spark] Add error message when sessionCatalog is null (#4161)
---
.../java/org/apache/paimon/spark/SparkGenericCatalog.java | 15 ++++++++++++---
1 file changed, 12 insertions(+), 3 deletions(-)
diff --git
a/paimon-spark/paimon-spark-common/src/main/java/org/apache/paimon/spark/SparkGenericCatalog.java
b/paimon-spark/paimon-spark-common/src/main/java/org/apache/paimon/spark/SparkGenericCatalog.java
index ae85e7995..12407f261 100644
---
a/paimon-spark/paimon-spark-common/src/main/java/org/apache/paimon/spark/SparkGenericCatalog.java
+++
b/paimon-spark/paimon-spark-common/src/main/java/org/apache/paimon/spark/SparkGenericCatalog.java
@@ -66,6 +66,7 @@ import static
org.apache.paimon.options.CatalogOptions.METASTORE;
import static org.apache.paimon.options.CatalogOptions.WAREHOUSE;
import static
org.apache.paimon.spark.SparkCatalogOptions.CREATE_UNDERLYING_SESSION_CATALOG;
import static org.apache.paimon.spark.SparkCatalogOptions.DEFAULT_DATABASE;
+import static org.apache.paimon.utils.Preconditions.checkNotNull;
/* This file is based on source code from the Iceberg Project
(http://iceberg.apache.org/), licensed by the Apache
* Software Foundation (ASF) under the Apache License, Version 2.0. See the
NOTICE file distributed with this work for
@@ -338,16 +339,24 @@ public class SparkGenericCatalog extends SparkBaseCatalog
implements CatalogExte
}
}
+ private CatalogPlugin getDelegateCatalog() {
+ checkNotNull(
+ sessionCatalog,
+ "Delegated SessionCatalog is missing, '%s' can only be used
with 'spark_catalog'.",
+ SparkGenericCatalog.class.getName());
+ return sessionCatalog;
+ }
+
private TableCatalog asTableCatalog() {
- return (TableCatalog) sessionCatalog;
+ return (TableCatalog) getDelegateCatalog();
}
private SupportsNamespaces asNamespaceCatalog() {
- return (SupportsNamespaces) sessionCatalog;
+ return (SupportsNamespaces) getDelegateCatalog();
}
private FunctionCatalog asFunctionCatalog() {
- return (FunctionCatalog) sessionCatalog;
+ return (FunctionCatalog) getDelegateCatalog();
}
@Override