cloud-fan commented on a change in pull request #27584: [SPARK-30814][SQL]
ALTER TABLE ... ADD COLUMN position should be able to reference columns being
added
URL: https://github.com/apache/spark/pull/27584#discussion_r380020469
##########
File path:
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/CheckAnalysis.scala
##########
@@ -483,8 +484,16 @@ trait CheckAnalysis extends PredicateHelper {
checkColumnNotExists("add", add.fieldNames(), table.schema)
}
val parent = findParentStruct("add", add.fieldNames())
- positionArgumentExists(add.position(), parent)
+ add.position match {
+ case after: After =>
+ // Handle the case where column position is referencing
new columns being added.
+ if (!colsToAdd.contains(add.fieldNames().init :+
after.column)) {
+ positionArgumentExists(add.position(), parent)
Review comment:
shall we just add one more parameter to `positionArgumentExists` for the
newly added columns?
----------------------------------------------------------------
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]