Skip to content

Commit

Permalink
Refactor apply method in InsertMapSortInRepartitionExpressions
Browse files Browse the repository at this point in the history
  • Loading branch information
ostronaut committed Jan 7, 2025
1 parent 75e323b commit 20c76e4
Showing 1 changed file with 3 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -89,21 +89,18 @@ object InsertMapSortInRepartitionExpressions extends Rule[LogicalPlan] {

override def apply(plan: LogicalPlan): LogicalPlan = {
plan.transformUpWithPruning(_.containsPattern(REPARTITION_OPERATION)) {
case rep @
RepartitionByExpression(partitionExprs, child, optNumPartitions, optAdvisoryPartitionSize)
case rep: RepartitionByExpression
if rep.partitionExpressions.exists(mapTypeExistsRecursively) =>
val exprToMapSort = new mutable.HashMap[Expression, Expression]
val newPartitionExprs = partitionExprs.map { expr =>
val newPartitionExprs = rep.partitionExpressions.map { expr =>
val inserted = insertMapSortRecursively(expr)
if (expr.ne(inserted)) {
exprToMapSort.getOrElseUpdate(expr.canonicalized, inserted)
} else {
expr
}
}
RepartitionByExpression(
newPartitionExprs, child, optNumPartitions, optAdvisoryPartitionSize
)
rep.copy(partitionExpressions = newPartitionExprs)
}
}
}
Expand Down

0 comments on commit 20c76e4

Please sign in to comment.