-
Notifications
You must be signed in to change notification settings - Fork 28.5k
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
[SPARK-33856][SQL] Migrate ALTER TABLE ... RENAME TO PARTITION to use UnresolvedTable to resolve the identifier #30862
Conversation
Kubernetes integration test starting |
Test build #133098 has finished for PR 30862 at commit
|
Kubernetes integration test status success |
@@ -445,10 +445,9 @@ class ResolveSessionCatalog( | |||
partSpecsAndLocs.asUnresolvedPartitionSpecs.map(spec => (spec.spec, spec.location)), | |||
ifNotExists) | |||
|
|||
case AlterTableRenamePartitionStatement(tbl, from, to) => | |||
val v1TableName = parseV1Table(tbl, "ALTER TABLE RENAME PARTITION") | |||
case AlterTableRenamePartition(ResolvedV1TableIdentifier(ident), from, to) => |
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 wonder will your changes help to resolve the issue: #30863 (comment)
from: TablePartitionSpec, | ||
to: TablePartitionSpec) extends Command { |
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, use PartitionSpec
spark/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/v2ResolutionPlans.scala
Line 74 in b112e2b
sealed trait PartitionSpec |
spark/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/plans/logical/v2Commands.scala
Line 667 in 0c19497
parts: Seq[PartitionSpec], |
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.
Updated. (I was going to introduce when implementing v2 version, but I guess it doesn't hurt to have it now).
@@ -1642,9 +1642,10 @@ abstract class DDLSuite extends QueryTest with SQLTestUtils { | |||
Set(Map("a" -> "10", "b" -> "p"), Map("a" -> "20", "b" -> "c"), Map("a" -> "3", "b" -> "p"))) | |||
|
|||
// table to alter does not exist | |||
intercept[NoSuchTableException] { | |||
val e = intercept[AnalysisException] { |
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.
Why did you replace 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.
Unresolved table is now handled here:
spark/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/CheckAnalysis.scala
Lines 104 to 105 in 8e26339
case u: UnresolvedTable => | |
u.failAnalysis(s"Table not found: ${u.multipartIdentifier.quoted}") |
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.
in that case, I believe we should throw NoSuchTableException
here.
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.
otherwise with such approach, you will lift all specific exception to the general one - AnalysisException
.
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.
let's fix it separately.
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.
Sounds good. I will do a follow-up PR.
Kubernetes integration test starting |
Test build #133122 has finished for PR 30862 at commit
|
Kubernetes integration test status failure |
cc @cloud-fan |
GA passed, merging to master! |
What changes were proposed in this pull request?
This PR proposes to migrate
ALTER TABLE ... RENAME TO PARTITION
to useUnresolvedTable
to resolve the table identifier. This allows consistent resolution rules (temp view first, etc.) to be applied for both v1/v2 commands. More info about the consistent resolution rule proposal can be found in JIRA or proposal doc.Note that
ALTER TABLE ... RENAME TO PARTITION
is not supported for v2 tables.Why are the changes needed?
The PR makes the resolution consistent behavior consistent. For example,
, but after this PR:
, which is the consistent behavior with other commands.
Does this PR introduce any user-facing change?
After this PR,
ALTER TABLE
in the above example is resolved to a temp viewt
first instead ofspark_catalog.test.t
.How was this patch tested?
Updated existing tests.