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/01/11 18:21:43 UTC

[GitHub] spark pull request #16553: [SPARK-9435][SQL] Reuse function in Java UDF to c...

GitHub user HyukjinKwon opened a pull request:

    https://github.com/apache/spark/pull/16553

    [SPARK-9435][SQL] Reuse function in Java UDF to correctly support expressions that require equality comparison

    ## What changes were proposed in this pull request?
    
    Currently, running the codes in Java
    
    ```java
    spark.udf().register("inc", new UDF1<Long, Long>() {
      @Override
      public Long call(Long i) {
        return i + 1;
      }
    }, DataTypes.LongType);
    
    spark.range(10).toDF("x").createOrReplaceTempView("tmp");
    Row result = spark.sql("SELECT inc(x) FROM tmp GROUP BY inc(x)").head();
    Assert.assertEquals(7, result.getLong(0));
    ```
    
    fails as below:
    
    ```
    org.apache.spark.sql.AnalysisException: expression 'tmp.`x`' is neither present in the group by, nor is it an aggregate function. Add to group by or wrap in first() (or first_value) if you don't care which value you get.;;
    Aggregate [UDF(x#19L)], [UDF(x#19L) AS UDF(x)#23L]
    +- SubqueryAlias tmp, `tmp`
       +- Project [id#16L AS x#19L]
          +- Range (0, 10, step=1, splits=Some(8))
    
    	at org.apache.spark.sql.catalyst.analysis.CheckAnalysis$class.failAnalysis(CheckAnalysis.scala:40)
    	at org.apache.spark.sql.catalyst.analysis.Analyzer.failAnalysis(Analyzer.scala:57)
    ```
    
    The root cause is because we were creating the function every time when it needs to build as below:
    
    ```scala
    scala> def inc(i: Int) = i + 1
    inc: (i: Int)Int
    
    scala> (inc(_: Int)).hashCode
    res15: Int = 1231799381
    
    scala> (inc(_: Int)).hashCode
    res16: Int = 2109839984
    
    scala> (inc(_: Int)) == (inc(_: Int))
    res17: Boolean = false
    ```
    
    This seems leading to the comparison failure between `ScalaUDF` created from Java UDF API, for example, in `Expression.semanticEquals`.
    
    In case of Scala one, it seems already fine.
    
    Both can be tested easily as below if any reviewer is comfortable with Scala:
    
    ```scala
    val df = Seq((1, 10), (2, 11), (3, 12)).toDF("x", "y")
    val javaUDF = new UDF1[Int, Int]  {
      override def call(i: Int): Int = i + 1
    }
    // spark.udf.register("inc", javaUDF, IntegerType) // Uncomment this for Java API
    // spark.udf.register("inc", (i: Int) => i + 1)    // Uncomment this for Scala API
    df.createOrReplaceTempView("tmp")
    spark.sql("SELECT inc(y) FROM tmp GROUP BY inc(y)").show()
    ```
    
    ## How was this patch tested?
    
    Unit test in `JavaUDFSuite.java`.

You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/HyukjinKwon/spark SPARK-9435

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/spark/pull/16553.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #16553
    
----
commit 30ed14f38b5c38091d07d0e014a49e494aeb73cc
Author: hyukjinkwon <gu...@gmail.com>
Date:   2017-01-11T18:02:08Z

    Reuse function in Java UDF to support correctly expression equality comparison

----


---
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


[GitHub] spark issue #16553: [SPARK-9435][SQL] Reuse function in Java UDF to correctl...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the issue:

    https://github.com/apache/spark/pull/16553
  
    Merged build finished. Test PASSed.


---
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


[GitHub] spark pull request #16553: [SPARK-9435][SQL] Reuse function in Java UDF to c...

Posted by HyukjinKwon <gi...@git.apache.org>.
Github user HyukjinKwon commented on a diff in the pull request:

    https://github.com/apache/spark/pull/16553#discussion_r95705218
  
    --- Diff: sql/core/src/main/scala/org/apache/spark/sql/UDFRegistration.scala ---
    @@ -109,9 +109,10 @@ class UDFRegistration private[sql] (functionRegistry: FunctionRegistry) extends
              | * @since 1.3.0
              | */
              |def register(name: String, f: UDF$i[$extTypeArgs, _], returnType: DataType): Unit = {
    +         |  val func = f$anyCast.call($anyParams)
              |  functionRegistry.registerFunction(
              |    name,
    -         |    (e: Seq[Expression]) => ScalaUDF(f$anyCast.call($anyParams), returnType, e))
    +         |    (e: Seq[Expression]) => ScalaUDF(func, returnType, e))
    --- End diff --
    
    I verified this by overwriting the current changes after copying and pasting and checking no diff.


---
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


[GitHub] spark issue #16553: [SPARK-9435][SQL] Reuse function in Java UDF to correctl...

Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the issue:

    https://github.com/apache/spark/pull/16553
  
    **[Test build #71235 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/71235/testReport)** for PR 16553 at commit [`2ea071a`](https://github.com/apache/spark/commit/2ea071ad0e4149ae3984cb9c1e31763bf892acfe).


---
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


[GitHub] spark issue #16553: [SPARK-9435][SQL] Reuse function in Java UDF to correctl...

Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the issue:

    https://github.com/apache/spark/pull/16553
  
    **[Test build #71224 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/71224/testReport)** for PR 16553 at commit [`30ed14f`](https://github.com/apache/spark/commit/30ed14f38b5c38091d07d0e014a49e494aeb73cc).


---
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


[GitHub] spark issue #16553: [SPARK-9435][SQL] Reuse function in Java UDF to correctl...

Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the issue:

    https://github.com/apache/spark/pull/16553
  
    **[Test build #71235 has finished](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/71235/testReport)** for PR 16553 at commit [`2ea071a`](https://github.com/apache/spark/commit/2ea071ad0e4149ae3984cb9c1e31763bf892acfe).
     * This patch passes all tests.
     * This patch merges cleanly.
     * This patch adds no public classes.


---
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


[GitHub] spark pull request #16553: [SPARK-9435][SQL] Reuse function in Java UDF to c...

Posted by marmbrus <gi...@git.apache.org>.
Github user marmbrus commented on a diff in the pull request:

    https://github.com/apache/spark/pull/16553#discussion_r95655634
  
    --- Diff: sql/core/src/main/scala/org/apache/spark/sql/UDFRegistration.scala ---
    @@ -488,219 +488,241 @@ class UDFRegistration private[sql] (functionRegistry: FunctionRegistry) extends
        * @since 1.3.0
        */
       def register(name: String, f: UDF1[_, _], returnType: DataType): Unit = {
    +    val func = f.asInstanceOf[UDF1[Any, Any]].call(_: Any)
    --- End diff --
    
    There is commented out code above thats used to generate these functions.  We should update it or delete it.


---
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


[GitHub] spark issue #16553: [SPARK-9435][SQL] Reuse function in Java UDF to correctl...

Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the issue:

    https://github.com/apache/spark/pull/16553
  
    **[Test build #71398 has finished](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/71398/testReport)** for PR 16553 at commit [`0d5b586`](https://github.com/apache/spark/commit/0d5b5861f2480e93958343f12a05b02acd7ba12b).
     * This patch passes all tests.
     * This patch merges cleanly.
     * This patch adds no public classes.


---
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


[GitHub] spark issue #16553: [SPARK-9435][SQL] Reuse function in Java UDF to correctl...

Posted by HyukjinKwon <gi...@git.apache.org>.
Github user HyukjinKwon commented on the issue:

    https://github.com/apache/spark/pull/16553
  
    @gatorsmile Thanks!


---
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


[GitHub] spark issue #16553: [SPARK-9435][SQL] Reuse function in Java UDF to correctl...

Posted by viirya <gi...@git.apache.org>.
Github user viirya commented on the issue:

    https://github.com/apache/spark/pull/16553
  
    One minor comment, otherwise LGTM.


---
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


[GitHub] spark issue #16553: [SPARK-9435][SQL] Reuse function in Java UDF to correctl...

Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the issue:

    https://github.com/apache/spark/pull/16553
  
    **[Test build #71885 has finished](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/71885/testReport)** for PR 16553 at commit [`0d5b586`](https://github.com/apache/spark/commit/0d5b5861f2480e93958343f12a05b02acd7ba12b).
     * This patch passes all tests.
     * This patch merges cleanly.
     * This patch adds no public classes.


---
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


[GitHub] spark issue #16553: [SPARK-9435][SQL] Reuse function in Java UDF to correctl...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the issue:

    https://github.com/apache/spark/pull/16553
  
    Merged build finished. Test PASSed.


---
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


[GitHub] spark issue #16553: [SPARK-9435][SQL] Reuse function in Java UDF to correctl...

Posted by HyukjinKwon <gi...@git.apache.org>.
Github user HyukjinKwon commented on the issue:

    https://github.com/apache/spark/pull/16553
  
    @gatorsmile Thanks !


---
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


[GitHub] spark issue #16553: [SPARK-9435][SQL] Reuse function in Java UDF to correctl...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the issue:

    https://github.com/apache/spark/pull/16553
  
    Merged build finished. Test PASSed.


---
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


[GitHub] spark pull request #16553: [SPARK-9435][SQL] Reuse function in Java UDF to c...

Posted by viirya <gi...@git.apache.org>.
Github user viirya commented on a diff in the pull request:

    https://github.com/apache/spark/pull/16553#discussion_r96137355
  
    --- Diff: sql/core/src/test/java/test/org/apache/spark/sql/JavaUDFSuite.java ---
    @@ -108,4 +109,24 @@ public void udf3Test() {
         result = spark.sql("SELECT stringLengthTest('test', 'test2')").head();
         Assert.assertEquals(9, result.getInt(0));
       }
    +
    +  @SuppressWarnings("unchecked")
    +  @Test
    +  public void udf4Test() {
    +    spark.udf().register("inc", new UDF1<Long, Long>() {
    +      @Override
    +      public Long call(Long i) {
    +        return i + 1;
    +      }
    +    }, DataTypes.LongType);
    +
    +    spark.range(10).toDF("x").createOrReplaceTempView("tmp");
    +    List<Row> results = spark.sql("SELECT inc(x) FROM tmp GROUP BY inc(x)").collectAsList();
    --- End diff --
    
    This test is not so obvious what it goes to test for. Can we add few comments showing that?


---
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


[GitHub] spark issue #16553: [SPARK-9435][SQL] Reuse function in Java UDF to correctl...

Posted by HyukjinKwon <gi...@git.apache.org>.
Github user HyukjinKwon commented on the issue:

    https://github.com/apache/spark/pull/16553
  
    cc @marmbrus, I just saw you in the JIRA. Could you please take a look?


---
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


[GitHub] spark issue #16553: [SPARK-9435][SQL] Reuse function in Java UDF to correctl...

Posted by HyukjinKwon <gi...@git.apache.org>.
Github user HyukjinKwon commented on the issue:

    https://github.com/apache/spark/pull/16553
  
    @marmbrus Can this be merged by any change maybe?


---
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


[GitHub] spark issue #16553: [SPARK-9435][SQL] Reuse function in Java UDF to correctl...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the issue:

    https://github.com/apache/spark/pull/16553
  
    Merged build finished. Test PASSed.


---
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


[GitHub] spark issue #16553: [SPARK-9435][SQL] Reuse function in Java UDF to correctl...

Posted by HyukjinKwon <gi...@git.apache.org>.
Github user HyukjinKwon commented on the issue:

    https://github.com/apache/spark/pull/16553
  
    @marmbrus, could you take another look when you have some time?


---
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


[GitHub] spark issue #16553: [SPARK-9435][SQL] Reuse function in Java UDF to correctl...

Posted by HyukjinKwon <gi...@git.apache.org>.
Github user HyukjinKwon commented on the issue:

    https://github.com/apache/spark/pull/16553
  
    (FWIW, I checked `/build/mvn -Pyarn -Phadoop-2.4 -Dscala-2.10 -DskipTests clean package`)


---
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


[GitHub] spark issue #16553: [SPARK-9435][SQL] Reuse function in Java UDF to correctl...

Posted by HyukjinKwon <gi...@git.apache.org>.
Github user HyukjinKwon commented on the issue:

    https://github.com/apache/spark/pull/16553
  
    gentle ping..


---
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


[GitHub] spark issue #16553: [SPARK-9435][SQL] Reuse function in Java UDF to correctl...

Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the issue:

    https://github.com/apache/spark/pull/16553
  
    **[Test build #71885 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/71885/testReport)** for PR 16553 at commit [`0d5b586`](https://github.com/apache/spark/commit/0d5b5861f2480e93958343f12a05b02acd7ba12b).


---
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


[GitHub] spark issue #16553: [SPARK-9435][SQL] Reuse function in Java UDF to correctl...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the issue:

    https://github.com/apache/spark/pull/16553
  
    Test PASSed.
    Refer to this link for build results (access rights to CI server needed): 
    https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder/71885/
    Test PASSed.


---
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


[GitHub] spark issue #16553: [SPARK-9435][SQL] Reuse function in Java UDF to correctl...

Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the issue:

    https://github.com/apache/spark/pull/16553
  
    **[Test build #71225 has finished](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/71225/testReport)** for PR 16553 at commit [`3dea44f`](https://github.com/apache/spark/commit/3dea44f5d4e4af846af3f2fd5e94d860d2b8d26f).
     * This patch passes all tests.
     * This patch merges cleanly.
     * This patch adds no public classes.


---
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


[GitHub] spark pull request #16553: [SPARK-9435][SQL] Reuse function in Java UDF to c...

Posted by HyukjinKwon <gi...@git.apache.org>.
Github user HyukjinKwon commented on a diff in the pull request:

    https://github.com/apache/spark/pull/16553#discussion_r95694410
  
    --- Diff: sql/core/src/main/scala/org/apache/spark/sql/UDFRegistration.scala ---
    @@ -488,219 +488,241 @@ class UDFRegistration private[sql] (functionRegistry: FunctionRegistry) extends
        * @since 1.3.0
        */
       def register(name: String, f: UDF1[_, _], returnType: DataType): Unit = {
    +    val func = f.asInstanceOf[UDF1[Any, Any]].call(_: Any)
    --- End diff --
    
    Ah, sure. Thanks!


---
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


[GitHub] spark issue #16553: [SPARK-9435][SQL] Reuse function in Java UDF to correctl...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the issue:

    https://github.com/apache/spark/pull/16553
  
    Merged build finished. Test PASSed.


---
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


[GitHub] spark issue #16553: [SPARK-9435][SQL] Reuse function in Java UDF to correctl...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the issue:

    https://github.com/apache/spark/pull/16553
  
    Test PASSed.
    Refer to this link for build results (access rights to CI server needed): 
    https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder/71235/
    Test PASSed.


---
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


[GitHub] spark issue #16553: [SPARK-9435][SQL] Reuse function in Java UDF to correctl...

Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the issue:

    https://github.com/apache/spark/pull/16553
  
    **[Test build #71398 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/71398/testReport)** for PR 16553 at commit [`0d5b586`](https://github.com/apache/spark/commit/0d5b5861f2480e93958343f12a05b02acd7ba12b).


---
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


[GitHub] spark issue #16553: [SPARK-9435][SQL] Reuse function in Java UDF to correctl...

Posted by gatorsmile <gi...@git.apache.org>.
Github user gatorsmile commented on the issue:

    https://github.com/apache/spark/pull/16553
  
    retest this please


---
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


[GitHub] spark issue #16553: [SPARK-9435][SQL] Reuse function in Java UDF to correctl...

Posted by HyukjinKwon <gi...@git.apache.org>.
Github user HyukjinKwon commented on the issue:

    https://github.com/apache/spark/pull/16553
  
    Thank you @gatorsmile 


---
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


[GitHub] spark issue #16553: [SPARK-9435][SQL] Reuse function in Java UDF to correctl...

Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the issue:

    https://github.com/apache/spark/pull/16553
  
    **[Test build #71225 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/71225/testReport)** for PR 16553 at commit [`3dea44f`](https://github.com/apache/spark/commit/3dea44f5d4e4af846af3f2fd5e94d860d2b8d26f).


---
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


[GitHub] spark issue #16553: [SPARK-9435][SQL] Reuse function in Java UDF to correctl...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the issue:

    https://github.com/apache/spark/pull/16553
  
    Test PASSed.
    Refer to this link for build results (access rights to CI server needed): 
    https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder/71225/
    Test PASSed.


---
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


[GitHub] spark pull request #16553: [SPARK-9435][SQL] Reuse function in Java UDF to c...

Posted by HyukjinKwon <gi...@git.apache.org>.
Github user HyukjinKwon commented on a diff in the pull request:

    https://github.com/apache/spark/pull/16553#discussion_r96137414
  
    --- Diff: sql/core/src/test/java/test/org/apache/spark/sql/JavaUDFSuite.java ---
    @@ -108,4 +109,24 @@ public void udf3Test() {
         result = spark.sql("SELECT stringLengthTest('test', 'test2')").head();
         Assert.assertEquals(9, result.getInt(0));
       }
    +
    +  @SuppressWarnings("unchecked")
    +  @Test
    +  public void udf4Test() {
    +    spark.udf().register("inc", new UDF1<Long, Long>() {
    +      @Override
    +      public Long call(Long i) {
    +        return i + 1;
    +      }
    +    }, DataTypes.LongType);
    +
    +    spark.range(10).toDF("x").createOrReplaceTempView("tmp");
    +    List<Row> results = spark.sql("SELECT inc(x) FROM tmp GROUP BY inc(x)").collectAsList();
    --- End diff --
    
    Sure, makes sense. Thanks!


---
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


[GitHub] spark issue #16553: [SPARK-9435][SQL] Reuse function in Java UDF to correctl...

Posted by gatorsmile <gi...@git.apache.org>.
Github user gatorsmile commented on the issue:

    https://github.com/apache/spark/pull/16553
  
    Maybe we can merge it now and you can resolve the comment when @marmbrus is not busy


---
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


[GitHub] spark issue #16553: [SPARK-9435][SQL] Reuse function in Java UDF to correctl...

Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the issue:

    https://github.com/apache/spark/pull/16553
  
    **[Test build #71224 has finished](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/71224/testReport)** for PR 16553 at commit [`30ed14f`](https://github.com/apache/spark/commit/30ed14f38b5c38091d07d0e014a49e494aeb73cc).
     * This patch passes all tests.
     * This patch merges cleanly.
     * This patch adds no public classes.


---
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


[GitHub] spark issue #16553: [SPARK-9435][SQL] Reuse function in Java UDF to correctl...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the issue:

    https://github.com/apache/spark/pull/16553
  
    Test PASSed.
    Refer to this link for build results (access rights to CI server needed): 
    https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder/71224/
    Test PASSed.


---
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


[GitHub] spark pull request #16553: [SPARK-9435][SQL] Reuse function in Java UDF to c...

Posted by gatorsmile <gi...@git.apache.org>.
Github user gatorsmile commented on a diff in the pull request:

    https://github.com/apache/spark/pull/16553#discussion_r96131308
  
    --- Diff: sql/core/src/main/scala/org/apache/spark/sql/UDFRegistration.scala ---
    @@ -109,9 +109,10 @@ class UDFRegistration private[sql] (functionRegistry: FunctionRegistry) extends
              | * @since 1.3.0
              | */
              |def register(name: String, f: UDF$i[$extTypeArgs, _], returnType: DataType): Unit = {
    +         |  val func = f$anyCast.call($anyParams)
              |  functionRegistry.registerFunction(
              |    name,
    -         |    (e: Seq[Expression]) => ScalaUDF(f$anyCast.call($anyParams), returnType, e))
    +         |    (e: Seq[Expression]) => ScalaUDF(func, returnType, e))
    --- End diff --
    
    I can confirm they are the same. 


---
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


[GitHub] spark pull request #16553: [SPARK-9435][SQL] Reuse function in Java UDF to c...

Posted by asfgit <gi...@git.apache.org>.
Github user asfgit closed the pull request at:

    https://github.com/apache/spark/pull/16553


---
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


[GitHub] spark issue #16553: [SPARK-9435][SQL] Reuse function in Java UDF to correctl...

Posted by gatorsmile <gi...@git.apache.org>.
Github user gatorsmile commented on the issue:

    https://github.com/apache/spark/pull/16553
  
    LGTM. cc @marmbrus for final sign off


---
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


[GitHub] spark issue #16553: [SPARK-9435][SQL] Reuse function in Java UDF to correctl...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the issue:

    https://github.com/apache/spark/pull/16553
  
    Test PASSed.
    Refer to this link for build results (access rights to CI server needed): 
    https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder/71398/
    Test PASSed.


---
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


[GitHub] spark issue #16553: [SPARK-9435][SQL] Reuse function in Java UDF to correctl...

Posted by gatorsmile <gi...@git.apache.org>.
Github user gatorsmile commented on the issue:

    https://github.com/apache/spark/pull/16553
  
    Thanks! Merging to master.


---
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