cloud-fan commented on a change in pull request #29339:
URL: https://github.com/apache/spark/pull/29339#discussion_r496736853



##########
File path: 
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/plans/logical/v2Commands.scala
##########
@@ -551,3 +552,31 @@ case class ShowFunctions(
     pattern: Option[String]) extends Command {
   override def children: Seq[LogicalPlan] = child.toSeq
 }
+
+/**
+ * The logical plan of the ALTER TABLE ADD PARTITION command that works for v2 
tables.
+ *
+ * The syntax of this command is:
+ * {{{
+ *     ALTER TABLE table ADD [IF NOT EXISTS]
+ *                 PARTITION spec1 [LOCATION 'loc1'][, PARTITION spec2 
[LOCATION 'loc2'], ...];
+ * }}}
+ */
+case class AlterTableAddPartition(
+    table: SupportsPartitionManagement,

Review comment:
       This is a good point and does reveal a flaw in the current framework.
   
   We can add some util classes to help us resolve partition spec
   ```
   trait PartitionSpec
   
   case class UnresolvedPartitionSpec(spec: TablePartitionSpec, location: 
Option[String]) extends PartitionSpec
   
   case class ResolvedPartitionSpec(spec: InternalRow, location: 
Option[String]) extends PartitionSpec
   ```
   
   then the command can be defined as
   ```
   case class AlterTableAddPartition(table: LogicalPlan, partitions: 
Seq[PartitionSpec], ifExists: Boolean, ...)
   ```
   
   And we add a rule to match `AlterTableAddPartition`, and resolve the 
`UnresolvedPartitionSpec` to `ResolvedPartitionSpec`.




----------------------------------------------------------------
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]



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to