-
Notifications
You must be signed in to change notification settings - Fork 28.7k
[SPARK-33414][SQL] Migrate SHOW CREATE TABLE command to use UnresolvedTableOrView to resolve the identifier #30321
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 failure |
cc @cloud-fan (GA passed) |
Test build #130890 has finished for PR 30321 at commit
|
@@ -155,16 +155,17 @@ abstract class ShowCreateTableSuite extends QueryTest with SQLTestUtils { | |||
val ex = intercept[AnalysisException] { | |||
sql(s"SHOW CREATE TABLE $viewName") | |||
} | |||
assert(ex.getMessage.contains("SHOW CREATE TABLE is not supported on a temporary view")) | |||
assert(ex.getMessage.contains(s"$viewName is a temp view not table or permanent view")) |
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.
Not related to this PR: One idea to improve the error message is to put the command name in UnresolvedTableOrView
or other similar plans when the parser creates the command logical plan.
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.
A good idea! I will follow up on this.
thanks, merging to master! |
…edTable ### What changes were proposed in this pull request? This PR proposes to improve the exception messages while `UnresolvedTable` is handled based on this suggestion: #30321 (comment). Currently, when an identifier is resolved to a view when a table is expected, the following exception message is displayed (e.g., for `COMMENT ON TABLE`): ``` v is a temp view not table. ``` After this PR, the message will be: ``` v is a temp view. 'COMMENT ON TABLE' expects a table. ``` Also, if an identifier is not resolved, the following exception message is currently used: ``` Table not found: t ``` After this PR, the message will be: ``` Table not found for 'COMMENT ON TABLE': t ``` ### Why are the changes needed? To improve the exception message. ### Does this PR introduce _any_ user-facing change? Yes, the exception message will be changed as described above. ### How was this patch tested? Updated existing tests. Closes #30461 from imback82/unresolved_table_message. Authored-by: Terry Kim <[email protected]> Signed-off-by: Wenchen Fan <[email protected]>
…edTableOrView ### What changes were proposed in this pull request? This PR proposes to improve the exception messages while `UnresolvedTableOrView` is handled based on this suggestion: #30321 (comment). Currently, when an identifier is resolved to a temp view when a table/permanent view is expected, the following exception message is displayed (e.g., for `SHOW CREATE TABLE`): ``` t is a temp view not table or permanent view. ``` After this PR, the message will be: ``` t is a temp view. 'SHOW CREATE TABLE' expects a table or permanent view. ``` Also, if an identifier is not resolved, the following exception message is currently used: ``` Table or view not found: t ``` After this PR, the message will be: ``` Table or permanent view not found for 'SHOW CREATE TABLE': t ``` or ``` Table or view not found for 'ANALYZE TABLE ... FOR COLUMNS ...': t ``` ### Why are the changes needed? To improve the exception message. ### Does this PR introduce _any_ user-facing change? Yes, the exception message will be changed as described above. ### How was this patch tested? Updated existing tests. Closes #30475 from imback82/unresolved_table_or_view. Authored-by: Terry Kim <[email protected]> Signed-off-by: Wenchen Fan <[email protected]>
What changes were proposed in this pull request?
This PR proposes to migrate
SHOW CREATE TABLE
to useUnresolvedTableOrView
to resolve the table identifier. This allows consistent resolution rules (temp view first, etc.) to be applied for both v1/v2 commands. More info about the consistent resolution rule proposal can be found in JIRA or proposal doc.Note that
SHOW CREATE TABLE
works only with a v1 table and a permanent view, and not supported for v2 tables.Why are the changes needed?
The changes allow consistent resolution behavior when resolving the table identifier. For example, the following is the current behavior:
With this change,
SHOW CREATE TABLE ... AS SERDE
above fails with the following:, which is expected since temporary view is resolved first and
SHOW CREATE TABLE ... AS SERDE
doesn't support a temporary view.Note that there is no behavior change for
SHOW CREATE TABLE
withoutAS SERDE
since it was already resolving to a temporary view first. See below for more detail.Does this PR introduce any user-facing change?
After this PR,
SHOW CREATE TABLE t AS SERDE
is resolved to a temp viewt
instead of tabledb.t
in the above scenario.Note that there is no behavior change for
SHOW CREATE TABLE
withoutAS SERDE
, but the exception message changes fromSHOW CREATE TABLE is not supported on a temporary view
tot is a temp view not table or permanent view
.How was this patch tested?
Updated existing tests.