[HUDI-4042] Support truncate-partition for Spark-3.2 (#5506)
This commit is contained in:
@@ -179,21 +179,22 @@ case class HoodieSpark3ResolveReferences(sparkSession: SparkSession) extends Rul
|
|||||||
case class HoodieSpark3PostAnalysisRule(sparkSession: SparkSession) extends Rule[LogicalPlan] {
|
case class HoodieSpark3PostAnalysisRule(sparkSession: SparkSession) extends Rule[LogicalPlan] {
|
||||||
override def apply(plan: LogicalPlan): LogicalPlan = {
|
override def apply(plan: LogicalPlan): LogicalPlan = {
|
||||||
plan match {
|
plan match {
|
||||||
case ShowPartitions(child, specOpt, _)
|
case ShowPartitions(ResolvedTable(_, idt, _: HoodieInternalV2Table, _), specOpt, _) =>
|
||||||
if child.isInstanceOf[ResolvedTable] &&
|
ShowHoodieTablePartitionsCommand(
|
||||||
child.asInstanceOf[ResolvedTable].table.isInstanceOf[HoodieInternalV2Table] =>
|
idt.asTableIdentifier, specOpt.map(s => s.asInstanceOf[UnresolvedPartitionSpec].spec))
|
||||||
ShowHoodieTablePartitionsCommand(child.asInstanceOf[ResolvedTable].identifier.asTableIdentifier, specOpt.map(s => s.asInstanceOf[UnresolvedPartitionSpec].spec))
|
|
||||||
|
|
||||||
// Rewrite TruncateTableCommand to TruncateHoodieTableCommand
|
// Rewrite TruncateTableCommand to TruncateHoodieTableCommand
|
||||||
case TruncateTable(child)
|
case TruncateTable(ResolvedTable(_, idt, _: HoodieInternalV2Table, _)) =>
|
||||||
if child.isInstanceOf[ResolvedTable] &&
|
TruncateHoodieTableCommand(idt.asTableIdentifier, None)
|
||||||
child.asInstanceOf[ResolvedTable].table.isInstanceOf[HoodieInternalV2Table] =>
|
|
||||||
new TruncateHoodieTableCommand(child.asInstanceOf[ResolvedTable].identifier.asTableIdentifier, None)
|
|
||||||
|
|
||||||
case DropPartitions(child, specs, ifExists, purge)
|
case TruncatePartition(
|
||||||
if child.resolved && child.isInstanceOf[ResolvedTable] && child.asInstanceOf[ResolvedTable].table.isInstanceOf[HoodieInternalV2Table] =>
|
ResolvedTable(_, idt, _: HoodieInternalV2Table, _),
|
||||||
|
partitionSpec: UnresolvedPartitionSpec) =>
|
||||||
|
TruncateHoodieTableCommand(idt.asTableIdentifier, Some(partitionSpec.spec))
|
||||||
|
|
||||||
|
case DropPartitions(ResolvedTable(_, idt, _: HoodieInternalV2Table, _), specs, ifExists, purge) =>
|
||||||
AlterHoodieTableDropPartitionCommand(
|
AlterHoodieTableDropPartitionCommand(
|
||||||
child.asInstanceOf[ResolvedTable].identifier.asTableIdentifier,
|
idt.asTableIdentifier,
|
||||||
specs.seq.map(f => f.asInstanceOf[UnresolvedPartitionSpec]).map(s => s.spec),
|
specs.seq.map(f => f.asInstanceOf[UnresolvedPartitionSpec]).map(s => s.spec),
|
||||||
ifExists,
|
ifExists,
|
||||||
purge,
|
purge,
|
||||||
|
|||||||
Reference in New Issue
Block a user