-
Notifications
You must be signed in to change notification settings - Fork 29k
[SPARK-20380][SQL] Unable to set/unset table comment property using ALTER TABLE SET/UNSET TBLPROPERTIES ddl #17649
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
Closed
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
sql/core/src/test/resources/sql-tests/inputs/describe-table-after-alter-table.sql
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| CREATE TABLE table_with_comment (a STRING, b INT, c STRING, d STRING) USING parquet COMMENT 'added'; | ||
|
|
||
| DESC FORMATTED table_with_comment; | ||
|
|
||
| -- ALTER TABLE BY MODIFYING COMMENT | ||
| ALTER TABLE table_with_comment SET TBLPROPERTIES("comment"= "modified comment", "type"= "parquet"); | ||
|
|
||
| DESC FORMATTED table_with_comment; | ||
|
|
||
| -- DROP TEST TABLE | ||
| DROP TABLE table_with_comment; | ||
|
|
||
| -- CREATE TABLE WITHOUT COMMENT | ||
| CREATE TABLE table_comment (a STRING, b INT) USING parquet; | ||
|
|
||
| DESC FORMATTED table_comment; | ||
|
|
||
| -- ALTER TABLE BY ADDING COMMENT | ||
| ALTER TABLE table_comment SET TBLPROPERTIES(comment = "added comment"); | ||
|
|
||
| DESC formatted table_comment; | ||
|
|
||
| -- ALTER UNSET PROPERTIES COMMENT | ||
| ALTER TABLE table_comment UNSET TBLPROPERTIES IF EXISTS ('comment'); | ||
|
|
||
| DESC FORMATTED table_comment; | ||
|
|
||
| -- DROP TEST TABLE | ||
| DROP TABLE table_comment; |
161 changes: 161 additions & 0 deletions
161
sql/core/src/test/resources/sql-tests/results/describe-table-after-alter-table.sql.out
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,161 @@ | ||
| -- Automatically generated by SQLQueryTestSuite | ||
| -- Number of queries: 12 | ||
|
|
||
|
|
||
| -- !query 0 | ||
| CREATE TABLE table_with_comment (a STRING, b INT, c STRING, d STRING) USING parquet COMMENT 'added' | ||
| -- !query 0 schema | ||
| struct<> | ||
| -- !query 0 output | ||
|
|
||
|
|
||
|
|
||
| -- !query 1 | ||
| DESC FORMATTED table_with_comment | ||
| -- !query 1 schema | ||
| struct<col_name:string,data_type:string,comment:string> | ||
| -- !query 1 output | ||
| # col_name data_type comment | ||
| a string | ||
| b int | ||
| c string | ||
| d string | ||
|
|
||
| # Detailed Table Information | ||
| Database default | ||
| Table table_with_comment | ||
| Created [not included in comparison] | ||
| Last Access [not included in comparison] | ||
| Type MANAGED | ||
| Provider parquet | ||
| Comment added | ||
| Location [not included in comparison]sql/core/spark-warehouse/table_with_comment | ||
|
|
||
|
|
||
| -- !query 2 | ||
| ALTER TABLE table_with_comment SET TBLPROPERTIES("comment"= "modified comment", "type"= "parquet") | ||
| -- !query 2 schema | ||
| struct<> | ||
| -- !query 2 output | ||
|
|
||
|
|
||
|
|
||
| -- !query 3 | ||
| DESC FORMATTED table_with_comment | ||
| -- !query 3 schema | ||
| struct<col_name:string,data_type:string,comment:string> | ||
| -- !query 3 output | ||
| # col_name data_type comment | ||
| a string | ||
| b int | ||
| c string | ||
| d string | ||
|
|
||
| # Detailed Table Information | ||
| Database default | ||
| Table table_with_comment | ||
| Created [not included in comparison] | ||
| Last Access [not included in comparison] | ||
| Type MANAGED | ||
| Provider parquet | ||
| Comment modified comment | ||
| Properties [type=parquet] | ||
| Location [not included in comparison]sql/core/spark-warehouse/table_with_comment | ||
|
|
||
|
|
||
| -- !query 4 | ||
| DROP TABLE table_with_comment | ||
| -- !query 4 schema | ||
| struct<> | ||
| -- !query 4 output | ||
|
|
||
|
|
||
|
|
||
| -- !query 5 | ||
| CREATE TABLE table_comment (a STRING, b INT) USING parquet | ||
| -- !query 5 schema | ||
| struct<> | ||
| -- !query 5 output | ||
|
|
||
|
|
||
|
|
||
| -- !query 6 | ||
| DESC FORMATTED table_comment | ||
| -- !query 6 schema | ||
| struct<col_name:string,data_type:string,comment:string> | ||
| -- !query 6 output | ||
| # col_name data_type comment | ||
| a string | ||
| b int | ||
|
|
||
| # Detailed Table Information | ||
| Database default | ||
| Table table_comment | ||
| Created [not included in comparison] | ||
| Last Access [not included in comparison] | ||
| Type MANAGED | ||
| Provider parquet | ||
| Location [not included in comparison]sql/core/spark-warehouse/table_comment | ||
|
|
||
|
|
||
| -- !query 7 | ||
| ALTER TABLE table_comment SET TBLPROPERTIES(comment = "added comment") | ||
| -- !query 7 schema | ||
| struct<> | ||
| -- !query 7 output | ||
|
|
||
|
|
||
|
|
||
| -- !query 8 | ||
| DESC formatted table_comment | ||
| -- !query 8 schema | ||
| struct<col_name:string,data_type:string,comment:string> | ||
| -- !query 8 output | ||
| # col_name data_type comment | ||
| a string | ||
| b int | ||
|
|
||
| # Detailed Table Information | ||
| Database default | ||
| Table table_comment | ||
| Created [not included in comparison] | ||
| Last Access [not included in comparison] | ||
| Type MANAGED | ||
| Provider parquet | ||
| Comment added comment | ||
| Location [not included in comparison]sql/core/spark-warehouse/table_comment | ||
|
|
||
|
|
||
| -- !query 9 | ||
| ALTER TABLE table_comment UNSET TBLPROPERTIES IF EXISTS ('comment') | ||
| -- !query 9 schema | ||
| struct<> | ||
| -- !query 9 output | ||
|
|
||
|
|
||
|
|
||
| -- !query 10 | ||
| DESC FORMATTED table_comment | ||
| -- !query 10 schema | ||
| struct<col_name:string,data_type:string,comment:string> | ||
| -- !query 10 output | ||
| # col_name data_type comment | ||
| a string | ||
| b int | ||
|
|
||
| # Detailed Table Information | ||
| Database default | ||
| Table table_comment | ||
| Created [not included in comparison] | ||
| Last Access [not included in comparison] | ||
| Type MANAGED | ||
| Provider parquet | ||
| Location [not included in comparison]sql/core/spark-warehouse/table_comment | ||
|
|
||
|
|
||
| -- !query 11 | ||
| DROP TABLE table_comment | ||
| -- !query 11 schema | ||
| struct<> | ||
| -- !query 11 output | ||
|
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back 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.
This only fixes the issue in InMemoryCatalog. We still have a hole in HiveExternalCatalog.
Could you move the fixes to
AlterTableSetPropertiesCommand?Uh oh!
There was an error while loading. Please reload this page.
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.
@gatorsmile @wzhfy
As i noticed for hive tables already the 'comment' property is been filtered while getting the hive table metadata(reading) in HiveClientImpl.scala -- > getTableOption() API. so i think it will be better if we can do the same for InMemoryCatalogs type table, while reading the table metadata we can exclude the 'comment', i think while alter command if we exclude 'comment' from table definition this can lead to an inconsistency state of metadata,
Eg: In create table we persist the 'comment' property inside properties map in metadata and while altering we are not.
Please correct me if i am going in wrong direction, Thanks.
I am very much curious to know why spark persists 'comment' property in both CatalogTable field level and in its properties map.
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 should not duplicate
commentin both CatalogTable field and table properties. Please correct it if you found it in the code. Thanks!Uh oh!
There was an error while loading. Please reload this page.
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.
sure, i will revisit and verify on this point and will update the PR.
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.
Thank you!