-
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -179,6 +179,7 @@ case class AlterTableUnsetPropertiesStatement( | |
| */ | ||
| case class AlterTableSetLocationStatement( | ||
| tableName: Seq[String], | ||
| partitionSpec: Option[TablePartitionSpec], | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I am piggybacking on the existing |
||
| location: String) extends ParsedStatement | ||
|
|
||
| /** | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -136,14 +136,21 @@ abstract class SQLViewSuite extends QueryTest with SQLTestUtils { | |
| assertNoSuchTable(s"ALTER TABLE $viewName SET SERDE 'whatever'") | ||
| assertNoSuchTable(s"ALTER TABLE $viewName PARTITION (a=1, b=2) SET SERDE 'whatever'") | ||
| assertNoSuchTable(s"ALTER TABLE $viewName SET SERDEPROPERTIES ('p' = 'an')") | ||
| assertNoSuchTable(s"ALTER TABLE $viewName PARTITION (a='4') SET LOCATION '/path/to/home'") | ||
| assertNoSuchTable(s"ALTER TABLE $viewName ADD IF NOT EXISTS PARTITION (a='4', b='8')") | ||
| assertNoSuchTable(s"ALTER TABLE $viewName DROP PARTITION (a='4', b='8')") | ||
| assertNoSuchTable(s"ALTER TABLE $viewName PARTITION (a='4') RENAME TO PARTITION (a='5')") | ||
| assertNoSuchTable(s"ALTER TABLE $viewName RECOVER PARTITIONS") | ||
|
|
||
| // For v2 ALTER TABLE statements, we have better error message saying view is not supported. | ||
| assertViewNotSupported(s"ALTER TABLE $viewName SET LOCATION '/path/to/your/lovely/heart'") | ||
| assertAnalysisError( | ||
| s"ALTER TABLE $viewName SET LOCATION '/path/to/your/lovely/heart'", | ||
| s"'$viewName' is a view not a table") | ||
|
|
||
| // For the following v2 ALERT TABLE statements, unsupported operations are checked first | ||
| // before resolving the relations. | ||
| assertAnalysisError( | ||
| s"ALTER TABLE $viewName PARTITION (a='4') SET LOCATION '/path/to/home'", | ||
| "ALTER TABLE SET LOCATION does not support partition for v2 tables") | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. looks reasonable to me
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I assume you meant the current approach looks reasonable, right?
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yea, the unsupported feature should be reported first. |
||
| } | ||
| } | ||
|
|
||
|
|
@@ -177,9 +184,9 @@ abstract class SQLViewSuite extends QueryTest with SQLTestUtils { | |
| } | ||
| } | ||
|
|
||
| private def assertViewNotSupported(query: String): Unit = { | ||
| private def assertAnalysisError(query: String, message: String): Unit = { | ||
| val e = intercept[AnalysisException](sql(query)) | ||
| assert(e.message.contains("'testView' is a view not a table")) | ||
| assert(e.message.contains(message)) | ||
| } | ||
|
|
||
| test("error handling: insert/load/truncate table commands against a view") { | ||
|
|
||
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.
Please let me know if this needs to be parsed separately.