mchades commented on code in PR #9580:
URL: https://github.com/apache/gravitino/pull/9580#discussion_r2780490568
##########
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;
}
@Override
public UnboundFunction loadFunction(Identifier ident) throws
NoSuchFunctionException {
- return ((SparkCatalog) sparkCatalog).loadFunction(ident);
+ try {
+ // When the namespace is empty, to maintain compatibility with Iceberg
behavior, only Iceberg
+ // functions are returned.
+ return ident.namespace().length == 0 &&
ArrayUtils.isEmpty(sparkCatalog.defaultNamespace())
+ ? ((SparkCatalog) sparkCatalog).loadFunction(ident)
+ : super.loadFunction(ident);
Review Comment:
For most scenarios, `defaultNamespace()` is not empty, so the path of
`super.loadFunction(ident)` is taken. This design is intentional.
--
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]