Github user icexelloss commented on a diff in the pull request:

    https://github.com/apache/spark/pull/20217#discussion_r160858034
  
    --- Diff: python/pyspark/sql/catalog.py ---
    @@ -255,26 +255,67 @@ def registerFunction(self, name, f, 
returnType=StringType()):
             >>> _ = spark.udf.register("stringLengthInt", len, IntegerType())
             >>> spark.sql("SELECT stringLengthInt('test')").collect()
             [Row(stringLengthInt(test)=4)]
    +        """
    +
    +        # This is to check whether the input function is a wrapped/native 
UserDefinedFunction
    +        if hasattr(f, 'asNondeterministic'):
    +            raise ValueError("Please use registerUDF for registering UDF. 
The expected function of "
    +                             "registerFunction is a Python function 
(including lambda function)")
    +        udf = UserDefinedFunction(f, returnType=returnType, name=name,
    +                                  evalType=PythonEvalType.SQL_BATCHED_UDF)
    +        self._jsparkSession.udf().registerPython(name, udf._judf)
    +        return udf._wrapped()
    +
    +    @ignore_unicode_prefix
    +    @since(2.3)
    +    def registerUDF(self, name, f):
    +        """Registers a :class:`UserDefinedFunction`. The registered UDF 
can be used in SQL
    +        statement.
    +
    +        :param name: name of the UDF
    --- End diff --
    
    Maybe something like "name of the UDF in SQL statement" to be more specific.


---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org

Reply via email to