Github user jzhuge commented on a diff in the pull request:
https://github.com/apache/spark/pull/21911#discussion_r207638866
--- Diff:
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/ResolveHints.scala
---
@@ -102,6 +104,38 @@ object ResolveHints {
}
}
+ /**
+ * COALESCE Hint accepts name "COALESCE" and "REPARTITION".
+ * Its parameter includes a partition number.
+ */
+ class ResolveCoalesceHints(conf: SQLConf) extends Rule[LogicalPlan] {
+ private val COALESCE_HINT_NAMES = Set("COALESCE", "REPARTITION")
+
+ private def applyCoalesceHint(
+ plan: LogicalPlan,
+ numPartitions: Int,
+ shuffle: Boolean): LogicalPlan = {
+ Repartition(numPartitions, shuffle, plan)
+ }
+
+ def apply(plan: LogicalPlan): LogicalPlan = plan.resolveOperators {
+ case h: UnresolvedHint if
COALESCE_HINT_NAMES.contains(h.name.toUpperCase(Locale.ROOT)) =>
+ val hintName = h.name.toUpperCase(Locale.ROOT)
+ val shuffle = hintName match {
+ case "REPARTITION" => true
+ case "COALESCE" => false
+ }
+ h.parameters match {
--- End diff --
Ah I see. Thanks.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]