|
7 | 7 |
|
8 | 8 | package org.elasticsearch.xpack.esql.optimizer; |
9 | 9 |
|
10 | | -import org.apache.lucene.util.BytesRef; |
11 | | -import org.elasticsearch.Build; |
12 | | -import org.elasticsearch.common.logging.LoggerMessageFormat; |
13 | | -import org.elasticsearch.common.lucene.BytesRefs; |
14 | | -import org.elasticsearch.compute.aggregation.QuantileStates; |
15 | | -import org.elasticsearch.compute.data.Block; |
16 | | -import org.elasticsearch.compute.data.LongVectorBlock; |
17 | | -import org.elasticsearch.compute.test.TestBlockFactory; |
18 | | -import org.elasticsearch.core.Tuple; |
19 | | -import org.elasticsearch.dissect.DissectParser; |
20 | 10 | import org.elasticsearch.index.IndexMode; |
21 | 11 | import org.elasticsearch.test.ESTestCase; |
22 | 12 | import org.elasticsearch.xpack.esql.EsqlTestUtils; |
23 | | -import org.elasticsearch.xpack.esql.VerificationException; |
24 | | -import org.elasticsearch.xpack.esql.action.EsqlCapabilities; |
25 | 13 | import org.elasticsearch.xpack.esql.analysis.Analyzer; |
26 | 14 | import org.elasticsearch.xpack.esql.analysis.AnalyzerContext; |
27 | 15 | import org.elasticsearch.xpack.esql.analysis.AnalyzerTestUtils; |
28 | 16 | import org.elasticsearch.xpack.esql.analysis.EnrichResolution; |
29 | | -import org.elasticsearch.xpack.esql.common.Failures; |
30 | | -import org.elasticsearch.xpack.esql.core.expression.Alias; |
31 | | -import org.elasticsearch.xpack.esql.core.expression.Attribute; |
32 | | -import org.elasticsearch.xpack.esql.core.expression.AttributeSet; |
33 | | -import org.elasticsearch.xpack.esql.core.expression.EntryExpression; |
34 | | -import org.elasticsearch.xpack.esql.core.expression.Expression; |
35 | | -import org.elasticsearch.xpack.esql.core.expression.Expressions; |
36 | | -import org.elasticsearch.xpack.esql.core.expression.FieldAttribute; |
37 | | -import org.elasticsearch.xpack.esql.core.expression.FoldContext; |
38 | | -import org.elasticsearch.xpack.esql.core.expression.Literal; |
39 | | -import org.elasticsearch.xpack.esql.core.expression.MapExpression; |
40 | | -import org.elasticsearch.xpack.esql.core.expression.NamedExpression; |
41 | | -import org.elasticsearch.xpack.esql.core.expression.Nullability; |
42 | | -import org.elasticsearch.xpack.esql.core.expression.ReferenceAttribute; |
43 | | -import org.elasticsearch.xpack.esql.core.expression.UnresolvedAttribute; |
44 | | -import org.elasticsearch.xpack.esql.core.expression.predicate.operator.comparison.BinaryComparison; |
45 | | -import org.elasticsearch.xpack.esql.core.tree.Source; |
46 | | -import org.elasticsearch.xpack.esql.core.type.DataType; |
47 | 17 | import org.elasticsearch.xpack.esql.core.type.EsField; |
48 | | -import org.elasticsearch.xpack.esql.core.type.PotentiallyUnmappedKeywordEsField; |
49 | | -import org.elasticsearch.xpack.esql.core.util.Holder; |
50 | | -import org.elasticsearch.xpack.esql.core.util.StringUtils; |
51 | | -import org.elasticsearch.xpack.esql.expression.Order; |
52 | 18 | import org.elasticsearch.xpack.esql.expression.function.EsqlFunctionRegistry; |
53 | | -import org.elasticsearch.xpack.esql.expression.function.aggregate.AggregateFunction; |
54 | | -import org.elasticsearch.xpack.esql.expression.function.aggregate.Count; |
55 | | -import org.elasticsearch.xpack.esql.expression.function.aggregate.FromPartial; |
56 | | -import org.elasticsearch.xpack.esql.expression.function.aggregate.Max; |
57 | | -import org.elasticsearch.xpack.esql.expression.function.aggregate.Min; |
58 | | -import org.elasticsearch.xpack.esql.expression.function.aggregate.Percentile; |
59 | | -import org.elasticsearch.xpack.esql.expression.function.aggregate.Rate; |
60 | | -import org.elasticsearch.xpack.esql.expression.function.aggregate.Sum; |
61 | | -import org.elasticsearch.xpack.esql.expression.function.aggregate.ToPartial; |
62 | | -import org.elasticsearch.xpack.esql.expression.function.aggregate.Values; |
63 | | -import org.elasticsearch.xpack.esql.expression.function.fulltext.Match; |
64 | | -import org.elasticsearch.xpack.esql.expression.function.fulltext.MultiMatch; |
65 | | -import org.elasticsearch.xpack.esql.expression.function.grouping.Bucket; |
66 | | -import org.elasticsearch.xpack.esql.expression.function.grouping.Categorize; |
67 | | -import org.elasticsearch.xpack.esql.expression.function.scalar.convert.ToDouble; |
68 | | -import org.elasticsearch.xpack.esql.expression.function.scalar.convert.ToInteger; |
69 | | -import org.elasticsearch.xpack.esql.expression.function.scalar.convert.ToLong; |
70 | | -import org.elasticsearch.xpack.esql.expression.function.scalar.convert.ToString; |
71 | | -import org.elasticsearch.xpack.esql.expression.function.scalar.math.Round; |
72 | | -import org.elasticsearch.xpack.esql.expression.function.scalar.multivalue.MvAvg; |
73 | | -import org.elasticsearch.xpack.esql.expression.function.scalar.multivalue.MvCount; |
74 | | -import org.elasticsearch.xpack.esql.expression.function.scalar.multivalue.MvDedupe; |
75 | | -import org.elasticsearch.xpack.esql.expression.function.scalar.multivalue.MvMax; |
76 | | -import org.elasticsearch.xpack.esql.expression.function.scalar.multivalue.MvMedian; |
77 | | -import org.elasticsearch.xpack.esql.expression.function.scalar.multivalue.MvMin; |
78 | | -import org.elasticsearch.xpack.esql.expression.function.scalar.multivalue.MvSum; |
79 | | -import org.elasticsearch.xpack.esql.expression.function.scalar.nulls.Coalesce; |
80 | | -import org.elasticsearch.xpack.esql.expression.function.scalar.string.Concat; |
81 | | -import org.elasticsearch.xpack.esql.expression.predicate.logical.And; |
82 | | -import org.elasticsearch.xpack.esql.expression.predicate.logical.Not; |
83 | | -import org.elasticsearch.xpack.esql.expression.predicate.logical.Or; |
84 | | -import org.elasticsearch.xpack.esql.expression.predicate.nulls.IsNotNull; |
85 | | -import org.elasticsearch.xpack.esql.expression.predicate.operator.arithmetic.Add; |
86 | | -import org.elasticsearch.xpack.esql.expression.predicate.operator.arithmetic.Div; |
87 | | -import org.elasticsearch.xpack.esql.expression.predicate.operator.arithmetic.Mod; |
88 | | -import org.elasticsearch.xpack.esql.expression.predicate.operator.arithmetic.Mul; |
89 | | -import org.elasticsearch.xpack.esql.expression.predicate.operator.arithmetic.Neg; |
90 | | -import org.elasticsearch.xpack.esql.expression.predicate.operator.arithmetic.Sub; |
91 | | -import org.elasticsearch.xpack.esql.expression.predicate.operator.comparison.Equals; |
92 | | -import org.elasticsearch.xpack.esql.expression.predicate.operator.comparison.EsqlBinaryComparison; |
93 | | -import org.elasticsearch.xpack.esql.expression.predicate.operator.comparison.GreaterThan; |
94 | | -import org.elasticsearch.xpack.esql.expression.predicate.operator.comparison.In; |
95 | | -import org.elasticsearch.xpack.esql.expression.predicate.operator.comparison.InsensitiveEquals; |
96 | | -import org.elasticsearch.xpack.esql.expression.predicate.operator.comparison.LessThan; |
97 | 19 | import org.elasticsearch.xpack.esql.index.EsIndex; |
98 | 20 | import org.elasticsearch.xpack.esql.index.IndexResolution; |
99 | | -import org.elasticsearch.xpack.esql.optimizer.rules.logical.LiteralsOnTheRight; |
100 | | -import org.elasticsearch.xpack.esql.optimizer.rules.logical.OptimizerRules; |
101 | | -import org.elasticsearch.xpack.esql.optimizer.rules.logical.PruneRedundantOrderBy; |
102 | | -import org.elasticsearch.xpack.esql.optimizer.rules.logical.PushDownAndCombineLimits; |
103 | | -import org.elasticsearch.xpack.esql.optimizer.rules.logical.PushDownCompletion; |
104 | | -import org.elasticsearch.xpack.esql.optimizer.rules.logical.PushDownEnrich; |
105 | | -import org.elasticsearch.xpack.esql.optimizer.rules.logical.PushDownEval; |
106 | | -import org.elasticsearch.xpack.esql.optimizer.rules.logical.PushDownRegexExtract; |
107 | | -import org.elasticsearch.xpack.esql.optimizer.rules.logical.SplitInWithFoldableValue; |
108 | 21 | import org.elasticsearch.xpack.esql.parser.EsqlParser; |
109 | | -import org.elasticsearch.xpack.esql.parser.ParsingException; |
110 | | -import org.elasticsearch.xpack.esql.plan.GeneratingPlan; |
111 | | -import org.elasticsearch.xpack.esql.plan.logical.Aggregate; |
112 | | -import org.elasticsearch.xpack.esql.plan.logical.ChangePoint; |
113 | | -import org.elasticsearch.xpack.esql.plan.logical.Dissect; |
114 | | -import org.elasticsearch.xpack.esql.plan.logical.Enrich; |
115 | | -import org.elasticsearch.xpack.esql.plan.logical.EsRelation; |
116 | | -import org.elasticsearch.xpack.esql.plan.logical.Eval; |
117 | | -import org.elasticsearch.xpack.esql.plan.logical.Filter; |
118 | | -import org.elasticsearch.xpack.esql.plan.logical.Grok; |
119 | | -import org.elasticsearch.xpack.esql.plan.logical.Limit; |
120 | 22 | import org.elasticsearch.xpack.esql.plan.logical.LogicalPlan; |
121 | | -import org.elasticsearch.xpack.esql.plan.logical.MvExpand; |
122 | | -import org.elasticsearch.xpack.esql.plan.logical.OrderBy; |
123 | | -import org.elasticsearch.xpack.esql.plan.logical.Project; |
124 | | -import org.elasticsearch.xpack.esql.plan.logical.Row; |
125 | | -import org.elasticsearch.xpack.esql.plan.logical.Sample; |
126 | | -import org.elasticsearch.xpack.esql.plan.logical.TimeSeriesAggregate; |
127 | | -import org.elasticsearch.xpack.esql.plan.logical.TopN; |
128 | | -import org.elasticsearch.xpack.esql.plan.logical.UnaryPlan; |
129 | | -import org.elasticsearch.xpack.esql.plan.logical.inference.Completion; |
130 | | -import org.elasticsearch.xpack.esql.plan.logical.join.InlineJoin; |
131 | | -import org.elasticsearch.xpack.esql.plan.logical.join.Join; |
132 | | -import org.elasticsearch.xpack.esql.plan.logical.join.JoinConfig; |
133 | | -import org.elasticsearch.xpack.esql.plan.logical.join.JoinTypes; |
134 | | -import org.elasticsearch.xpack.esql.plan.logical.join.LookupJoin; |
135 | | -import org.elasticsearch.xpack.esql.plan.logical.local.EsqlProject; |
136 | | -import org.elasticsearch.xpack.esql.plan.logical.local.LocalRelation; |
137 | | -import org.elasticsearch.xpack.esql.plan.logical.local.LocalSupplier; |
138 | 23 | import org.junit.BeforeClass; |
139 | 24 |
|
140 | | -import java.time.Duration; |
141 | | -import java.util.ArrayList; |
142 | | -import java.util.Arrays; |
143 | 25 | import java.util.List; |
144 | | -import java.util.Locale; |
145 | 26 | import java.util.Map; |
146 | 27 | import java.util.Set; |
147 | | -import java.util.function.BiFunction; |
148 | | -import java.util.function.Function; |
149 | 28 |
|
150 | | -import static java.util.Arrays.asList; |
151 | | -import static java.util.Collections.emptyList; |
152 | 29 | import static java.util.Collections.emptyMap; |
153 | | -import static java.util.Collections.singletonList; |
154 | | -import static org.elasticsearch.test.ListMatcher.matchesList; |
155 | | -import static org.elasticsearch.test.MapMatcher.assertMap; |
156 | | -import static org.elasticsearch.xpack.esql.EsqlTestUtils.L; |
157 | | -import static org.elasticsearch.xpack.esql.EsqlTestUtils.ONE; |
158 | 30 | import static org.elasticsearch.xpack.esql.EsqlTestUtils.TEST_VERIFIER; |
159 | | -import static org.elasticsearch.xpack.esql.EsqlTestUtils.THREE; |
160 | | -import static org.elasticsearch.xpack.esql.EsqlTestUtils.TWO; |
161 | | -import static org.elasticsearch.xpack.esql.EsqlTestUtils.as; |
162 | | -import static org.elasticsearch.xpack.esql.EsqlTestUtils.asLimit; |
163 | 31 | import static org.elasticsearch.xpack.esql.EsqlTestUtils.emptyInferenceResolution; |
164 | | -import static org.elasticsearch.xpack.esql.EsqlTestUtils.emptySource; |
165 | | -import static org.elasticsearch.xpack.esql.EsqlTestUtils.fieldAttribute; |
166 | | -import static org.elasticsearch.xpack.esql.EsqlTestUtils.getFieldAttribute; |
167 | 32 | import static org.elasticsearch.xpack.esql.EsqlTestUtils.loadMapping; |
168 | | -import static org.elasticsearch.xpack.esql.EsqlTestUtils.localSource; |
169 | | -import static org.elasticsearch.xpack.esql.EsqlTestUtils.randomLiteral; |
170 | | -import static org.elasticsearch.xpack.esql.EsqlTestUtils.referenceAttribute; |
171 | | -import static org.elasticsearch.xpack.esql.EsqlTestUtils.singleValue; |
172 | 33 | import static org.elasticsearch.xpack.esql.EsqlTestUtils.unboundLogicalOptimizerContext; |
173 | 34 | import static org.elasticsearch.xpack.esql.EsqlTestUtils.withDefaultLimitWarning; |
174 | | -import static org.elasticsearch.xpack.esql.analysis.Analyzer.NO_FIELDS; |
175 | | -import static org.elasticsearch.xpack.esql.analysis.AnalyzerTestUtils.analyze; |
176 | 35 | import static org.elasticsearch.xpack.esql.analysis.AnalyzerTestUtils.defaultLookupResolution; |
177 | | -import static org.elasticsearch.xpack.esql.core.expression.Literal.NULL; |
178 | | -import static org.elasticsearch.xpack.esql.core.tree.Source.EMPTY; |
179 | | -import static org.elasticsearch.xpack.esql.core.type.DataType.DOUBLE; |
180 | | -import static org.elasticsearch.xpack.esql.core.type.DataType.GEO_POINT; |
181 | | -import static org.elasticsearch.xpack.esql.core.type.DataType.INTEGER; |
182 | 36 | import static org.elasticsearch.xpack.esql.core.type.DataType.KEYWORD; |
183 | | -import static org.elasticsearch.xpack.esql.core.type.DataType.LONG; |
184 | | -import static org.elasticsearch.xpack.esql.core.type.DataType.TEXT; |
185 | | -import static org.elasticsearch.xpack.esql.expression.predicate.operator.comparison.EsqlBinaryComparison.BinaryComparisonOperation.EQ; |
186 | | -import static org.elasticsearch.xpack.esql.expression.predicate.operator.comparison.EsqlBinaryComparison.BinaryComparisonOperation.GT; |
187 | | -import static org.elasticsearch.xpack.esql.expression.predicate.operator.comparison.EsqlBinaryComparison.BinaryComparisonOperation.GTE; |
188 | | -import static org.elasticsearch.xpack.esql.expression.predicate.operator.comparison.EsqlBinaryComparison.BinaryComparisonOperation.LT; |
189 | | -import static org.elasticsearch.xpack.esql.expression.predicate.operator.comparison.EsqlBinaryComparison.BinaryComparisonOperation.LTE; |
190 | | -import static org.hamcrest.Matchers.allOf; |
191 | | -import static org.hamcrest.Matchers.anyOf; |
192 | | -import static org.hamcrest.Matchers.contains; |
193 | | -import static org.hamcrest.Matchers.containsInAnyOrder; |
194 | | -import static org.hamcrest.Matchers.containsString; |
195 | | -import static org.hamcrest.Matchers.empty; |
196 | | -import static org.hamcrest.Matchers.emptyArray; |
197 | | -import static org.hamcrest.Matchers.equalTo; |
198 | | -import static org.hamcrest.Matchers.everyItem; |
199 | | -import static org.hamcrest.Matchers.hasItem; |
200 | | -import static org.hamcrest.Matchers.hasSize; |
201 | | -import static org.hamcrest.Matchers.instanceOf; |
202 | | -import static org.hamcrest.Matchers.is; |
203 | | -import static org.hamcrest.Matchers.not; |
204 | | -import static org.hamcrest.Matchers.nullValue; |
205 | | -import static org.hamcrest.Matchers.startsWith; |
206 | 37 |
|
207 | 38 | //@TestLogging(value = "org.elasticsearch.xpack.esql:TRACE", reason = "debug") |
208 | 39 | public abstract class AbstractLogicalPlanOptimizerTests extends ESTestCase { |
|
0 commit comments