JingsongLi commented on code in PR #8751:
URL: https://github.com/apache/paimon/pull/8751#discussion_r3619446758
##########
paimon-spark/paimon-spark-common/src/main/scala/org/apache/spark/sql/catalyst/parser/extensions/RewriteSparkDDLCommands.scala:
##########
@@ -37,8 +41,41 @@ case class RewriteSparkDDLCommands(spark: SparkSession)
// A new member was added to CreatePaimonView since spark4.0,
// unapply pattern matching is not used here to ensure compatibility
across multiple spark versions.
- case DropPartitions(UnresolvedPaimonRelation(aliasedTable), parts,
ifExists, purge) =>
+ //
+ // Both Paimon data tables and Format Tables with catalog-managed
partitions route DROP
+ // PARTITION through PaimonDropPartitions (the latter resolve partial
specs through the
+ // partition gateway, so they must bypass Spark's strict partition-spec
resolution too). A
+ // single extractor loads the table once and classifies it, avoiding a
second
+ // catalog.loadTable per analyzer iteration. Format Tables using
filesystem partition
+ // discovery are not matched and keep Spark's own resolution plus the
explicit unsupported
+ // error at execution.
+ case DropPartitions(UnresolvedPaimonDropTarget(aliasedTable), parts,
ifExists, purge) =>
PaimonDropPartitions(aliasedTable, parts, ifExists, purge)
+ }
+
+ private object UnresolvedPaimonDropTarget {
+ def unapply(plan: LogicalPlan): Option[LogicalPlan] = {
+ EliminateSubqueryAliases(plan) match {
+ case UnresolvedTable(multipartIdentifier, _, _)
+ if isPaimonDropTarget(multipartIdentifier) =>
+ Some(plan)
+ case _ => None
+ }
+ }
+ }
+ private def isPaimonDropTarget(multipartIdentifier: Seq[String]): Boolean = {
+ multipartIdentifier match {
+ case CatalogAndIdentifier(catalog: TableCatalog, ident) =>
+ Try(catalog.loadTable(ident))
+ .map {
+ case _: SparkTable => true
+ case formatTable: PaimonFormatTable =>
+
PaimonFormatTablePartitionDdlExec.usesCatalogManagedPartitions(formatTable)
Review Comment:
Why the different treatment? What’s the difference between the file system
and the metadata?
--
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]