|
7 | 7 |
|
8 | 8 | package org.elasticsearch.xpack.esql.analysis; |
9 | 9 |
|
| 10 | +import org.elasticsearch.index.IndexMode; |
10 | 11 | import org.elasticsearch.test.ESTestCase; |
| 12 | +import org.elasticsearch.xpack.esql.EsqlTestUtils; |
| 13 | +import org.elasticsearch.xpack.esql.core.tree.Source; |
| 14 | +import org.elasticsearch.xpack.esql.core.type.DataType; |
| 15 | +import org.elasticsearch.xpack.esql.core.type.EsField; |
| 16 | +import org.elasticsearch.xpack.esql.expression.function.EsqlFunctionRegistry; |
| 17 | +import org.elasticsearch.xpack.esql.expression.predicate.nulls.IsNotNull; |
| 18 | +import org.elasticsearch.xpack.esql.index.EsIndex; |
| 19 | +import org.elasticsearch.xpack.esql.index.IndexResolution; |
| 20 | +import org.elasticsearch.xpack.esql.parser.EsqlParser; |
| 21 | +import org.elasticsearch.xpack.esql.plan.logical.Aggregate; |
| 22 | +import org.elasticsearch.xpack.esql.plan.logical.Filter; |
| 23 | +import org.elasticsearch.xpack.esql.plan.logical.Limit; |
| 24 | +import org.elasticsearch.xpack.esql.plan.logical.LogicalPlan; |
11 | 25 |
|
| 26 | +import java.util.Map; |
| 27 | + |
| 28 | +import static org.elasticsearch.xpack.esql.EsqlTestUtils.TEST_VERIFIER; |
| 29 | +import static org.elasticsearch.xpack.esql.EsqlTestUtils.as; |
| 30 | +import static org.elasticsearch.xpack.esql.EsqlTestUtils.emptyInferenceResolution; |
| 31 | +import static org.elasticsearch.xpack.esql.analysis.AnalyzerTestUtils.defaultLookupResolution; |
| 32 | + |
| 33 | +/** |
| 34 | + * Tests desi |
| 35 | + */ |
12 | 36 | public class IgnoreNullMetricsTests extends ESTestCase { |
13 | 37 |
|
| 38 | + private Analyzer analyzer; |
| 39 | + |
| 40 | + private LogicalPlan analyze(String query) { |
| 41 | + EsqlParser parser = new EsqlParser(); |
| 42 | + EnrichResolution enrichResolution = new EnrichResolution(); |
| 43 | + AnalyzerTestUtils.loadEnrichPolicyResolution(enrichResolution, "languages_idx", "id", "languages_idx", "mapping-languages.json"); |
| 44 | + |
| 45 | + Map<String, EsField> mapping = Map.of( |
| 46 | + "dimension_1", |
| 47 | + new EsField("dimension_1", DataType.KEYWORD, Map.of(), true, EsField.TimeSeriesFieldType.DIMENSION), |
| 48 | + "metric_1", |
| 49 | + new EsField("metric_1", DataType.LONG, Map.of(), true, EsField.TimeSeriesFieldType.METRIC) |
| 50 | + ); |
| 51 | + EsIndex test = new EsIndex("test", mapping, Map.of("test", IndexMode.TIME_SERIES)); |
| 52 | + IndexResolution getIndexResult = IndexResolution.valid(test); |
| 53 | + analyzer = new Analyzer( |
| 54 | + new AnalyzerContext( |
| 55 | + EsqlTestUtils.TEST_CFG, |
| 56 | + new EsqlFunctionRegistry(), |
| 57 | + getIndexResult, |
| 58 | + defaultLookupResolution(), |
| 59 | + enrichResolution, |
| 60 | + emptyInferenceResolution() |
| 61 | + ), |
| 62 | + TEST_VERIFIER |
| 63 | + ); |
| 64 | + |
| 65 | + return analyzer.analyze(parser.createStatement(query, EsqlTestUtils.TEST_CFG)); |
| 66 | + } |
| 67 | + |
| 68 | + public void testSimple() { |
| 69 | + LogicalPlan actual = analyze(""" |
| 70 | + TS test |
| 71 | + | STATS max(max_over_time(metric_1)) |
| 72 | + """); |
| 73 | + Limit limit = as(actual, Limit.class); |
| 74 | + Aggregate agg = as(limit.child(), Aggregate.class); |
| 75 | + Filter filter = as(agg.child(), Filter.class); |
| 76 | + IsNotNull condition = as(filter.condition(), IsNotNull.class); |
| 77 | + |
| 78 | + } |
14 | 79 | } |
0 commit comments