Copilot commented on code in PR #8414:
URL: https://github.com/apache/paimon/pull/8414#discussion_r3510472840
##########
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:
`withNewQuery` uses reflection to call `withNewChildInternal` via
`getMethod`, but `withNewChildInternal` is a protected Catalyst API (see other
overrides in this repo), so `getMethod` will not find it and this rule will
throw `NoSuchMethodException` / `IllegalAccessException` at runtime for
dynamic-partition inserts.
Use Catalyst's public `withNewChildren` (or `copy(query = ...)` when
available) instead of reflectively invoking a protected method.
--
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]