-
Notifications
You must be signed in to change notification settings - Fork 29k
[SPARK-29592][SQL] ALTER TABLE (set partition location) should look up catalog/table like v2 commands #26304
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
|
cc: @cloud-fan @rdblue @viirya |
| | ALTER TABLE multipartIdentifier SET locationSpec #setTableLocation | ||
| | ALTER TABLE tableIdentifier partitionSpec SET locationSpec #setPartitionLocation | ||
| | ALTER TABLE multipartIdentifier | ||
| (partitionSpec)? SET locationSpec #setTableLocation |
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.
Please let me know if this needs to be parsed separately.
| */ | ||
| case class AlterTableSetLocationStatement( | ||
| tableName: Seq[String], | ||
| partitionSpec: Option[TablePartitionSpec], |
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 am piggybacking on the existing AlterTableSetLocationStatement (after looking at how AlterTableSetLocationCommand is doing). Please let me know if this is not what we want and I will create a separate statement for partition.
|
Test build #112881 has finished for PR 26304 at commit
|
|
seems a related test failure. |
|
LGTM if tests pass |
| // before resolving the relations. | ||
| assertAnalysisExceptionThrown( | ||
| s"ALTER TABLE $viewName PARTITION (a='4') SET LOCATION '/path/to/home'", | ||
| "ALTER TABLE SET LOCATION does not support partition for v2 tables") |
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, If we need to retain the same behavior to throw an exception with "'$viewName' is a view not a table" message, we need to pass partitionSpec to AlterTable, then check if partitionSpec is set inside AlterTableExec. I don't think it's necessary, but please let me know if that is preferred.
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.
looks reasonable to me
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 assume you meant the current approach looks reasonable, right?
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.
yea, the unsupported feature should be reported first.
sql/core/src/test/scala/org/apache/spark/sql/execution/SQLViewSuite.scala
Outdated
Show resolved
Hide resolved
|
Test build #112932 has finished for PR 26304 at commit
|
|
Test build #112942 has finished for PR 26304 at commit
|
|
thanks, merging to master! |
What changes were proposed in this pull request?
Update
AlterTableSetLocationStatementto storepartitionSpecand makeALTER TABLE a.b.c PARTITION(...) SET LOCATION 'loc'fail ifpartitionSpecis 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.
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