-
Notifications
You must be signed in to change notification settings - Fork 29k
[SPARK-34302][SQL][FOLLOWUP] More code cleanup #33213
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 @imback82 |
|
Test build #140642 has finished for PR 33213 at commit
|
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.
|
Kubernetes integration test starting |
|
Kubernetes integration test status success |
|
Kubernetes integration test starting |
|
Kubernetes integration test status success |
|
Test build #140645 has finished for PR 33213 at commit
|
|
Kubernetes integration test starting |
|
Test build #140660 has finished for PR 33213 at commit
|
|
Kubernetes integration test status success |
imback82
left a comment
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.
LGTM (if tests pass), thanks @cloud-fan!
| case o => alter.failAnalysis(s"Cannot ${alter.operation} ${fieldName.quoted}, " + | ||
| s"because its parent is not a StructType. Found $o") | ||
| } | ||
| alter.failAnalysis(s"Couldn't resolve positional argument $position amongst " + |
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.
UnresolvedFieldPosition was carrying fieldName to reconstruct this message (no need to match by commands). If this is not needed anymore, we can drop fieldName. Thanks for cleaning this up.
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.
The error message can refer to a position in the SQL string, which should provide sufficient context. The missing top-level column also uses a simple error message.
| sql(s"ALTER TABLE $tableName ALTER COLUMN bad_column COMMENT 'test'") | ||
| }.getMessage | ||
| assert(msg.contains("Cannot update missing field bad_column in h2.test.alt_table")) | ||
| assert(msg.contains("Missing field bad_column in table h2.test.alt_table")) |
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.
If we are simplifying the message, we may not need to have AlterTableComand.operation. I can remove it in #33200.
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, thanks!
|
Kubernetes integration test starting |
|
Kubernetes integration test status success |
|
thanks for the review, merging to master/3.2 (since it's a followup). |
### What changes were proposed in this pull request? This is a followup of #33113, to do some code cleanup: 1. `UnresolvedFieldPosition` doesn't need to include the field name. We can get it through "context" (`AlterTableAlterColumn.column.name`). 2. Run `ResolveAlterTableCommands` in the main resolution batch, so that the column/field resolution is also unified between v1 and v2 commands (same error message). 3. Fail immediately in `ResolveAlterTableCommands` if we can't resolve the field, instead of waiting until `CheckAnalysis`. We don't expect other rules to resolve fields in ALTER TABLE commands, so failing immediately is simpler and we can remove duplicated code in `CheckAnalysis`. ### Why are the changes needed? code simplification. ### Does this PR introduce _any_ user-facing change? no ### How was this patch tested? existing tests Closes #33213 from cloud-fan/follow. Authored-by: Wenchen Fan <wenchen@databricks.com> Signed-off-by: Wenchen Fan <wenchen@databricks.com> (cherry picked from commit 8b46e26) Signed-off-by: Wenchen Fan <wenchen@databricks.com>
|
Test build #140668 has finished for PR 33213 at commit
|
What changes were proposed in this pull request?
This is a followup of #33113, to do some code cleanup:
UnresolvedFieldPositiondoesn't need to include the field name. We can get it through "context" (AlterTableAlterColumn.column.name).ResolveAlterTableCommandsin the main resolution batch, so that the column/field resolution is also unified between v1 and v2 commands (same error message).ResolveAlterTableCommandsif we can't resolve the field, instead of waiting untilCheckAnalysis. We don't expect other rules to resolve fields in ALTER TABLE commands, so failing immediately is simpler and we can remove duplicated code inCheckAnalysis.Why are the changes needed?
code simplification.
Does this PR introduce any user-facing change?
no
How was this patch tested?
existing tests