imback82 commented on a change in pull request #33200:
URL: https://github.com/apache/spark/pull/33200#discussion_r675048044
##########
File path:
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/plans/logical/v2Commands.scala
##########
@@ -1099,21 +1066,83 @@ case class UnsetTableProperties(
copy(table = newChild)
}
-trait AlterTableCommand extends UnaryCommand {
+trait AlterTableColumnCommand extends UnaryCommand {
def table: LogicalPlan
- def operation: String
def changes: Seq[TableChange]
override def child: LogicalPlan = table
}
+/**
+ * The logical plan of the ALTER TABLE ... ADD COLUMNS command.
+ */
+case class AlterTableAddColumns(
+ table: LogicalPlan,
+ columnsToAdd: Seq[QualifiedColType]) extends AlterTableColumnCommand {
+ import org.apache.spark.sql.connector.catalog.CatalogV2Util._
+ columnsToAdd.foreach { c =>
+ failNullType(c.dataType)
+ TypeUtils.failWithIntervalType(c.dataType)
+ }
+
+ override def changes: Seq[TableChange] = {
+ columnsToAdd.map { col =>
+ require(col.position.forall(_.resolved),
Review comment:
Updated.
##########
File path:
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/parser/AstBuilder.scala
##########
@@ -3716,7 +3720,12 @@ class AstBuilder extends SqlBaseBaseVisitor[AnyRef] with
SQLConfHelper with Logg
throw QueryParsingErrors.operationInHiveStyleCommandUnsupportedError(
"Column position", "REPLACE COLUMNS", ctx)
}
- typedVisit[QualifiedColType](colType)
+ val col = typedVisit[QualifiedColType](colType)
+ if (col.path.isDefined) {
+ throw QueryParsingErrors.operationInHiveStyleCommandUnsupportedError(
+ "Replacing with a nested column", "REPLACE COLUMNS", ctx)
Review comment:
New requirement for the replace 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.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]