WeiZhong94 commented on a change in pull request #13325:
URL: https://github.com/apache/flink/pull/13325#discussion_r483411913



##########
File path: flink-python/pyflink/table/expressions.py
##########
@@ -538,9 +538,44 @@ def call(f: Union[str, UserDefinedFunctionWrapper], *args) 
-> Expression:
     :param args: parameters of the user-defined function.
     """
     gateway = get_gateway()
-    return Expression(gateway.jvm.Expressions.call(
-        f if isinstance(f, str) else f.java_user_defined_function(),
-        to_jarray(gateway.jvm.Object, [_get_java_expression(arg) for arg in 
args])))
+
+    if isinstance(f, str):
+        return Expression(gateway.jvm.Expressions.call(
+            f, to_jarray(gateway.jvm.Object, [_get_java_expression(arg) for 
arg in args])))
+
+    def get_function_definition(f):
+        if isinstance(f, UserDefinedTableFunctionWrapper):
+            """
+            TypeInference was not supported for TableFunction in the old 
planner. Use
+            TableFunctionDefinition to work around this issue.
+            """
+            j_result_types = to_jarray(gateway.jvm.TypeInformation,
+                                       [_to_java_type(i) for i in 
f._result_types])
+            j_result_type = 
gateway.jvm.org.apache.flink.api.java.typeutils.RowTypeInfo(
+                j_result_types)
+            return 
gateway.jvm.org.apache.flink.table.functions.TableFunctionDefinition(
+                'f', f.java_user_defined_function(), j_result_type)
+        else:
+            return f.java_user_defined_function()
+
+    expressions_clz = gateway.jvm.Class \

Review comment:
       Can be replaced by pyflink.util.utils.load_java_class()?

##########
File path: flink-python/pyflink/table/udf.py
##########
@@ -184,6 +184,10 @@ def __init__(self, func, input_types, deterministic=None, 
name=None):
         self._deterministic = deterministic if deterministic is not None else (
             func.is_deterministic() if isinstance(func, UserDefinedFunction) 
else True)
 
+    def __call__(self, *args):

Review comment:
       add a type hint?




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

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Reply via email to