imback82 commented on a change in pull request #27243: [SPARK-30535][SQL]
Migrate ALTER TABLE commands to the new framework
URL: https://github.com/apache/spark/pull/27243#discussion_r367780264
##########
File path:
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/parser/AstBuilder.scala
##########
@@ -2916,14 +2916,14 @@ class AstBuilder(conf: SQLConf) extends
SqlBaseBaseVisitor[AnyRef] with Logging
* }}}
*/
override def visitAddTableColumns(ctx: AddTableColumnsContext): LogicalPlan
= withOrigin(ctx) {
- AlterTableAddColumnsStatement(
- visitMultipartIdentifier(ctx.multipartIdentifier),
+ AlterTableAddColumns(
+ UnresolvedTable(visitMultipartIdentifier(ctx.multipartIdentifier)),
Review comment:
Thanks, I will do it in this PR.
But I wasn't sure if the error message parameter would work well because you
can't guarantee the error message is mapped to the actual error condition
(unless I misunderstood).
How about we introduce the "actual" resolved plan? For example, in
`Analyzer.scala`
```
case u @ UnresolvedTable(identifier) =>
lookupTableOrView(identifier).map {
case v: ResolvedView => u.copy(actual = v)
case table => table
}.getOrElse(u)
```
Then, in `CheckAnalysis.checkAnalysis`,
```
case AlterTable(u @ UnresolvedTable(_, actual: ResolvedView), _) =>
u.failAnalysis("Cannot alter a view with ALTER TABLE. Please use ALTER
VIEW instead")
```
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]