FANNG1 commented on code in PR #9580:
URL: https://github.com/apache/gravitino/pull/9580#discussion_r2785691668


##########
spark-connector/spark-common/src/main/java/org/apache/gravitino/spark/connector/iceberg/GravitinoIcebergCatalog.java:
##########
@@ -109,12 +111,45 @@ 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);
+
+    // Try to get Gravitino functions. If the namespace doesn't exist in 
Gravitino
+    // (e.g., Iceberg's "system" namespace), gracefully return empty array.
+    Identifier[] gravitinoFunctions;
+    if (namespace.length == 0) {
+      gravitinoFunctions = new Identifier[0];
+    } else {
+      try {
+        gravitinoFunctions = super.listFunctions(namespace);
+      } catch (NoSuchNamespaceException e) {
+        // Namespace exists in Iceberg but not in Gravitino, skip Gravitino 
functions
+        gravitinoFunctions = new Identifier[0];
+      }
+    }
+
+    // Combine and deduplicate functions, Gravitino functions take precedence

Review Comment:
   One corner case is user creates a namespace with the name `system`  which is 
the the same with Iceberg function namespace



-- 
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]

Reply via email to