Skip to content

Commit

Permalink
[ESQL] move optimizer rules to a package (elastic#109408)
Browse files Browse the repository at this point in the history
This moves (most of) the Optimizer Rules from being public static sub-classes of OptimizerRules to being public top level classes in the optimizer.rules package. The main benefit of this is to reduce git conflicts when touching rules, since they will no longer be all in the same file. It also improves readability, as short files are easier to read in general.

I would like to move the tests for these rules into class-specific test files, but there's some more general test refactoring that I'd like to get done first, so that'll be in a follow-up PR.

---------

Co-authored-by: Elastic Machine <[email protected]>
  • Loading branch information
not-napoleon and elasticmachine authored Jun 10, 2024
1 parent eedc2b9 commit bf19072
Show file tree
Hide file tree
Showing 6 changed files with 540 additions and 496 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,11 @@
import org.elasticsearch.xpack.esql.expression.function.scalar.spatial.SpatialRelatesFunction;
import org.elasticsearch.xpack.esql.expression.predicate.operator.comparison.Equals;
import org.elasticsearch.xpack.esql.expression.predicate.operator.comparison.In;
import org.elasticsearch.xpack.esql.optimizer.rules.BooleanFunctionEqualsElimination;
import org.elasticsearch.xpack.esql.optimizer.rules.CombineDisjunctionsToIn;
import org.elasticsearch.xpack.esql.optimizer.rules.ConstantFolding;
import org.elasticsearch.xpack.esql.optimizer.rules.LiteralsOnTheRight;
import org.elasticsearch.xpack.esql.optimizer.rules.PropagateEquals;
import org.elasticsearch.xpack.esql.optimizer.rules.PruneLiteralsInOrderBy;
import org.elasticsearch.xpack.esql.optimizer.rules.SetAsOptimized;
import org.elasticsearch.xpack.esql.optimizer.rules.SimplifyComparisonsArithmetics;
Expand Down Expand Up @@ -159,10 +162,10 @@ protected static Batch<LogicalPlan> operators() {
new BooleanSimplification(),
new LiteralsOnTheRight(),
// needs to occur before BinaryComparison combinations (see class)
new org.elasticsearch.xpack.esql.optimizer.OptimizerRules.PropagateEquals(),
new PropagateEquals(),
new PropagateNullable(),
new org.elasticsearch.xpack.esql.optimizer.OptimizerRules.BooleanFunctionEqualsElimination(),
new org.elasticsearch.xpack.esql.optimizer.OptimizerRules.CombineDisjunctionsToIn(),
new BooleanFunctionEqualsElimination(),
new CombineDisjunctionsToIn(),
new SimplifyComparisonsArithmetics(EsqlDataTypes::areCompatible),
// prune/elimination
new PruneFilters(),
Expand Down
Loading

0 comments on commit bf19072

Please sign in to comment.