Please sign in to comment.
[SPARK-29592][SQL] ALTER TABLE (set partition location) should look u…
…p catalog/table like v2 commands ### What changes were proposed in this pull request? Update `AlterTableSetLocationStatement` to store `partitionSpec` and make `ALTER TABLE a.b.c PARTITION(...) SET LOCATION 'loc'` fail if `partitionSpec` is set with unsupported message. ### Why are the changes needed? It's important to make all the commands have the same table resolution behavior, to avoid confusing end-users. e.g. ``` USE my_catalog DESC t // success and describe the table t from my_catalog ALTER TABLE t PARTITION(...) SET LOCATION 'loc' // report set location with partition spec is not supported. ``` ### Does this PR introduce any user-facing change? yes. When running ALTER TABLE (set partition location), Spark fails the command if the current catalog is set to a v2 catalog, or the table name specified a v2 catalog. ### How was this patch tested? New unit tests Closes #26304 from imback82/alter_table_partition_loc. Authored-by: Terry Kim <firstname.lastname@example.org> Signed-off-by: Wenchen Fan <email@example.com>
- Loading branch information
Showing with 49 additions and 41 deletions.
- +2 −2 sql/catalyst/src/main/antlr4/org/apache/spark/sql/catalyst/parser/SqlBase.g4
- +5 −1 sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/ResolveCatalogs.scala
- +1 −0 sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/parser/AstBuilder.scala
- +1 −0 sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/plans/logical/statements.scala
- +10 −4 sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/parser/DDLParserSuite.scala
- +6 −2 sql/core/src/main/scala/org/apache/spark/sql/catalyst/analysis/ResolveSessionCatalog.scala
- +0 −16 sql/core/src/main/scala/org/apache/spark/sql/execution/SparkSqlParser.scala
- +13 −0 sql/core/src/test/scala/org/apache/spark/sql/connector/AlterTableTests.scala
- +11 −4 sql/core/src/test/scala/org/apache/spark/sql/execution/SQLViewSuite.scala
- +0 −12 sql/core/src/test/scala/org/apache/spark/sql/execution/command/DDLParserSuite.scala