You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by davies <gi...@git.apache.org> on 2015/11/09 23:21:56 UTC

[GitHub] spark pull request: [SPARK-11599] [SQL] fix NPE when resolve Hive ...

GitHub user davies opened a pull request:

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

    [SPARK-11599] [SQL] fix NPE when resolve Hive UDF in SQLParser

    The DataFrame APIs that takes a SQL expression always use SQLParser, then the HiveFunctionRegistry will called outside of Hive state, cause NPE if there is not a active Session State for current thread (in PySpark).
    
    cc @rxin @yhuai 

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

    $ git pull https://github.com/davies/spark hive_udf

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

    https://github.com/apache/spark/pull/9576.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 #9576
    
----
commit db747843ae6869ec3c6aa999ab72f62bf911c0e5
Author: Davies Liu <da...@databricks.com>
Date:   2015-11-09T22:16:43Z

    fix NPE when resolve Hive UDF

----


---
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: [SPARK-11599] [SQL] fix NPE when resolve Hive ...

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

    https://github.com/apache/spark/pull/9576#issuecomment-155258036
  
    **[Test build #2023 has finished](https://amplab.cs.berkeley.edu/jenkins/job/NewSparkPullRequestBuilder/2023/consoleFull)** for PR 9576 at commit [`db74784`](https://github.com/apache/spark/commit/db747843ae6869ec3c6aa999ab72f62bf911c0e5).
     * 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: [SPARK-11599] [SQL] fix NPE when resolve Hive ...

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

    https://github.com/apache/spark/pull/9576#discussion_r44348401
  
    --- Diff: sql/hive/src/test/scala/org/apache/spark/sql/hive/execution/HiveQuerySuite.scala ---
    @@ -1235,6 +1232,26 @@ class HiveQuerySuite extends HiveComparisonTest with BeforeAndAfter {
     
       }
     
    +  test("lookup hive UDF in another thread") {
    +    val e = intercept[AnalysisException] {
    +      range(1).selectExpr("not_a_udf()")
    +    }
    +    assert(e.getMessage.contains("undefined function not_a_udf"))
    +    var success = false
    +    val t = new Thread("test") {
    +      override def run(): Unit = {
    +        val e = intercept[AnalysisException] {
    +          range(1).selectExpr("not_a_udf()")
    --- End diff --
    
    How about we add a comment to let readers know what's the original exception without this fix? We can add this comment when we merge the PR.


---
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: [SPARK-11599] [SQL] fix NPE when resolve Hive ...

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

    https://github.com/apache/spark/pull/9576#discussion_r44342951
  
    --- Diff: sql/hive/src/test/scala/org/apache/spark/sql/hive/execution/HiveQuerySuite.scala ---
    @@ -1235,6 +1232,26 @@ class HiveQuerySuite extends HiveComparisonTest with BeforeAndAfter {
     
       }
     
    +  test("lookup hive UDF in another thread") {
    +    val e = intercept[AnalysisException] {
    +      range(1).selectExpr("not_a_udf()")
    +    }
    +    assert(e.getMessage.contains("undefined function not_a_udf"))
    +    var success = false
    +    val t = new Thread("test") {
    +      override def run(): Unit = {
    +        val e = intercept[AnalysisException] {
    +          range(1).selectExpr("not_a_udf()")
    --- End diff --
    
    Without the fix, this line will throw NPE, right?


---
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: [SPARK-11599] [SQL] fix NPE when resolve Hive ...

Posted by davies <gi...@git.apache.org>.
Github user davies commented on the pull request:

    https://github.com/apache/spark/pull/9576#issuecomment-155344051
  
    Merged into master and 1.6.


---
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: [SPARK-11599] [SQL] fix NPE when resolve Hive ...

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

    https://github.com/apache/spark/pull/9576#issuecomment-155217669
  
     Merged build triggered.


---
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: [SPARK-11599] [SQL] fix NPE when resolve Hive ...

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

    https://github.com/apache/spark/pull/9576#issuecomment-155230233
  
    Merged build finished. Test FAILed.


---
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: [SPARK-11599] [SQL] fix NPE when resolve Hive ...

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

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


---
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: [SPARK-11599] [SQL] fix NPE when resolve Hive ...

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

    https://github.com/apache/spark/pull/9576#discussion_r44342939
  
    --- Diff: sql/hive/src/main/scala/org/apache/spark/sql/hive/HiveContext.scala ---
    @@ -455,7 +455,15 @@ class HiveContext private[hive](
       // Note that HiveUDFs will be overridden by functions registered in this context.
       @transient
       override protected[sql] lazy val functionRegistry: FunctionRegistry =
    -    new HiveFunctionRegistry(FunctionRegistry.builtin.copy())
    +    new HiveFunctionRegistry(FunctionRegistry.builtin.copy()) {
    +      override def lookupFunction(name: String, children: Seq[Expression]): Expression = {
    +        // Hive Registry need current database to lookup function
    +        // TODO: the current database of executionHive should be consistent with metadataHive
    +        executionHive.withHiveState {
    +          super.lookupFunction(name, children)
    --- End diff --
    
    Just a note. In `HiveQLDialect`, when we parse a query, we use `sqlContext.executionHive.withHiveState`. Right now, `create function` is still broken because the metadata of the function is in metadata hive. However, it is the work of another PR.


---
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: [SPARK-11599] [SQL] fix NPE when resolve Hive ...

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

    https://github.com/apache/spark/pull/9576#discussion_r44344420
  
    --- Diff: sql/hive/src/test/scala/org/apache/spark/sql/hive/execution/HiveQuerySuite.scala ---
    @@ -1235,6 +1232,26 @@ class HiveQuerySuite extends HiveComparisonTest with BeforeAndAfter {
     
       }
     
    +  test("lookup hive UDF in another thread") {
    +    val e = intercept[AnalysisException] {
    +      range(1).selectExpr("not_a_udf()")
    +    }
    +    assert(e.getMessage.contains("undefined function not_a_udf"))
    +    var success = false
    +    val t = new Thread("test") {
    +      override def run(): Unit = {
    +        val e = intercept[AnalysisException] {
    +          range(1).selectExpr("not_a_udf()")
    --- End diff --
    
    Yes


---
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: [SPARK-11599] [SQL] fix NPE when resolve Hive ...

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

    https://github.com/apache/spark/pull/9576#issuecomment-155217704
  
    Merged build started.


---
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: [SPARK-11599] [SQL] fix NPE when resolve Hive ...

Posted by yhuai <gi...@git.apache.org>.
Github user yhuai commented on the pull request:

    https://github.com/apache/spark/pull/9576#issuecomment-155229981
  
    LGTM pending jenkins.


---
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: [SPARK-11599] [SQL] fix NPE when resolve Hive ...

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

    https://github.com/apache/spark/pull/9576#issuecomment-155218052
  
    **[Test build #45427 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/45427/consoleFull)** for PR 9576 at commit [`db74784`](https://github.com/apache/spark/commit/db747843ae6869ec3c6aa999ab72f62bf911c0e5).


---
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: [SPARK-11599] [SQL] fix NPE when resolve Hive ...

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

    https://github.com/apache/spark/pull/9576#issuecomment-155230178
  
    **[Test build #45427 has finished](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/45427/consoleFull)** for PR 9576 at commit [`db74784`](https://github.com/apache/spark/commit/db747843ae6869ec3c6aa999ab72f62bf911c0e5).
     * This patch **fails Spark unit 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: [SPARK-11599] [SQL] fix NPE when resolve Hive ...

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

    https://github.com/apache/spark/pull/9576#issuecomment-155231104
  
    **[Test build #2023 has started](https://amplab.cs.berkeley.edu/jenkins/job/NewSparkPullRequestBuilder/2023/consoleFull)** for PR 9576 at commit [`db74784`](https://github.com/apache/spark/commit/db747843ae6869ec3c6aa999ab72f62bf911c0e5).


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