YannByron commented on code in PR #8414:
URL: https://github.com/apache/paimon/pull/8414#discussion_r3511181294


##########
paimon-spark/paimon-spark-common/src/main/scala/org/apache/spark/sql/catalyst/parser/extensions/AbstractPaimonSparkSqlExtensionsParser.scala:
##########
@@ -368,6 +370,39 @@ class UpperCaseCharStream(wrapped: CodePointCharStream) 
extends CharStream {
   // scalastyle:on
 }
 
+object MarkHiveDynamicPartitionWrite extends Rule[LogicalPlan] {
+
+  override def apply(plan: LogicalPlan): LogicalPlan = {
+    AnalysisHelper.allowInvokingTransformsInAnalyzer {
+      plan.transformDown {
+        case insert: InsertIntoStatement
+            if insert.userSpecifiedCols.isEmpty && !isByName(insert) &&
+              insert.partitionSpec.exists(_._2.isEmpty) =>
+          val dynamicPartitionColumns =
+            insert.partitionSpec.collect { case (name, None) => name }.toSeq
+          withNewQuery(
+            insert,
+            PaimonHiveDynamicPartitionQuery(dynamicPartitionColumns, 
insert.query))
+      }
+    }
+  }
+
+  private def withNewQuery(insert: InsertIntoStatement, query: LogicalPlan): 
InsertIntoStatement = {
+    insert.getClass
+      .getMethod("withNewChildInternal", classOf[LogicalPlan])
+      .invoke(insert, query)
+      .asInstanceOf[InsertIntoStatement]
+  }

Review Comment:
   +1



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

Reply via email to