-
Notifications
You must be signed in to change notification settings - Fork 29k
[SPARK-33692][SQL] View should use captured catalog and namespace to lookup function #30662
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
Conversation
|
Kubernetes integration test starting |
|
Kubernetes integration test status success |
|
Test build #132405 has finished for PR 30662 at commit
|
|
Kubernetes integration test starting |
|
Kubernetes integration test status success |
|
Test build #132414 has finished for PR 30662 at commit
|
|
Kubernetes integration test starting |
|
Test build #132423 has finished for PR 30662 at commit
|
|
Kubernetes integration test status success |
|
retest this please |
|
Kubernetes integration test starting |
|
Kubernetes integration test status failure |
|
Test build #132430 has finished for PR 30662 at commit
|
|
retest this please |
|
Kubernetes integration test starting |
|
Kubernetes integration test status failure |
|
Test build #132436 has finished for PR 30662 at commit
|
sql/hive/src/test/scala/org/apache/spark/sql/hive/UDFSuite.scala
Outdated
Show resolved
Hide resolved
|
Kubernetes integration test starting |
|
Kubernetes integration test status success |
|
Test build #132455 has finished for PR 30662 at commit
|
| case Seq(_, db) => db | ||
| case Seq(catalog, namespace @ _*) => | ||
| throw new AnalysisException( | ||
| s"Unsupported catalog ${catalog} and " + |
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.
we can just say: V2 catalog does not support functions yet
| return functionRegistry.lookupFunction(name, children) | ||
| val isResolvingView = AnalysisContext.get.catalogAndNamespace.nonEmpty | ||
| // We lookup function without database in two cases: | ||
| // 1. the function is not a temporary function |
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.
the function is built-in
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.
there are also external functions, in isTemporaryFunction:
name.database.isEmpty &&
functionRegistry.functionExists(name) &&
!FunctionRegistry.builtin.functionExists(name) &&
!hiveFunctions.contains(name.funcName.toLowerCase(Locale.ROOT))
| // temporary view | ||
| sql(s"CREATE TEMPORARY VIEW tempView1 AS SELECT $tempFunctionName(id) from tab1") | ||
| checkAnswer(sql("select count(*) FROM tempView1"), Row(10)) | ||
| // TODO: temporary function support for temporary view with sql text stored will |
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.
nit: TODO (SPARK-XXX): support temporary functions in temp views
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.
yeah, but there are also test failure in udf-inner-join.sql related to temp function in temp views. I changed to another way to find these test cases. could you check again?
https://github.com/apache/spark/pull/30662/files#diff-ed19f376a63eba52eea59ca71f3355d4495fad4fad4db9a3324aade0d4986a47R118
cloud-fan
left a comment
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.
LGTM except some minor comments
|
Kubernetes integration test starting |
|
Kubernetes integration test status success |
|
Test build #132476 has finished for PR 30662 at commit
|
| relationCache: mutable.Map[Seq[String], LogicalPlan] = mutable.Map.empty, | ||
| referredTempViewNames: Seq[Seq[String]] = Seq.empty) | ||
| referredTempViewNames: Seq[Seq[String]] = Seq.empty, | ||
| isTempView: Boolean = false) |
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.
then shall we just use referredTempFuncNames?
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.
if we change the type to referredTempFuncNames: Option[Seq[String]], then it can replace isTempView. Because Seq.empty can be permanent view or temp view refers non temp functions.
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.
yea let's do it then. We can use isTempView: Boolean = false in the backport PR of 3.0/2.4.
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.
you are correct in the first comment. we can just use referredTempFunctionNames. But this approach will fix both permanent and temp view problems, which I was planning to fix them separately. Anyway, I switch to use referredTempFunctionNames in the latest commit.
BTW, in 3.0/2.4, temp view stores analyzed plan, and won't be wrapped in View, so we don't need the isTempView flag.
|
Kubernetes integration test starting |
|
Kubernetes integration test starting |
|
Kubernetes integration test status failure |
|
Kubernetes integration test starting |
|
Kubernetes integration test status success |
|
Kubernetes integration test status success |
| case Seq(catalog, namespace @ _*) => | ||
| throw new AnalysisException( | ||
| s"V2 catalog does not support functions yet. " + | ||
| s"catalog: ${catalog}, namespace '${namespace.mkString("[", ".", "]")}'") |
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.
nit: namespace.quoted. We need to import CatalogV2Implicits._ first.
|
Test build #132531 has finished for PR 30662 at commit
|
|
Test build #132532 has finished for PR 30662 at commit
|
|
Kubernetes integration test starting |
|
Kubernetes integration test status success |
|
Test build #132546 has finished for PR 30662 at commit
|
|
retest this please |
|
The failed 3 tests are the well known flaky tests from the thrift-server module. I'm merging it to master/3.1, thanks! |
…lookup function ### What changes were proposed in this pull request? Using the view captured catalog and namespace to lookup function, so the view referred functions won't be overridden by newly created function with the same name, but different database or function type (i.e. temporary function) ### Why are the changes needed? bug fix, without this PR, changing database or create a temporary function with the same name may cause failure when querying a view. ### Does this PR introduce _any_ user-facing change? Yes, bug fix. ### How was this patch tested? newly added and existing test cases. Closes #30662 from linhongliu-db/SPARK-33692. Lead-authored-by: Linhong Liu <[email protected]> Co-authored-by: Linhong Liu <[email protected]> Signed-off-by: Wenchen Fan <[email protected]> (cherry picked from commit 1554977) Signed-off-by: Wenchen Fan <[email protected]>
What changes were proposed in this pull request?
Using the view captured catalog and namespace to lookup function, so the view
referred functions won't be overridden by newly created function with the same name,
but different database or function type (i.e. temporary function)
Why are the changes needed?
bug fix, without this PR, changing database or create a temporary function with
the same name may cause failure when querying a view.
Does this PR introduce any user-facing change?
Yes, bug fix.
How was this patch tested?
newly added and existing test cases.