Github user kiszk commented on a diff in the pull request:
https://github.com/apache/spark/pull/23206#discussion_r238776051
--- Diff:
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/optimizer/Optimizer.scala
---
@@ -235,10 +235,127 @@ abstract class Optimizer(sessionCatalog:
SessionCatalog)
*/
def extendedOperatorOptimizationRules: Seq[Rule[LogicalPlan]] = Nil
+ /**
+ * Seq of Optimizer rule to be added after or before a rule in a
specific batch
+ */
+ def optimizerRulesInOrder: Seq[RuleInOrder] = Nil
+
+ /**
+ * Batches to add to the optimizer in a specific order with respect to a
existing batch
+ * Seq of Tuple(existing batch name, order, Batch to add).
+ */
+ def optimizerBatches: Seq[(String, Order.Value, Batch)] = Nil
+
+ /**
+ * Return the batch after removing rules that need to be excluded
+ */
+ private def handleExcludedRules(batch: Batch, excludedRules:
Seq[String]): Seq[Batch] = {
+ // Excluded rules
+ val filteredRules = batch.rules.filter { rule =>
+ val exclude = excludedRules.contains(rule.ruleName)
+ if (exclude) {
+ logInfo(s"Optimization rule '${rule.ruleName}' is excluded from
the optimizer.")
+ }
+ !exclude
+ }
+ if (batch.rules == filteredRules) {
+ Seq(batch)
+ } else if (filteredRules.nonEmpty) {
+ Seq(Batch(batch.name, batch.strategy, filteredRules: _*))
+ } else {
+ logInfo(s"Optimization batch '${batch.name}' is excluded from the
optimizer " +
+ s"as all enclosed rules have been excluded.")
+ Seq.empty
+ }
+ }
+
+ /**
+ * Add the customized rules and batch in order to the optimizer batches.
+ * excludedRules - rules that will be excluded
--- End diff --
nit: `* @param excludedRules ...`
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]