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

    https://github.com/apache/spark/pull/17831#discussion_r114511769
  
    --- Diff: python/pyspark/sql/catalog.py ---
    @@ -237,23 +237,28 @@ def registerFunction(self, name, f, 
returnType=StringType()):
             :param name: name of the UDF
             :param f: python function
             :param returnType: a :class:`pyspark.sql.types.DataType` object
    +        :return: a wrapped :class:`UserDefinedFunction`
     
    -        >>> spark.catalog.registerFunction("stringLengthString", lambda x: 
len(x))
    +        >>> strlen = spark.catalog.registerFunction("stringLengthString", 
len)
             >>> spark.sql("SELECT stringLengthString('test')").collect()
             [Row(stringLengthString(test)=u'4')]
     
    +        >>> spark.sql("SELECT 'foo' AS 
text").select(strlen("text")).collect()
    +        [Row(stringLengthString(text)=u'3')]
    +
             >>> from pyspark.sql.types import IntegerType
    -        >>> spark.catalog.registerFunction("stringLengthInt", lambda x: 
len(x), IntegerType())
    +        >>> strlen = spark.catalog.registerFunction("stringLengthInt", 
len, IntegerType())
    --- End diff --
    
    We have to either capture the output (we could use `_` I guess) or use it 
in the doctests:
    
    ```
    >>> spark.catalog.registerFunction("stringLengthInt", len, IntegerType())
    <function len>
    ```
    
    I am not sure if it makes sense to use it, unless we provide more diverse 
tests.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

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

Reply via email to