-
Notifications
You must be signed in to change notification settings - Fork 28.6k
[SPARK-30282][SQL][FOLLOWUP] SHOW TBLPROPERTIES should support views #28375
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 #121925 has finished for PR 28375 at commit
|
@@ -59,7 +59,7 @@ license: | | |||
|
|||
- In Spark 3.0, you can use `ADD FILE` to add file directories as well. Earlier you could add only single files using this command. To restore the behavior of earlier versions, set `spark.sql.legacy.addSingleFileInAddFile` to `true`. | |||
|
|||
- In Spark 3.0, `SHOW TBLPROPERTIES` throws `AnalysisException` if the table does not exist. In Spark version 2.4 and below, this scenario caused `NoSuchTableException`. Also, `SHOW TBLPROPERTIES` on a temporary view causes `AnalysisException`. In Spark version 2.4 and below, it returned an empty result. | |||
- In Spark 3.0, `SHOW TBLPROPERTIES` throws `AnalysisException` if the table does not exist. In Spark version 2.4 and below, this scenario caused `NoSuchTableException`. |
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.
maybe we can remove it. Exception class change doesn't worth a migration guide item.
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 exception class change was brought up in this comment: #26921 (comment). Can I still remove it?
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.
I don't think error message/exception type change is a breaking change. @dongjoon-hyun what do you think?
@@ -193,18 +193,16 @@ class HiveCommandSuite extends QueryTest with SQLTestUtils with TestHiveSingleto | |||
checkAnswer(sql("SHOW TBLPROPERTIES parquet_tab2('`prop2Key`')"), Row("prop2Val")) | |||
} | |||
|
|||
test("show tblproperties for spark temporary table - AnalysisException is thrown") { | |||
test("show tblproperties for spark temporary table - empty row") { |
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.
can we move this test to show-tblproperties.sql
as well?
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.
OK, will do.
Test build #122008 has finished for PR 28375 at commit
|
retest this please |
Test build #122017 has finished for PR 28375 at commit
|
-- create a temporary view with properties | ||
CREATE TEMPORARY VIEW tv TBLPROPERTIES('p1'='v1') AS SELECT 1 AS c1; | ||
|
||
-- Properties for a temporary view should be empty |
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.
BTW I'd treat this as a bug. I don't think anyone would expect SHOW TBLPROPERTIES
to always return None for temp views.
This is an existing issue, we can deal with it later.
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.
@cloud-fan I will create a PR for this. This can be misleading as you pointed out.
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.
@cloud-fan There are few ways to address this:
- Throw an exception if
CREATE TEMPORARY VIEW
contains properties since they are ignored anyway. - Throw an exception when
SHOW TBLPROPERTIES
are run on a temporary view inShowTablePropertiesCommand
. - Create
UnresolvedTableOrPermanentView
and use it for commands that don't support temporary views.
WDYT?
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.
I'd vote for 3. We have many commands that named as XXX TABLE but can work for views.
thanks, merging to master/3.0! |
### What changes were proposed in this pull request? This PR addresses two things: - `SHOW TBLPROPERTIES` should supports view (a regression introduced by #26921) - `SHOW TBLPROPERTIES` on a temporary view should return empty result (2.4 behavior instead of throwing `AnalysisException`. ### Why are the changes needed? It's a bug. ### Does this PR introduce any user-facing change? Yes, now `SHOW TBLPROPERTIES` works on views: ``` scala> sql("CREATE VIEW view TBLPROPERTIES('p1'='v1', 'p2'='v2') AS SELECT 1 AS c1") scala> sql("SHOW TBLPROPERTIES view").show(truncate=false) +---------------------------------+-------------+ |key |value | +---------------------------------+-------------+ |view.catalogAndNamespace.numParts|2 | |view.query.out.col.0 |c1 | |view.query.out.numCols |1 | |p2 |v2 | |view.catalogAndNamespace.part.0 |spark_catalog| |p1 |v1 | |view.catalogAndNamespace.part.1 |default | +---------------------------------+-------------+ ``` And for a temporary view: ``` scala> sql("CREATE TEMPORARY VIEW tview TBLPROPERTIES('p1'='v1', 'p2'='v2') AS SELECT 1 AS c1") scala> sql("SHOW TBLPROPERTIES tview").show(truncate=false) +---+-----+ |key|value| +---+-----+ +---+-----+ ``` ### How was this patch tested? Added tests. Closes #28375 from imback82/show_tblproperties_followup. Authored-by: Terry Kim <yuminkim@gmail.com> Signed-off-by: Wenchen Fan <wenchen@databricks.com> (cherry picked from commit 3680303) Signed-off-by: Wenchen Fan <wenchen@databricks.com>
What changes were proposed in this pull request?
This PR addresses two things:
SHOW TBLPROPERTIES
should support views (a regression introduced by [SPARK-30282][SQL] Migrate SHOW TBLPROPERTIES to new framework #26921)SHOW TBLPROPERTIES
on a temporary view should return empty result (2.4 behavior instead of throwingAnalysisException
.Why are the changes needed?
It's a bug.
Does this PR introduce any user-facing change?
Yes, now
SHOW TBLPROPERTIES
works on views:And for a temporary view:
How was this patch tested?
Added tests.