hequn8128 commented on a change in pull request #9886: 
[FLINK-14027][python][doc] Add documentation for Python user-defined functions.
URL: https://github.com/apache/flink/pull/9886#discussion_r334384504
 
 

 ##########
 File path: docs/dev/table/udfs.md
 ##########
 @@ -112,50 +152,54 @@ public class HashCode extends ScalarFunction {
 }
 '''
 
+class HashCode(ScalarFunction):
+  def eval(self, s):
+    return hash(s) * factor
+
 table_env = BatchTableEnvironment.create(env)
 
-# register the java function
+# register the Java function
 table_env.register_java_function("hashCode", "my.java.function.HashCode")
 
+# register the Python function
+table_env.register_function("py_hash_code", udf(HashCode(), 
DataTypes.STRING(), DataTypes.BIGINT()))
+
 # use the function in Python Table API
-my_table.select("string, string.hashCode(), hashCode(string)")
+my_table.select("string, string.hashCode(), hashCode(string), 
string.py_hash_code(), py_hash_code(string)")
 
 Review comment:
   String type has not been supported by now for the python udfs. We can use 
bigint for now and change to string later. 

----------------------------------------------------------------
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:
[email protected]


With regards,
Apache Git Services

Reply via email to