Skip to content

Commit

Permalink
[spark] Add error message when sessionCatalog is null (#4161)
Browse files Browse the repository at this point in the history
  • Loading branch information
Zouxxyy committed Sep 10, 2024
1 parent 588b6e0 commit 9393a94
Showing 1 changed file with 12 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@
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
Expand Down Expand Up @@ -338,16 +339,24 @@ public void setDelegateCatalog(CatalogPlugin delegate) {
}
}

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

0 comments on commit 9393a94

Please sign in to comment.