-
Notifications
You must be signed in to change notification settings - Fork 29k
[SPARK-11599] [SQL] fix NPE when resolve Hive UDF in SQLParser #9576
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -20,22 +20,19 @@ package org.apache.spark.sql.hive.execution | |
| import java.io.File | ||
| import java.util.{Locale, TimeZone} | ||
|
|
||
| import org.apache.spark.sql.execution.joins.BroadcastNestedLoopJoin | ||
|
|
||
| import scala.util.Try | ||
|
|
||
| import org.scalatest.BeforeAndAfter | ||
|
|
||
| import org.apache.hadoop.hive.conf.HiveConf.ConfVars | ||
| import org.scalatest.BeforeAndAfter | ||
|
|
||
| import org.apache.spark.{SparkFiles, SparkException} | ||
| import org.apache.spark.sql.{AnalysisException, DataFrame, Row} | ||
| import org.apache.spark.sql.catalyst.expressions.Cast | ||
| import org.apache.spark.sql.catalyst.plans.logical.Project | ||
| import org.apache.spark.sql.execution.joins.BroadcastNestedLoopJoin | ||
| import org.apache.spark.sql.hive._ | ||
| import org.apache.spark.sql.hive.test.TestHiveContext | ||
| import org.apache.spark.sql.hive.test.TestHive | ||
| import org.apache.spark.sql.hive.test.TestHive._ | ||
| import org.apache.spark.sql.hive.test.{TestHive, TestHiveContext} | ||
| import org.apache.spark.sql.{AnalysisException, DataFrame, Row} | ||
| import org.apache.spark.{SparkException, SparkFiles} | ||
|
|
||
| case class TestData(a: Int, b: String) | ||
|
|
||
|
|
@@ -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()") | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Without the fix, this line will throw NPE, right?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 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. |
||
| } | ||
| assert(e.getMessage.contains("undefined function not_a_udf")) | ||
| success = true | ||
| } | ||
| } | ||
| t.start() | ||
| t.join() | ||
| assert(success) | ||
| } | ||
|
|
||
| createQueryTest("select from thrift based table", | ||
| "SELECT * from src_thrift") | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a note. In
HiveQLDialect, when we parse a query, we usesqlContext.executionHive.withHiveState. Right now,create functionis still broken because the metadata of the function is in metadata hive. However, it is the work of another PR.