You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by HyukjinKwon <gi...@git.apache.org> on 2017/05/03 10:02:32 UTC

[GitHub] spark pull request #17831: [SPARK-18777][PYTHON][SQL] Return UDF from udf.re...

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

    https://github.com/apache/spark/pull/17831#discussion_r114509033
  
    --- 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 --
    
    It looks `strlen` is not being used. Should we remove this or add an example for this?


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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