kbendick commented on code in PR #5305:
URL: https://github.com/apache/iceberg/pull/5305#discussion_r927178316
##########
spark/v3.3/spark/src/main/java/org/apache/iceberg/spark/BaseCatalog.java:
##########
@@ -46,4 +54,56 @@ public Procedure loadProcedure(Identifier ident) throws
NoSuchProcedureException
throw new NoSuchProcedureException(ident);
}
+
+ @Override
+ public Identifier[] listFunctions(String[] namespace) throws
NoSuchNamespaceException {
+ if (isValidNamespaceForFunction(namespace)) {
+ return Arrays.stream(SparkFunctions.list())
+ .map(name -> Identifier.of(namespace, name))
+ .toArray(Identifier[]::new);
+ } else {
+ throw new NoSuchNamespaceException(namespace);
+ }
+ }
+
+ @Override
+ public UnboundFunction loadFunction(Identifier ident) throws
NoSuchFunctionException {
+ String[] namespace = ident.namespace();
+ String name = ident.name();
+
+ if (isValidNamespaceForFunction(namespace)) {
+ UnboundFunction func = SparkFunctions.load(name);
+ if (func != null) {
+ return func;
+ }
+ }
+
+ throw new NoSuchFunctionException(ident);
+ }
+
+ /**
+ * When in an Iceberg catalog, allow for using the built-in Iceberg
functions provided that:
+ * <ol>
+ * <li>
+ * The namespace is not specified,
+ * i.e. {@code SELECT truncate(1, 4)} or {@code SELECT
my_catalog.truncate(1, 4)}
+ * </li>
+ * <li>
+ * The implicit <b>system</b> namespace is used, to mirror call
procedure syntax,
+ * i.e. {@code SELECT system.truncate(1, 4)} or {@code SELECT
my_catalog.system.truncate(1, 4)}
+ * </li>
+ * <li>
+ * A namespace that exists within the catalog is referenced,
+ * i.e. {@code SELECT ns.truncate(1, 4)} or {@code SELECT
my_catalog.ns.truncate(1, 4)}
Review Comment:
We spoke offline and we're just giong to hold off on the spark session
catalog for now.
Most likely in a follow up we will add a namespace `system` that will then
be resolvable (as these issues go away when the namespace is resolvable). That
matches other databases, as well as the experience of using the
`ProcedureCatalog`.
I can handle this in a follow up PR.
--
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]