Github user icexelloss commented on a diff in the pull request: https://github.com/apache/spark/pull/20217#discussion_r160979747 --- 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 + :param f: a wrapped/native UserDefinedFunction. The UDF can be either row-at-a-time or + scalar vectorized. Grouped vectorized UDFs are not supported. --- End diff -- Ok. Maybe as a follow up we can standardize the language to describe the `udf` and `pandas_udf` objects.
--- --------------------------------------------------------------------- To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org For additional commands, e-mail: reviews-h...@spark.apache.org