-
Notifications
You must be signed in to change notification settings - Fork 29k
[SPARK-22488] [SQL] Fix the view resolution issue in the SparkSession internal table() API #19713
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
|
Test build #83664 has finished for PR 19713 at commit
|
| } | ||
|
|
||
| test("rename temporary view") { | ||
| test("rename temporary table") { |
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.
temporary view is more accurate?
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.
Copied from 2.2 version... : )
| table(sessionState.sqlParser.parseTableIdentifier(tableName)) | ||
| } | ||
|
|
||
| private[sql] def table(tableIdent: TableIdentifier): DataFrame = { |
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.
This is also called by the public table API, so this bug affects the public interface too.
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. many public APIs and DDL command processing are based on this internal API.
|
LGTM |
|
Test build #83678 has finished for PR 19713 at commit
|
|
Test build #83674 has finished for PR 19713 at commit
|
|
it's a valid failure |
|
Test build #83717 has finished for PR 19713 at commit
|
|
|
||
| expect_error(uncacheTable("foo"), | ||
| "Error in uncacheTable : no such table - Table or view 'foo' not found in database 'default'") | ||
| "Error in uncacheTable : analysis error - Table or view not found: foo") |
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.
tiny nit:
expect_error(uncacheTable("foo"),
"Error in uncacheTable : analysis error - Table or view not found: foo")|
Test build #83721 has finished for PR 19713 at commit
|
jiangxb1987
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
|
thanks, merging to master! can you send a new PR for 2.2? |
|
Sounds like we should have for 2.2.1
I’m looking at cutting 2.2.1 ASAP, could someone backport this and tag me?
|
…internal table() API The current internal `table()` API of `SparkSession` bypasses the Analyzer and directly calls `sessionState.catalog.lookupRelation` API. This skips the view resolution logics in our Analyzer rule `ResolveRelations`. This internal API is widely used by various DDL commands, public and internal APIs. Users might get the strange error caused by view resolution when the default database is different. ``` Table or view not found: t1; line 1 pos 14 org.apache.spark.sql.AnalysisException: Table or view not found: t1; line 1 pos 14 at org.apache.spark.sql.catalyst.analysis.package$AnalysisErrorAt.failAnalysis(package.scala:42) ``` This PR is to fix it by enforcing it to use `ResolveRelations` to resolve the table. Added a test case and modified the existing test cases Author: gatorsmile <[email protected]> Closes apache#19713 from gatorsmile/viewResolution.
|
Hi, All. |
…tion ## What changes were proposed in this pull request? During [SPARK-22488](apache#19713) to fix view resolution issue, there occurs a regression at `2.2.1` and `master` branch like the following. This PR fixes that. ```scala scala> spark.version res2: String = 2.2.1 scala> sql("DROP TABLE IF EXISTS t").show 17/12/04 21:01:06 WARN DropTableCommand: org.apache.spark.sql.AnalysisException: Table or view not found: t; org.apache.spark.sql.AnalysisException: Table or view not found: t; ``` ## How was this patch tested? Manual. Author: Dongjoon Hyun <[email protected]> Closes apache#19888 from dongjoon-hyun/SPARK-22686.
…tion ## What changes were proposed in this pull request? During [SPARK-22488](#19713) to fix view resolution issue, there occurs a regression at `2.2.1` and `master` branch like the following. This PR fixes that. ```scala scala> spark.version res2: String = 2.2.1 scala> sql("DROP TABLE IF EXISTS t").show 17/12/04 21:01:06 WARN DropTableCommand: org.apache.spark.sql.AnalysisException: Table or view not found: t; org.apache.spark.sql.AnalysisException: Table or view not found: t; ``` ## How was this patch tested? Manual. Author: Dongjoon Hyun <[email protected]> Closes #19888 from dongjoon-hyun/SPARK-22686. (cherry picked from commit 82183f7) Signed-off-by: Wenchen Fan <[email protected]>
…tion ## What changes were proposed in this pull request? During [SPARK-22488](apache#19713) to fix view resolution issue, there occurs a regression at `2.2.1` and `master` branch like the following. This PR fixes that. ```scala scala> spark.version res2: String = 2.2.1 scala> sql("DROP TABLE IF EXISTS t").show 17/12/04 21:01:06 WARN DropTableCommand: org.apache.spark.sql.AnalysisException: Table or view not found: t; org.apache.spark.sql.AnalysisException: Table or view not found: t; ``` ## How was this patch tested? Manual. Author: Dongjoon Hyun <[email protected]> Closes apache#19888 from dongjoon-hyun/SPARK-22686. (cherry picked from commit 82183f7) Signed-off-by: Wenchen Fan <[email protected]>
What changes were proposed in this pull request?
The current internal
table()API ofSparkSessionbypasses the Analyzer and directly callssessionState.catalog.lookupRelationAPI. This skips the view resolution logics in our Analyzer ruleResolveRelations. This internal API is widely used by various DDL commands, public and internal APIs.Users might get the strange error caused by view resolution when the default database is different.
This PR is to fix it by enforcing it to use
ResolveRelationsto resolve the table.How was this patch tested?
Added a test case and modified the existing test cases