beliefer commented on PR #46573:
URL: https://github.com/apache/spark/pull/46573#issuecomment-2111937434
For example:
```
private def canEliminateGlobalSort(plan: LogicalPlan): Boolean = plan
match {
case r: RepartitionByExpression =>
r.partitionExpressions.forall(_.deterministic)
case r: RebalancePartitions =>
r.partitionExpressions.forall(_.deterministic)
case _: Repartition => true
case _ => false
}
```
```
protected def userSpecifiedRepartition(p: LogicalPlan): Boolean = p match {
case _: Repartition => true
case r: RepartitionByExpression
if r.optNumPartitions.isDefined || r.partitionExpressions.nonEmpty =>
true
case _ => false
}
```
```
case r: logical.RepartitionByExpression =>
val shuffleOrigin = if (r.partitionExpressions.isEmpty &&
r.optNumPartitions.isEmpty) {
REBALANCE_PARTITIONS_BY_NONE
} else if (r.optNumPartitions.isEmpty) {
REPARTITION_BY_COL
} else {
REPARTITION_BY_NUM
}
exchange.ShuffleExchangeExec(
r.partitioning, planLater(r.child),
shuffleOrigin, r.optAdvisoryPartitionSize) :: Nil
case r @ logical.Repartition(numPartitions, shuffle, child) =>
if (shuffle) {
ShuffleExchangeExec(r.partitioning, planLater(child),
REPARTITION_BY_NUM) :: Nil
} else {
execution.CoalesceExec(numPartitions, planLater(child)) :: Nil
}
```
--
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]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]