mchades commented on code in PR #9580:
URL: https://github.com/apache/gravitino/pull/9580#discussion_r2780496225
##########
spark-connector/spark-common/src/main/java/org/apache/gravitino/spark/connector/iceberg/GravitinoIcebergCatalog.java:
##########
@@ -109,12 +110,33 @@ protected SparkTransformConverter
getSparkTransformConverter() {
@Override
public Identifier[] listFunctions(String[] namespace) throws
NoSuchNamespaceException {
- return ((SparkCatalog) sparkCatalog).listFunctions(namespace);
+ // Get functions from Iceberg catalog
+ Identifier[] icebergFunctions = ((SparkCatalog)
sparkCatalog).listFunctions(namespace);
+
+ // When the namespace is empty, to maintain compatibility with Iceberg
behavior, only Iceberg
+ // functions are returned.
+ Identifier[] gravitinoFunctions =
+ namespace.length == 0 ? new Identifier[0] :
super.listFunctions(namespace);
+
+ // Combine and return both sets of functions
+ Identifier[] allFunctions = new Identifier[icebergFunctions.length +
gravitinoFunctions.length];
+ System.arraycopy(icebergFunctions, 0, allFunctions, 0,
icebergFunctions.length);
+ System.arraycopy(
+ gravitinoFunctions, 0, allFunctions, icebergFunctions.length,
gravitinoFunctions.length);
+ return allFunctions;
Review Comment:
fixed
##########
spark-connector/spark-common/src/main/java/org/apache/gravitino/spark/connector/catalog/BaseCatalog.java:
##########
@@ -437,17 +444,72 @@ protected String getDatabase(Identifier sparkIdentifier) {
return getCatalogDefaultNamespace();
}
+ @Override
+ public Identifier[] listFunctions(String[] namespace) throws
NoSuchNamespaceException {
+ String gravitinoNamespace;
+ if (namespace.length == 0) {
+ gravitinoNamespace = getCatalogDefaultNamespace();
+ } else {
+ validateNamespace(namespace);
+ gravitinoNamespace = namespace[0];
+ }
+ try {
+ Function[] functions =
+ gravitinoCatalogClient
+ .asFunctionCatalog()
+ .listFunctionInfos(Namespace.of(gravitinoNamespace));
+ // Filter functions that have Spark runtime implementation
+ return Arrays.stream(functions)
+ .filter(this::hasSparkImplementation)
+ .map(f -> Identifier.of(new String[] {gravitinoNamespace}, f.name()))
+ .toArray(Identifier[]::new);
+ } catch (NoSuchSchemaException e) {
+ return new Identifier[0];
Review Comment:
fixed
--
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]