fdolce commented on code in PR #29146:
URL: https://github.com/apache/flink/pull/29146#discussion_r3979036265


##########
flink-python/pyflink/dataframe/sql.py:
##########
@@ -257,6 +315,97 @@ def _register_bindings(
             _warn_skipped(name, f"registration failed: {e}")
             continue
         registered.append(name)
+    return registered
+
+
+def _register_functions(
+    t_env: TableEnvironment,
+    explicit: Dict[str, _DataFrameUDFWrapper],
+    auto: Dict[str, _DataFrameUDFWrapper],
+) -> List[str]:
+    """
+    Register explicit and auto-collected UDFs as temporary system functions 
and return
+    the registered names. Registration is all-or-nothing: if an explicit 
binding is
+    rejected, the functions registered before it are dropped again before 
raising.
+
+    System functions are looked up by bare name independently of the current 
catalog
+    and database, which matches how a Python name is referenced in the query. 
Function
+    names are case-insensitive: the catalog normalizes them to lower case, so
+    collisions are checked case-insensitively. Mirroring views, explicit 
bindings may
+    shadow built-in and permanent catalog functions but never an existing 
temporary
+    function; auto-bind shadows nothing.
+    """
+    if not explicit and not auto:
+        return []
+    # list_user_defined_functions() covers temporary and permanent functions 
alike;
+    # the permanent ones are those the current catalog lists for the current 
database.
+    user_defined = {f.lower() for f in t_env.list_user_defined_functions()}
+    temporary_functions = user_defined - _permanent_functions(t_env)
+    # Explicit bindings take precedence on name collisions, so only the 
remaining
+    # auto-bound candidates need the built-in function names. list_functions() 
covers
+    # those as well, but is comparatively expensive, so skip it when nothing 
needs it.
+    auto_candidates = {name: value for name, value in auto.items() if name not 
in explicit}

Review Comment:
   True, working on this



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