From 5036b996d76599c8fe9f71ab90290078e2396382 Mon Sep 17 00:00:00 2001 From: Gal Lalouche Date: Thu, 18 Dec 2025 20:46:26 +0200 Subject: [PATCH 01/25] Late materialization golden tests --- x-pack/plugin/esql/build.gradle | 7 +- ...ductionLateMaterializationGoldenTests.java | 37 +++++ .../esql/plan/physical/FragmentExec.java | 2 +- .../xpack/esql/plugin/ComputeService.java | 3 +- .../xpack/esql/plugin/ReductionPlan.java | 3 +- .../xpack/esql/optimizer/GoldenTestCase.java | 120 +++++++++++--- ...LateMaterializationPlannerGoldenTests.java | 154 ++++++++++++++++++ .../physical_optimization.expected | 7 + .../reduction_data.expected | 5 + .../reduction_local_data.expected | 4 + .../reduction_local_node_reduce.expected | 5 + .../reduction_node_reduce.expected | 5 + .../physical_optimization.expected | 8 + .../reduction_data.expected | 6 + .../reduction_local_data.expected | 6 + .../reduction_local_node_reduce.expected | 5 + .../reduction_node_reduce.expected | 5 + .../physical_optimization.expected | 10 ++ .../reduction_data.expected | 9 + .../reduction_local_data.expected | 25 +++ .../reduction_local_node_reduce.expected | 5 + .../reduction_node_reduce.expected | 5 + .../physical_optimization.expected | 7 + .../reduction_data.expected | 5 + .../reduction_local_data.expected | 4 + .../reduction_local_node_reduce.expected | 5 + .../reduction_node_reduce.expected | 5 + .../physical_optimization.expected | 8 + .../testMultipleTopN/reduction_data.expected | 5 + .../reduction_local_data.expected | 4 + .../reduction_local_node_reduce.expected | 5 + .../reduction_node_reduce.expected | 5 + .../physical_optimization.expected | 8 + .../reduction_data.expected | 7 + .../reduction_local_data.expected | 7 + .../reduction_local_node_reduce.expected | 3 + .../reduction_node_reduce.expected | 3 + .../physical_optimization.expected | 7 + .../reduction_data.expected | 5 + .../reduction_local_data.expected | 4 + .../reduction_local_node_reduce.expected | 5 + .../reduction_node_reduce.expected | 5 + .../physical_optimization.expected | 8 + .../reduction_data.expected | 6 + .../reduction_local_data.expected | 17 ++ .../reduction_local_node_reduce.expected | 5 + .../reduction_node_reduce.expected | 5 + .../physical_optimization.expected | 10 ++ .../testTopNThenStats/reduction_data.expected | 5 + .../reduction_local_data.expected | 4 + .../reduction_local_node_reduce.expected | 5 + .../reduction_node_reduce.expected | 5 + .../physical_optimization.expected | 7 + .../reduction_data.expected | 5 + .../reduction_local_data.expected | 4 + .../reduction_local_node_reduce.expected | 5 + .../reduction_node_reduce.expected | 5 + 57 files changed, 613 insertions(+), 26 deletions(-) create mode 100644 x-pack/plugin/esql/src/internalClusterTest/java/org/elasticsearch/xpack/esql/action/EsqlReductionLateMaterializationGoldenTests.java create mode 100644 x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/plugin/LateMaterializationPlannerGoldenTests.java create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testBasicTopNLateMaterialization/physical_optimization.expected create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testBasicTopNLateMaterialization/reduction_data.expected create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testBasicTopNLateMaterialization/reduction_local_data.expected create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testBasicTopNLateMaterialization/reduction_local_node_reduce.expected create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testBasicTopNLateMaterialization/reduction_node_reduce.expected create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testExpressionSortTopN/physical_optimization.expected create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testExpressionSortTopN/reduction_data.expected create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testExpressionSortTopN/reduction_local_data.expected create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testExpressionSortTopN/reduction_local_node_reduce.expected create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testExpressionSortTopN/reduction_node_reduce.expected create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testLookupJoinOnDataNode/physical_optimization.expected create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testLookupJoinOnDataNode/reduction_data.expected create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testLookupJoinOnDataNode/reduction_local_data.expected create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testLookupJoinOnDataNode/reduction_local_node_reduce.expected create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testLookupJoinOnDataNode/reduction_node_reduce.expected create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testMultipleFieldSortTopN/physical_optimization.expected create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testMultipleFieldSortTopN/reduction_data.expected create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testMultipleFieldSortTopN/reduction_local_data.expected create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testMultipleFieldSortTopN/reduction_local_node_reduce.expected create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testMultipleFieldSortTopN/reduction_node_reduce.expected create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testMultipleTopN/physical_optimization.expected create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testMultipleTopN/reduction_data.expected create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testMultipleTopN/reduction_local_data.expected create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testMultipleTopN/reduction_local_node_reduce.expected create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testMultipleTopN/reduction_node_reduce.expected create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testMvExpandBeforeTopN/physical_optimization.expected create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testMvExpandBeforeTopN/reduction_data.expected create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testMvExpandBeforeTopN/reduction_local_data.expected create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testMvExpandBeforeTopN/reduction_local_node_reduce.expected create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testMvExpandBeforeTopN/reduction_node_reduce.expected create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testPushedDownTopN/physical_optimization.expected create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testPushedDownTopN/reduction_data.expected create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testPushedDownTopN/reduction_local_data.expected create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testPushedDownTopN/reduction_local_node_reduce.expected create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testPushedDownTopN/reduction_node_reduce.expected create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testSomeFieldsNeededBeforeLateMaterialization/physical_optimization.expected create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testSomeFieldsNeededBeforeLateMaterialization/reduction_data.expected create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testSomeFieldsNeededBeforeLateMaterialization/reduction_local_data.expected create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testSomeFieldsNeededBeforeLateMaterialization/reduction_local_node_reduce.expected create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testSomeFieldsNeededBeforeLateMaterialization/reduction_node_reduce.expected create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testTopNThenStats/physical_optimization.expected create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testTopNThenStats/reduction_data.expected create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testTopNThenStats/reduction_local_data.expected create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testTopNThenStats/reduction_local_node_reduce.expected create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testTopNThenStats/reduction_node_reduce.expected create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testTopNWithMissingSortField/physical_optimization.expected create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testTopNWithMissingSortField/reduction_data.expected create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testTopNWithMissingSortField/reduction_local_data.expected create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testTopNWithMissingSortField/reduction_local_node_reduce.expected create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testTopNWithMissingSortField/reduction_node_reduce.expected diff --git a/x-pack/plugin/esql/build.gradle b/x-pack/plugin/esql/build.gradle index 620e941e8c4c6..35346969e8f23 100644 --- a/x-pack/plugin/esql/build.gradle +++ b/x-pack/plugin/esql/build.gradle @@ -626,12 +626,13 @@ tasks.named("test").configure { if (System.getProperty("golden.noactual") != null || project.hasProperty("golden.noactual")) { systemProperty "golden.noactual", "true" } - if (System.getProperty("golden.cleanactual") != null || project.hasProperty("golden.cleanactual")) { - systemProperty "golden.cleanactual", "true" - } if (System.getProperty("golden.overwrite") != null || project.hasProperty("golden.overwrite")) { systemProperty "golden.overwrite", "true" } + if (System.getProperty("golden.cleanactual") != null || project.hasProperty("golden.cleanactual")) { + systemProperty "golden.cleanactual", "true" + } + systemProperty "policy.directory", file("${projectDir}").absolutePath systemProperty "java.security.policy", file("${projectDir}/test.policy").absolutePath } diff --git a/x-pack/plugin/esql/src/internalClusterTest/java/org/elasticsearch/xpack/esql/action/EsqlReductionLateMaterializationGoldenTests.java b/x-pack/plugin/esql/src/internalClusterTest/java/org/elasticsearch/xpack/esql/action/EsqlReductionLateMaterializationGoldenTests.java new file mode 100644 index 0000000000000..015676ebb099d --- /dev/null +++ b/x-pack/plugin/esql/src/internalClusterTest/java/org/elasticsearch/xpack/esql/action/EsqlReductionLateMaterializationGoldenTests.java @@ -0,0 +1,37 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. + */ + +package org.elasticsearch.xpack.esql.action; + +import org.elasticsearch.xpack.esql.optimizer.GoldenTestCase; + +import java.util.EnumSet; + +public class EsqlReductionLateMaterializationGoldenTests extends GoldenTestCase { + /* + For instance, I'd like to see the data (and reduce) plans for cases such as: + queries with more than 1 topn + queries that have mv_expand (known problem due to preventing projections from bubbling up) + queries that have lookup joins on the data node + queries that have subsequent reducers that should end up on the coordinator (e.g. topn first, then stats) + queries where some fields need to be extracted before the topn, and others don't + queries where the topn sorts on expressions and/or sorts on more than 1 field + queries where the topn can be pushed down to Lucene in the data node plan, and queries where this isn't possible. + queries where the fields required for the TopN are missing on the data node (interactions with ReplaceFieldWithConstantOrNull can be subtle and only pop up as bugs months later) + */ + + public void testMultipleTopN() throws Exception { + String query = """ + FROM employees + | SORT hire_date + | LIMIT 20 + | SORT salary + | LIMIT 10 + """; + runGoldenTest(query, EnumSet.of(Stage.NODE_REDUCE)); + } +} diff --git a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/plan/physical/FragmentExec.java b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/plan/physical/FragmentExec.java index 35667bdaf00a2..c1a642817fad7 100644 --- a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/plan/physical/FragmentExec.java +++ b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/plan/physical/FragmentExec.java @@ -137,7 +137,7 @@ public String nodeString(NodeStringFormat format) { sb.append(estimatedRowSize); sb.append(", reducer=["); sb.append("], fragment=[<>\n"); - sb.append(fragment.toString()); + sb.append(fragment.toString(format)); sb.append("<>]]"); return sb.toString(); } diff --git a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/plugin/ComputeService.java b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/plugin/ComputeService.java index e5e06f6392ea5..5fd6ccea54f24 100644 --- a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/plugin/ComputeService.java +++ b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/plugin/ComputeService.java @@ -758,7 +758,8 @@ ActionListener addCompletionInfo( }); } - static ReductionPlan reductionPlan( + // public for testing + public static ReductionPlan reductionPlan( PlannerSettings plannerSettings, EsqlFlags flags, Configuration configuration, diff --git a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/plugin/ReductionPlan.java b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/plugin/ReductionPlan.java index 965762d127413..9e7ee12aa3e03 100644 --- a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/plugin/ReductionPlan.java +++ b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/plugin/ReductionPlan.java @@ -10,10 +10,11 @@ import org.elasticsearch.xpack.esql.plan.physical.ExchangeSinkExec; /** + * This class is {@code public} for testing. * @param nodeReducePlan The plan to be executed on the node_reduce driver. This should not contain a * {@link org.elasticsearch.xpack.esql.plan.physical.FragmentExec}, but be a plan "sandwiched" between an {@link ExchangeSinkExec} and an * {@link org.elasticsearch.xpack.esql.plan.physical.ExchangeSourceExec}. * @param dataNodePlan The plan to be executed on the data driver. This may contain a * {@link org.elasticsearch.xpack.esql.plan.physical.FragmentExec}. */ -record ReductionPlan(ExchangeSinkExec nodeReducePlan, ExchangeSinkExec dataNodePlan) {} +public record ReductionPlan(ExchangeSinkExec nodeReducePlan, ExchangeSinkExec dataNodePlan) {} diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/optimizer/GoldenTestCase.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/optimizer/GoldenTestCase.java index b382d2916c095..8a3150f24e877 100644 --- a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/optimizer/GoldenTestCase.java +++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/optimizer/GoldenTestCase.java @@ -31,10 +31,14 @@ import org.elasticsearch.xpack.esql.parser.EsqlParser; import org.elasticsearch.xpack.esql.plan.QueryPlan; import org.elasticsearch.xpack.esql.plan.logical.LogicalPlan; +import org.elasticsearch.xpack.esql.plan.physical.ExchangeExec; +import org.elasticsearch.xpack.esql.plan.physical.ExchangeSinkExec; import org.elasticsearch.xpack.esql.plan.physical.PhysicalPlan; import org.elasticsearch.xpack.esql.planner.PlannerUtils; import org.elasticsearch.xpack.esql.planner.mapper.Mapper; +import org.elasticsearch.xpack.esql.plugin.ComputeService; import org.elasticsearch.xpack.esql.plugin.EsqlFlags; +import org.elasticsearch.xpack.esql.plugin.ReductionPlan; import org.elasticsearch.xpack.esql.session.Configuration; import org.elasticsearch.xpack.esql.session.Versioned; import org.elasticsearch.xpack.esql.stats.SearchStats; @@ -78,6 +82,10 @@ public GoldenTestCase() { } + protected void runGoldenTest(String esqlQuery, EnumSet stages, String... nestedPath) { + runGoldenTest(esqlQuery, stages, EsqlTestUtils.TEST_SEARCH_STATS, nestedPath); + } + protected void runGoldenTest(String esqlQuery, EnumSet stages, SearchStats searchStats, String... nestedPath) { String testName = extractTestName(); new Test(baseFile, testName, nestedPath, esqlQuery, stages, searchStats).doTest(); @@ -185,59 +193,128 @@ private List> doTests() throws IOException { if (stages.contains(Stage.LOGICAL_OPTIMIZATION)) { result.add(Tuple.tuple(Stage.LOGICAL_OPTIMIZATION, verifyOrWrite(logicallyOptimized, Stage.LOGICAL_OPTIMIZATION))); } - if (stages.contains(Stage.PHYSICAL_OPTIMIZATION) || stages.contains(Stage.LOCAL_PHYSICAL_OPTIMIZATION)) { + if (stages.contains(Stage.PHYSICAL_OPTIMIZATION) + || stages.contains(Stage.LOCAL_PHYSICAL_OPTIMIZATION) + || stages.contains(Stage.NODE_REDUCE_OPTIMIZATION) + || stages.contains(Stage.NODE_REDUCE_LOCAL_PHYSICAL_OPTIMIZATION)) { var physicalPlanOptimizer = new PhysicalPlanOptimizer(new PhysicalOptimizerContext(null, null)); PhysicalPlan physicalPlan = physicalPlanOptimizer.optimize(new Mapper().map(new Versioned<>(logicallyOptimized, version))); if (stages.contains(Stage.PHYSICAL_OPTIMIZATION)) { result.add(Tuple.tuple(Stage.PHYSICAL_OPTIMIZATION, verifyOrWrite(physicalPlan, Stage.PHYSICAL_OPTIMIZATION))); } + Configuration conf = analyzer.context().configuration(); if (stages.contains(Stage.LOCAL_PHYSICAL_OPTIMIZATION)) { - Configuration conf = analyzer.context().configuration(); - var localPhysicalPlan = PlannerUtils.localPlan( + TestResult localPhysicalResult = verifyOrWrite(localOptimize(physicalPlan, conf), Stage.LOCAL_PHYSICAL_OPTIMIZATION); + result.add(Tuple.tuple(Stage.LOCAL_PHYSICAL_OPTIMIZATION, localPhysicalResult)); + } + if (stages.contains(Stage.NODE_REDUCE_OPTIMIZATION) || stages.contains(Stage.NODE_REDUCE_LOCAL_PHYSICAL_OPTIMIZATION)) { + ExchangeExec exec = EsqlTestUtils.singleValue(physicalPlan.collect(ExchangeExec.class)); + var sink = new ExchangeSinkExec(exec.source(), exec.output(), false, exec.child()); + var reductionPlan = ComputeService.reductionPlan( EsqlTestUtils.TEST_PLANNER_SETTINGS, new EsqlFlags(false), conf, conf.newFoldContext(), - physicalPlan, - searchStats, + sink, + true, // runNodeLevelReduction + true, // reduceNodeLateMaterialization new PlanTimeProfile() + ); - result.add( - Tuple.tuple(Stage.LOCAL_PHYSICAL_OPTIMIZATION, verifyOrWrite(localPhysicalPlan, Stage.LOCAL_PHYSICAL_OPTIMIZATION)) - ); + if (stages.contains(Stage.NODE_REDUCE_OPTIMIZATION)) { + result.addAll(addDualPlanResult(Stage.NODE_REDUCE_OPTIMIZATION, reductionPlan, "node_reduce", "data")); + } + if (stages.contains(Stage.NODE_REDUCE_LOCAL_PHYSICAL_OPTIMIZATION)) { + var finalizedResult = new ReductionPlan( + localOptimize(reductionPlan.nodeReducePlan(), conf), + localOptimize(reductionPlan.dataNodePlan(), conf) + ); + result.addAll( + addDualPlanResult( + Stage.NODE_REDUCE_LOCAL_PHYSICAL_OPTIMIZATION, + finalizedResult, + "local_node_reduce", + "local_data" + ) + ); + } } } return result; } - enum TestResult { + private enum TestResult { SUCCESS, FAILURE, CREATED } + private List> addDualPlanResult( + Stage stage, + ReductionPlan plan, + String nodeReduceName, + String dataNodeName + ) throws IOException { + var reduceResult = verifyOrWrite(plan.nodeReducePlan(), outputPath("reduction_", nodeReduceName)); + var dataResult = verifyOrWrite(plan.dataNodePlan(), outputPath("reduction_", dataNodeName)); + var result = new ArrayList>(); + if (reduceResult == TestResult.FAILURE || dataResult == TestResult.FAILURE) { + result.add(Tuple.tuple(stage, TestResult.FAILURE)); + } else if (reduceResult == TestResult.CREATED || dataResult == TestResult.CREATED) { + if (reduceResult != dataResult) { + throw new IllegalStateException("Both local reduction and local data plan should be created for a new test"); + } + result.add(Tuple.tuple(stage, TestResult.CREATED)); + } else { + if (reduceResult != TestResult.SUCCESS || dataResult != TestResult.SUCCESS) { + throw new IllegalStateException("Both local reduction and local data plan should be successful at this point"); + } + result.add(Tuple.tuple(stage, TestResult.SUCCESS)); + } + return result; + } + private > TestResult verifyOrWrite(T plan, Stage stage) throws IOException { - var outputPath = outputPath(stage); + return verifyOrWrite(plan, outputPath(stage)); + } + + private > TestResult verifyOrWrite(T plan, Path outputFile) throws IOException { if (System.getProperty("golden.overwrite") != null) { - logger.info("Bulldozing file {}", outputPath); - return createNewOutput(outputPath, plan); + logger.info("Overwriting file {}", outputFile); + return createNewOutput(outputFile, plan); } else { - if (Files.exists(outputPath)) { - return verifyExisting(outputPath, plan); + if (Files.exists(outputFile)) { + return verifyExisting(outputFile, plan); } else { - logger.debug("No output exists for file {}, writing new output", outputPath); - return createNewOutput(outputPath, plan); + logger.debug("No output exists for file {}, writing new output", outputFile); + return createNewOutput(outputFile, plan); } } } private Path outputPath(Stage stage) { + return outputPath("", stage.name().toLowerCase(Locale.ROOT)); + } + + private Path outputPath(String prefix, String suffix) { var paths = new String[nestedPath.length + 2]; paths[0] = testName; System.arraycopy(nestedPath, 0, paths, 1, nestedPath.length); - paths[paths.length - 1] = Strings.format("%s.expected", stage.name().toLowerCase(Locale.ROOT)); + paths[paths.length - 1] = Strings.format("%s%s.expected", prefix, suffix); return PathUtils.get(basePath.toString(), paths); } + + private ExchangeSinkExec localOptimize(PhysicalPlan plan, Configuration conf) { + return (ExchangeSinkExec) PlannerUtils.localPlan( + EsqlTestUtils.TEST_PLANNER_SETTINGS, + new EsqlFlags(false), + conf, + conf.newFoldContext(), + plan, + searchStats, + new PlanTimeProfile() + ); + } } private static Test.TestResult createNewOutput(Path output, QueryPlan plan) throws IOException { @@ -253,9 +330,8 @@ private static String toString(Node plan) { private static final Pattern IDENTIFIER_PATTERN = Pattern.compile("#\\d+"); private static Test.TestResult verifyExisting(Path output, QueryPlan plan) throws IOException { - String read = Files.readString(output); String testString = normalize(toString(plan)); - if (normalize(testString).equals(normalize(read))) { + if (testString.equals(normalize(Files.readString(output)))) { if (System.getProperty("golden.cleanactual") != null) { Path path = actualPath(output); if (Files.exists(path)) { @@ -292,7 +368,11 @@ protected enum Stage { PHYSICAL_OPTIMIZATION, // There's no LOCAL_LOGICAL here since in production we use PlannerUtils.localPlan to produce the local physical plan directly from // non-local physical plan. - LOCAL_PHYSICAL_OPTIMIZATION + LOCAL_PHYSICAL_OPTIMIZATION, + // Both node_reduce stages actually result in *two* plans: one for the node reduce driver and one for the data nodes. + NODE_REDUCE_OPTIMIZATION, + // Perform the local physical optimization on both node reduce and data node plans. + NODE_REDUCE_LOCAL_PHYSICAL_OPTIMIZATION } private static String normalize(String s) { diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/plugin/LateMaterializationPlannerGoldenTests.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/plugin/LateMaterializationPlannerGoldenTests.java new file mode 100644 index 0000000000000..c27e6de78f056 --- /dev/null +++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/plugin/LateMaterializationPlannerGoldenTests.java @@ -0,0 +1,154 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. + */ + +package org.elasticsearch.xpack.esql.plugin; + +import org.elasticsearch.xpack.esql.EsqlTestUtils; +import org.elasticsearch.xpack.esql.core.expression.FieldAttribute; +import org.elasticsearch.xpack.esql.optimizer.GoldenTestCase; + +import java.util.EnumSet; + +public class LateMaterializationPlannerGoldenTests extends GoldenTestCase { + private static final EnumSet STAGES = EnumSet.of( + Stage.PHYSICAL_OPTIMIZATION, + Stage.NODE_REDUCE_OPTIMIZATION, + Stage.NODE_REDUCE_LOCAL_PHYSICAL_OPTIMIZATION + ); + + public void testBasicTopNLateMaterialization() throws Exception { + String query = """ + FROM employees + | keep hire_date, salary, emp_no + | SORT hire_date + | LIMIT 20 + """; + runGoldenTest(query, STAGES, unindexedStats()); + } + + public void testMultipleTopN() throws Exception { + String query = """ + FROM employees + | keep hire_date, salary, emp_no + | SORT hire_date + | LIMIT 20 + | SORT salary + | LIMIT 10 + """; + runGoldenTest(query, STAGES, unindexedStats()); + } + + public void testSomeFieldsNeededBeforeLateMaterialization() throws Exception { + String query = """ + FROM employees + | keep hire_date, salary, emp_no + | WHERE salary > 10000 + | SORT hire_date + | LIMIT 20 + """; + runGoldenTest(query, STAGES, unindexedStats()); + } + + public void testMultipleFieldSortTopN() throws Exception { + String query = """ + FROM employees + | keep hire_date, emp_no, height + | SORT hire_date, height + | LIMIT 20 + """; + runGoldenTest(query, STAGES, unindexedStats()); + } + + public void testExpressionSortTopN() throws Exception { + String query = """ + FROM employees + | keep hire_date, height + | SORT sin(height) * 2 + | LIMIT 20 + """; + runGoldenTest(query, STAGES, unindexedStats()); + } + + public void testPushedDownTopN() throws Exception { + String query = """ + FROM employees + | keep emp_no, height + | SORT height + | LIMIT 20 + """; + runGoldenTest(query, STAGES); // default stats are indexed. + } + + public void testTopNWithMissingSortField() throws Exception { + String query = """ + FROM employees + | keep hire_date, salary, emp_no + | SORT hire_date + | LIMIT 20 + """; + runGoldenTest(query, STAGES, missingFieldStats("hire_date")); + } + + public void testLookupJoinOnDataNode() throws Exception { + String query = """ + FROM employees + | EVAL language_code = languages + | LOOKUP JOIN languages_lookup ON language_code + | WHERE emp_no >= 10091 AND emp_no < 10094 + | SORT emp_no + | LIMIT 20 + """; + runGoldenTest(query, STAGES, unindexedStats()); + } + + public void testTopNThenStats() throws Exception { + String query = """ + FROM employees + | keep hire_date, salary, emp_no + | SORT hire_date + | LIMIT 20 + | STATS avg_salary = AVG(salary), count = COUNT(*) + """; + runGoldenTest(query, STAGES, unindexedStats()); + } + + public void testMvExpandBeforeTopN() throws Exception { + String query = """ + FROM employees + | keep emp_no, job_positions, salary + | MV_EXPAND job_positions + | SORT salary + | LIMIT 20 + """; + runGoldenTest(query, STAGES, unindexedStats()); + } + + // Prevents TopN pushdown. + private static EsqlTestUtils.TestSearchStats unindexedStats() { + return new EsqlTestUtils.TestSearchStats() { + @Override + public boolean isIndexed(FieldAttribute.FieldName field) { + return false; + } + }; + } + + // Returns false for exists() for the specified field, simulating a missing field on the data node. + private static EsqlTestUtils.TestSearchStats missingFieldStats(String missingField) { + return new EsqlTestUtils.TestSearchStats() { + @Override + public boolean exists(FieldAttribute.FieldName field) { + return false; + } + + @Override + public boolean isIndexed(FieldAttribute.FieldName field) { + return false; + } + }; + } +} diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testBasicTopNLateMaterialization/physical_optimization.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testBasicTopNLateMaterialization/physical_optimization.expected new file mode 100644 index 0000000000000..cd76be3897e14 --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testBasicTopNLateMaterialization/physical_optimization.expected @@ -0,0 +1,7 @@ +ProjectExec[[hire_date{f}, salary{f}, emp_no{f}]] +\_TopNExec[[Order[hire_date{f},ASC,LAST]],20[INTEGER],null] + \_ExchangeExec[[emp_no{f}, hire_date{f}, salary{f}],false] + \_FragmentExec[filter=null, estimatedRowSize=0, reducer=[], fragment=[<> +Project[[emp_no{f}, hire_date{f}, salary{f}]] +\_TopN[[Order[hire_date{f},ASC,LAST]],20[INTEGER],false] + \_EsRelation[employees][avg_worked_seconds{f}, birth_date{f}, emp_no{f}, first_name{f}, gender{f}, height{f}, height.float{f}, height.half_float{f}, height.scaled_float{f}, hire_date{f}, is_rehired{f}, job_positions{f}, languages{f}, languages.byte{f}, languages.long{f}, languages.short{f}, last_name{f}, salary{f}, salary_change{f}, salary_change.int{f}, salary_change.keyword{f}, salary_change.long{f}, still_hired{f}]<>]] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testBasicTopNLateMaterialization/reduction_data.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testBasicTopNLateMaterialization/reduction_data.expected new file mode 100644 index 0000000000000..42c2f1deccb35 --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testBasicTopNLateMaterialization/reduction_data.expected @@ -0,0 +1,5 @@ +ExchangeSinkExec[[emp_no{f}, hire_date{f}, salary{f}],false] +\_FragmentExec[filter=null, estimatedRowSize=0, reducer=[], fragment=[<> +Project[[_doc{f}, hire_date{f}]] +\_TopN[[Order[hire_date{f},ASC,LAST]],20[INTEGER],false] + \_EsRelation[employees][_doc{f}, avg_worked_seconds{f}, birth_date{f}, emp_no{f}, first_name{f}, gender{f}, height{f}, height.float{f}, height.half_float{f}, height.scaled_float{f}, hire_date{f}, is_rehired{f}, job_positions{f}, languages{f}, languages.byte{f}, languages.long{f}, languages.short{f}, last_name{f}, salary{f}, salary_change{f}, salary_change.int{f}, salary_change.keyword{f}, salary_change.long{f}, still_hired{f}]<>]] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testBasicTopNLateMaterialization/reduction_local_data.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testBasicTopNLateMaterialization/reduction_local_data.expected new file mode 100644 index 0000000000000..79d08e098a4ac --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testBasicTopNLateMaterialization/reduction_local_data.expected @@ -0,0 +1,4 @@ +ExchangeSinkExec[[emp_no{f}, hire_date{f}, salary{f}],false] +\_ProjectExec[[_doc{f}, hire_date{f}]] + \_FieldExtractExec[hire_date{f}]<[],[]> + \_EsQueryExec[employees], indexMode[standard], [_doc{f}], limit[20], sort[[FieldSort[field=hire_date{f}, direction=ASC, nulls=LAST]]] estimatedRowSize[24] queryBuilderAndTags [[QueryBuilderAndTags[query=null, tags=[]]]] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testBasicTopNLateMaterialization/reduction_local_node_reduce.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testBasicTopNLateMaterialization/reduction_local_node_reduce.expected new file mode 100644 index 0000000000000..378271a5e3f37 --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testBasicTopNLateMaterialization/reduction_local_node_reduce.expected @@ -0,0 +1,5 @@ +ExchangeSinkExec[[emp_no{f}, hire_date{f}, salary{f}],false] +\_ProjectExec[[emp_no{f}, hire_date{f}, salary{f}]] + \_FieldExtractExec[emp_no{f}, salary{f}]<[],[]> + \_TopNExec[[Order[hire_date{f},ASC,LAST]],20[INTEGER],36] + \_ExchangeSourceExec[[_doc{f}, hire_date{f}],false] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testBasicTopNLateMaterialization/reduction_node_reduce.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testBasicTopNLateMaterialization/reduction_node_reduce.expected new file mode 100644 index 0000000000000..378271a5e3f37 --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testBasicTopNLateMaterialization/reduction_node_reduce.expected @@ -0,0 +1,5 @@ +ExchangeSinkExec[[emp_no{f}, hire_date{f}, salary{f}],false] +\_ProjectExec[[emp_no{f}, hire_date{f}, salary{f}]] + \_FieldExtractExec[emp_no{f}, salary{f}]<[],[]> + \_TopNExec[[Order[hire_date{f},ASC,LAST]],20[INTEGER],36] + \_ExchangeSourceExec[[_doc{f}, hire_date{f}],false] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testExpressionSortTopN/physical_optimization.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testExpressionSortTopN/physical_optimization.expected new file mode 100644 index 0000000000000..10cc006e32b1b --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testExpressionSortTopN/physical_optimization.expected @@ -0,0 +1,8 @@ +ProjectExec[[hire_date{f}, height{f}]] +\_TopNExec[[Order[$$order_by$0$0{r},ASC,LAST]],20[INTEGER],null] + \_ExchangeExec[[height{f}, hire_date{f}, $$order_by$0$0{r}],false] + \_FragmentExec[filter=null, estimatedRowSize=0, reducer=[], fragment=[<> +Project[[height{f}, hire_date{f}, $$order_by$0$0{r}]] +\_TopN[[Order[$$order_by$0$0{r},ASC,LAST]],20[INTEGER],false] + \_Eval[[SIN(height{f}) * 2[INTEGER] AS $$order_by$0$0]] + \_EsRelation[employees][avg_worked_seconds{f}, birth_date{f}, emp_no{f}, first_name{f}, gender{f}, height{f}, height.float{f}, height.half_float{f}, height.scaled_float{f}, hire_date{f}, is_rehired{f}, job_positions{f}, languages{f}, languages.byte{f}, languages.long{f}, languages.short{f}, last_name{f}, salary{f}, salary_change{f}, salary_change.int{f}, salary_change.keyword{f}, salary_change.long{f}, still_hired{f}]<>]] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testExpressionSortTopN/reduction_data.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testExpressionSortTopN/reduction_data.expected new file mode 100644 index 0000000000000..79ce101ea8de7 --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testExpressionSortTopN/reduction_data.expected @@ -0,0 +1,6 @@ +ExchangeSinkExec[[height{f}, hire_date{f}, $$order_by$0$0{r}],false] +\_FragmentExec[filter=null, estimatedRowSize=0, reducer=[], fragment=[<> +Project[[_doc{f}, height{f}, $$order_by$0$0{r}]] +\_TopN[[Order[$$order_by$0$0{r},ASC,LAST]],20[INTEGER],false] + \_Eval[[SIN(height{f}) * 2[INTEGER] AS $$order_by$0$0]] + \_EsRelation[employees][_doc{f}, avg_worked_seconds{f}, birth_date{f}, emp_no{f}, first_name{f}, gender{f}, height{f}, height.float{f}, height.half_float{f}, height.scaled_float{f}, hire_date{f}, is_rehired{f}, job_positions{f}, languages{f}, languages.byte{f}, languages.long{f}, languages.short{f}, last_name{f}, salary{f}, salary_change{f}, salary_change.int{f}, salary_change.keyword{f}, salary_change.long{f}, still_hired{f}]<>]] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testExpressionSortTopN/reduction_local_data.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testExpressionSortTopN/reduction_local_data.expected new file mode 100644 index 0000000000000..843bf41435308 --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testExpressionSortTopN/reduction_local_data.expected @@ -0,0 +1,6 @@ +ExchangeSinkExec[[height{f}, hire_date{f}, $$order_by$0$0{r}],false] +\_ProjectExec[[_doc{f}, height{f}, $$order_by$0$0{r}]] + \_TopNExec[[Order[$$order_by$0$0{r},ASC,LAST]],20[INTEGER],36] + \_EvalExec[[SIN(height{f}) * 2[INTEGER] AS $$order_by$0$0]] + \_FieldExtractExec[height{f}]<[],[]> + \_EsQueryExec[employees], indexMode[standard], [_doc{f}], limit[], sort[] estimatedRowSize[20] queryBuilderAndTags [[QueryBuilderAndTags[query=null, tags=[]]]] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testExpressionSortTopN/reduction_local_node_reduce.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testExpressionSortTopN/reduction_local_node_reduce.expected new file mode 100644 index 0000000000000..d23a70cf756e6 --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testExpressionSortTopN/reduction_local_node_reduce.expected @@ -0,0 +1,5 @@ +ExchangeSinkExec[[height{f}, hire_date{f}, $$order_by$0$0{r}],false] +\_ProjectExec[[height{f}, hire_date{f}, $$order_by$0$0{r}]] + \_FieldExtractExec[hire_date{f}]<[],[]> + \_TopNExec[[Order[$$order_by$0$0{r},ASC,LAST]],20[INTEGER],44] + \_ExchangeSourceExec[[_doc{f}, height{f}, $$order_by$0$0{r}],false] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testExpressionSortTopN/reduction_node_reduce.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testExpressionSortTopN/reduction_node_reduce.expected new file mode 100644 index 0000000000000..d23a70cf756e6 --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testExpressionSortTopN/reduction_node_reduce.expected @@ -0,0 +1,5 @@ +ExchangeSinkExec[[height{f}, hire_date{f}, $$order_by$0$0{r}],false] +\_ProjectExec[[height{f}, hire_date{f}, $$order_by$0$0{r}]] + \_FieldExtractExec[hire_date{f}]<[],[]> + \_TopNExec[[Order[$$order_by$0$0{r},ASC,LAST]],20[INTEGER],44] + \_ExchangeSourceExec[[_doc{f}, height{f}, $$order_by$0$0{r}],false] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testLookupJoinOnDataNode/physical_optimization.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testLookupJoinOnDataNode/physical_optimization.expected new file mode 100644 index 0000000000000..6de9cdeb68a29 --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testLookupJoinOnDataNode/physical_optimization.expected @@ -0,0 +1,10 @@ +TopNExec[[Order[emp_no{f},ASC,LAST]],20[INTEGER],null] +\_ExchangeExec[[avg_worked_seconds{f}, birth_date{f}, emp_no{f}, first_name{f}, gender{f}, height{f}, height.float{f}, height.half_float{f}, height.scaled_float{f}, hire_date{f}, is_rehired{f}, job_positions{f}, languages{f}, languages.byte{f}, languages.long{f}, languages.short{f}, last_name{f}, salary{f}, salary_change{f}, salary_change.int{f}, salary_change.keyword{f}, salary_change.long{f}, still_hired{f}, language_code{r}, language_name{f}],false] + \_FragmentExec[filter=null, estimatedRowSize=0, reducer=[], fragment=[<> +Project[[avg_worked_seconds{f}, birth_date{f}, emp_no{f}, first_name{f}, gender{f}, height{f}, height.float{f}, height.half_float{f}, height.scaled_float{f}, hire_date{f}, is_rehired{f}, job_positions{f}, languages{f}, languages.byte{f}, languages.long{f}, languages.short{f}, last_name{f}, salary{f}, salary_change{f}, salary_change.int{f}, salary_change.keyword{f}, salary_change.long{f}, still_hired{f}, language_code{r}, language_name{f}]] +\_TopN[[Order[emp_no{f},ASC,LAST]],20[INTEGER],false] + \_Join[LEFT,[language_code{r}],[language_code{f}],null] + |_Eval[[languages{f} AS language_code]] + | \_Filter[emp_no{f} >= 10091[INTEGER] AND emp_no{f} < 10094[INTEGER]] + | \_EsRelation[employees][avg_worked_seconds{f}, birth_date{f}, emp_no{f}, first_name{f}, gender{f}, height{f}, height.float{f}, height.half_float{f}, height.scaled_float{f}, hire_date{f}, is_rehired{f}, job_positions{f}, languages{f}, languages.byte{f}, languages.long{f}, languages.short{f}, last_name{f}, salary{f}, salary_change{f}, salary_change.int{f}, salary_change.keyword{f}, salary_change.long{f}, still_hired{f}] + \_EsRelation[languages_lookup][LOOKUP][language_code{f}, language_name{f}]<>]] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testLookupJoinOnDataNode/reduction_data.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testLookupJoinOnDataNode/reduction_data.expected new file mode 100644 index 0000000000000..ef61e922e587d --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testLookupJoinOnDataNode/reduction_data.expected @@ -0,0 +1,9 @@ +ExchangeSinkExec[[avg_worked_seconds{f}, birth_date{f}, emp_no{f}, first_name{f}, gender{f}, height{f}, height.float{f}, height.half_float{f}, height.scaled_float{f}, hire_date{f}, is_rehired{f}, job_positions{f}, languages{f}, languages.byte{f}, languages.long{f}, languages.short{f}, last_name{f}, salary{f}, salary_change{f}, salary_change.int{f}, salary_change.keyword{f}, salary_change.long{f}, still_hired{f}, language_code{r}, language_name{f}],false] +\_FragmentExec[filter=null, estimatedRowSize=0, reducer=[], fragment=[<> +Project[[_doc{f}, emp_no{f}, languages{f}, language_code{r}, language_name{f}]] +\_TopN[[Order[emp_no{f},ASC,LAST]],20[INTEGER],false] + \_Join[LEFT,[language_code{r}],[language_code{f}],null] + |_Eval[[languages{f} AS language_code]] + | \_Filter[emp_no{f} >= 10091[INTEGER] AND emp_no{f} < 10094[INTEGER]] + | \_EsRelation[employees][_doc{f}, avg_worked_seconds{f}, birth_date{f}, emp_no{f}, first_name{f}, gender{f}, height{f}, height.float{f}, height.half_float{f}, height.scaled_float{f}, hire_date{f}, is_rehired{f}, job_positions{f}, languages{f}, languages.byte{f}, languages.long{f}, languages.short{f}, last_name{f}, salary{f}, salary_change{f}, salary_change.int{f}, salary_change.keyword{f}, salary_change.long{f}, still_hired{f}] + \_EsRelation[languages_lookup][LOOKUP][language_code{f}, language_name{f}]<>]] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testLookupJoinOnDataNode/reduction_local_data.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testLookupJoinOnDataNode/reduction_local_data.expected new file mode 100644 index 0000000000000..afa8bc120313d --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testLookupJoinOnDataNode/reduction_local_data.expected @@ -0,0 +1,25 @@ +ExchangeSinkExec[[avg_worked_seconds{f}, birth_date{f}, emp_no{f}, first_name{f}, gender{f}, height{f}, height.float{f}, height.half_float{f}, height.scaled_float{f}, hire_date{f}, is_rehired{f}, job_positions{f}, languages{f}, languages.byte{f}, languages.long{f}, languages.short{f}, last_name{f}, salary{f}, salary_change{f}, salary_change.int{f}, salary_change.keyword{f}, salary_change.long{f}, still_hired{f}, language_code{r}, language_name{f}],false] +\_ProjectExec[[_doc{f}, emp_no{f}, languages{f}, language_code{r}, language_name{f}]] + \_TopNExec[[Order[emp_no{f},ASC,LAST]],20[INTEGER],82] + \_FieldExtractExec[emp_no{f}]<[],[]> + \_LookupJoinExec[[language_code{r}],[language_code{f}],[language_name{f}],null] + |_EvalExec[[languages{f} AS language_code]] + | \_FieldExtractExec[languages{f}]<[],[]> + | \_EsQueryExec[employees], indexMode[standard], [_doc{f}], limit[], sort[] estimatedRowSize[66] queryBuilderAndTags [[QueryBuilderAndTags[query={ + "esql_single_value" : { + "field" : "emp_no", + "next" : { + "range" : { + "emp_no" : { + "gte" : 10091, + "lt" : 10094, + "time_zone" : "Z", + "boost" : 0.0 + } + } + }, + "source" : "emp_no >= 10091@4:9" + } +}, tags=[]]]] + \_FragmentExec[filter=null, estimatedRowSize=0, reducer=[], fragment=[<> +EsRelation[languages_lookup][LOOKUP][language_code{f}, language_name{f}]<>]] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testLookupJoinOnDataNode/reduction_local_node_reduce.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testLookupJoinOnDataNode/reduction_local_node_reduce.expected new file mode 100644 index 0000000000000..1c739d108e561 --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testLookupJoinOnDataNode/reduction_local_node_reduce.expected @@ -0,0 +1,5 @@ +ExchangeSinkExec[[avg_worked_seconds{f}, birth_date{f}, emp_no{f}, first_name{f}, gender{f}, height{f}, height.float{f}, height.half_float{f}, height.scaled_float{f}, hire_date{f}, is_rehired{f}, job_positions{f}, languages{f}, languages.byte{f}, languages.long{f}, languages.short{f}, last_name{f}, salary{f}, salary_change{f}, salary_change.int{f}, salary_change.keyword{f}, salary_change.long{f}, still_hired{f}, language_code{r}, language_name{f}],false] +\_ProjectExec[[avg_worked_seconds{f}, birth_date{f}, emp_no{f}, first_name{f}, gender{f}, height{f}, height.float{f}, height.half_float{f}, height.scaled_float{f}, hire_date{f}, is_rehired{f}, job_positions{f}, languages{f}, languages.byte{f}, languages.long{f}, languages.short{f}, last_name{f}, salary{f}, salary_change{f}, salary_change.int{f}, salary_change.keyword{f}, salary_change.long{f}, still_hired{f}, language_code{r}, language_name{f}]] + \_FieldExtractExec[avg_worked_seconds{f}, birth_date{f}, first_name{f}, gender{f}, height{f}, height.float{f}, height.half_float{f}, height.scaled_float{f}, hire_date{f}, is_rehired{f}, job_positions{f}, languages.byte{f}, languages.long{f}, languages.short{f}, last_name{f}, salary{f}, salary_change{f}, salary_change.int{f}, salary_change.keyword{f}, salary_change.long{f}, still_hired{f}]<[],[]> + \_TopNExec[[Order[emp_no{f},ASC,LAST]],20[INTEGER],430] + \_ExchangeSourceExec[[_doc{f}, emp_no{f}, languages{f}, language_code{r}, language_name{f}],false] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testLookupJoinOnDataNode/reduction_node_reduce.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testLookupJoinOnDataNode/reduction_node_reduce.expected new file mode 100644 index 0000000000000..1c739d108e561 --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testLookupJoinOnDataNode/reduction_node_reduce.expected @@ -0,0 +1,5 @@ +ExchangeSinkExec[[avg_worked_seconds{f}, birth_date{f}, emp_no{f}, first_name{f}, gender{f}, height{f}, height.float{f}, height.half_float{f}, height.scaled_float{f}, hire_date{f}, is_rehired{f}, job_positions{f}, languages{f}, languages.byte{f}, languages.long{f}, languages.short{f}, last_name{f}, salary{f}, salary_change{f}, salary_change.int{f}, salary_change.keyword{f}, salary_change.long{f}, still_hired{f}, language_code{r}, language_name{f}],false] +\_ProjectExec[[avg_worked_seconds{f}, birth_date{f}, emp_no{f}, first_name{f}, gender{f}, height{f}, height.float{f}, height.half_float{f}, height.scaled_float{f}, hire_date{f}, is_rehired{f}, job_positions{f}, languages{f}, languages.byte{f}, languages.long{f}, languages.short{f}, last_name{f}, salary{f}, salary_change{f}, salary_change.int{f}, salary_change.keyword{f}, salary_change.long{f}, still_hired{f}, language_code{r}, language_name{f}]] + \_FieldExtractExec[avg_worked_seconds{f}, birth_date{f}, first_name{f}, gender{f}, height{f}, height.float{f}, height.half_float{f}, height.scaled_float{f}, hire_date{f}, is_rehired{f}, job_positions{f}, languages.byte{f}, languages.long{f}, languages.short{f}, last_name{f}, salary{f}, salary_change{f}, salary_change.int{f}, salary_change.keyword{f}, salary_change.long{f}, still_hired{f}]<[],[]> + \_TopNExec[[Order[emp_no{f},ASC,LAST]],20[INTEGER],430] + \_ExchangeSourceExec[[_doc{f}, emp_no{f}, languages{f}, language_code{r}, language_name{f}],false] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testMultipleFieldSortTopN/physical_optimization.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testMultipleFieldSortTopN/physical_optimization.expected new file mode 100644 index 0000000000000..01e434d142dbc --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testMultipleFieldSortTopN/physical_optimization.expected @@ -0,0 +1,7 @@ +ProjectExec[[hire_date{f}, emp_no{f}, height{f}]] +\_TopNExec[[Order[hire_date{f},ASC,LAST], Order[height{f},ASC,LAST]],20[INTEGER],null] + \_ExchangeExec[[emp_no{f}, height{f}, hire_date{f}],false] + \_FragmentExec[filter=null, estimatedRowSize=0, reducer=[], fragment=[<> +Project[[emp_no{f}, height{f}, hire_date{f}]] +\_TopN[[Order[hire_date{f},ASC,LAST], Order[height{f},ASC,LAST]],20[INTEGER],false] + \_EsRelation[employees][avg_worked_seconds{f}, birth_date{f}, emp_no{f}, first_name{f}, gender{f}, height{f}, height.float{f}, height.half_float{f}, height.scaled_float{f}, hire_date{f}, is_rehired{f}, job_positions{f}, languages{f}, languages.byte{f}, languages.long{f}, languages.short{f}, last_name{f}, salary{f}, salary_change{f}, salary_change.int{f}, salary_change.keyword{f}, salary_change.long{f}, still_hired{f}]<>]] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testMultipleFieldSortTopN/reduction_data.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testMultipleFieldSortTopN/reduction_data.expected new file mode 100644 index 0000000000000..8ab7e96ac70e1 --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testMultipleFieldSortTopN/reduction_data.expected @@ -0,0 +1,5 @@ +ExchangeSinkExec[[emp_no{f}, height{f}, hire_date{f}],false] +\_FragmentExec[filter=null, estimatedRowSize=0, reducer=[], fragment=[<> +Project[[_doc{f}, hire_date{f}, height{f}]] +\_TopN[[Order[hire_date{f},ASC,LAST], Order[height{f},ASC,LAST]],20[INTEGER],false] + \_EsRelation[employees][_doc{f}, avg_worked_seconds{f}, birth_date{f}, emp_no{f}, first_name{f}, gender{f}, height{f}, height.float{f}, height.half_float{f}, height.scaled_float{f}, hire_date{f}, is_rehired{f}, job_positions{f}, languages{f}, languages.byte{f}, languages.long{f}, languages.short{f}, last_name{f}, salary{f}, salary_change{f}, salary_change.int{f}, salary_change.keyword{f}, salary_change.long{f}, still_hired{f}]<>]] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testMultipleFieldSortTopN/reduction_local_data.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testMultipleFieldSortTopN/reduction_local_data.expected new file mode 100644 index 0000000000000..4ba472a701132 --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testMultipleFieldSortTopN/reduction_local_data.expected @@ -0,0 +1,4 @@ +ExchangeSinkExec[[emp_no{f}, height{f}, hire_date{f}],false] +\_ProjectExec[[_doc{f}, hire_date{f}, height{f}]] + \_FieldExtractExec[hire_date{f}, height{f}]<[],[]> + \_EsQueryExec[employees], indexMode[standard], [_doc{f}], limit[20], sort[[FieldSort[field=hire_date{f}, direction=ASC, nulls=LAST], FieldSort[field=height{f}, direction=ASC, nulls=LAST]]] estimatedRowSize[32] queryBuilderAndTags [[QueryBuilderAndTags[query=null, tags=[]]]] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testMultipleFieldSortTopN/reduction_local_node_reduce.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testMultipleFieldSortTopN/reduction_local_node_reduce.expected new file mode 100644 index 0000000000000..b4903131e7355 --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testMultipleFieldSortTopN/reduction_local_node_reduce.expected @@ -0,0 +1,5 @@ +ExchangeSinkExec[[emp_no{f}, height{f}, hire_date{f}],false] +\_ProjectExec[[emp_no{f}, height{f}, hire_date{f}]] + \_FieldExtractExec[emp_no{f}]<[],[]> + \_TopNExec[[Order[hire_date{f},ASC,LAST], Order[height{f},ASC,LAST]],20[INTEGER],40] + \_ExchangeSourceExec[[_doc{f}, hire_date{f}, height{f}],false] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testMultipleFieldSortTopN/reduction_node_reduce.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testMultipleFieldSortTopN/reduction_node_reduce.expected new file mode 100644 index 0000000000000..b4903131e7355 --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testMultipleFieldSortTopN/reduction_node_reduce.expected @@ -0,0 +1,5 @@ +ExchangeSinkExec[[emp_no{f}, height{f}, hire_date{f}],false] +\_ProjectExec[[emp_no{f}, height{f}, hire_date{f}]] + \_FieldExtractExec[emp_no{f}]<[],[]> + \_TopNExec[[Order[hire_date{f},ASC,LAST], Order[height{f},ASC,LAST]],20[INTEGER],40] + \_ExchangeSourceExec[[_doc{f}, hire_date{f}, height{f}],false] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testMultipleTopN/physical_optimization.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testMultipleTopN/physical_optimization.expected new file mode 100644 index 0000000000000..f614767fd6b3e --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testMultipleTopN/physical_optimization.expected @@ -0,0 +1,8 @@ +ProjectExec[[hire_date{f}, salary{f}, emp_no{f}]] +\_TopNExec[[Order[salary{f},ASC,LAST]],10[INTEGER],null] + \_TopNExec[[Order[hire_date{f},ASC,LAST]],20[INTEGER],null] + \_ExchangeExec[[emp_no{f}, hire_date{f}, salary{f}],false] + \_FragmentExec[filter=null, estimatedRowSize=0, reducer=[], fragment=[<> +Project[[emp_no{f}, hire_date{f}, salary{f}]] +\_TopN[[Order[hire_date{f},ASC,LAST]],20[INTEGER],false] + \_EsRelation[employees][avg_worked_seconds{f}, birth_date{f}, emp_no{f}, first_name{f}, gender{f}, height{f}, height.float{f}, height.half_float{f}, height.scaled_float{f}, hire_date{f}, is_rehired{f}, job_positions{f}, languages{f}, languages.byte{f}, languages.long{f}, languages.short{f}, last_name{f}, salary{f}, salary_change{f}, salary_change.int{f}, salary_change.keyword{f}, salary_change.long{f}, still_hired{f}]<>]] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testMultipleTopN/reduction_data.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testMultipleTopN/reduction_data.expected new file mode 100644 index 0000000000000..42c2f1deccb35 --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testMultipleTopN/reduction_data.expected @@ -0,0 +1,5 @@ +ExchangeSinkExec[[emp_no{f}, hire_date{f}, salary{f}],false] +\_FragmentExec[filter=null, estimatedRowSize=0, reducer=[], fragment=[<> +Project[[_doc{f}, hire_date{f}]] +\_TopN[[Order[hire_date{f},ASC,LAST]],20[INTEGER],false] + \_EsRelation[employees][_doc{f}, avg_worked_seconds{f}, birth_date{f}, emp_no{f}, first_name{f}, gender{f}, height{f}, height.float{f}, height.half_float{f}, height.scaled_float{f}, hire_date{f}, is_rehired{f}, job_positions{f}, languages{f}, languages.byte{f}, languages.long{f}, languages.short{f}, last_name{f}, salary{f}, salary_change{f}, salary_change.int{f}, salary_change.keyword{f}, salary_change.long{f}, still_hired{f}]<>]] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testMultipleTopN/reduction_local_data.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testMultipleTopN/reduction_local_data.expected new file mode 100644 index 0000000000000..79d08e098a4ac --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testMultipleTopN/reduction_local_data.expected @@ -0,0 +1,4 @@ +ExchangeSinkExec[[emp_no{f}, hire_date{f}, salary{f}],false] +\_ProjectExec[[_doc{f}, hire_date{f}]] + \_FieldExtractExec[hire_date{f}]<[],[]> + \_EsQueryExec[employees], indexMode[standard], [_doc{f}], limit[20], sort[[FieldSort[field=hire_date{f}, direction=ASC, nulls=LAST]]] estimatedRowSize[24] queryBuilderAndTags [[QueryBuilderAndTags[query=null, tags=[]]]] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testMultipleTopN/reduction_local_node_reduce.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testMultipleTopN/reduction_local_node_reduce.expected new file mode 100644 index 0000000000000..378271a5e3f37 --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testMultipleTopN/reduction_local_node_reduce.expected @@ -0,0 +1,5 @@ +ExchangeSinkExec[[emp_no{f}, hire_date{f}, salary{f}],false] +\_ProjectExec[[emp_no{f}, hire_date{f}, salary{f}]] + \_FieldExtractExec[emp_no{f}, salary{f}]<[],[]> + \_TopNExec[[Order[hire_date{f},ASC,LAST]],20[INTEGER],36] + \_ExchangeSourceExec[[_doc{f}, hire_date{f}],false] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testMultipleTopN/reduction_node_reduce.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testMultipleTopN/reduction_node_reduce.expected new file mode 100644 index 0000000000000..378271a5e3f37 --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testMultipleTopN/reduction_node_reduce.expected @@ -0,0 +1,5 @@ +ExchangeSinkExec[[emp_no{f}, hire_date{f}, salary{f}],false] +\_ProjectExec[[emp_no{f}, hire_date{f}, salary{f}]] + \_FieldExtractExec[emp_no{f}, salary{f}]<[],[]> + \_TopNExec[[Order[hire_date{f},ASC,LAST]],20[INTEGER],36] + \_ExchangeSourceExec[[_doc{f}, hire_date{f}],false] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testMvExpandBeforeTopN/physical_optimization.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testMvExpandBeforeTopN/physical_optimization.expected new file mode 100644 index 0000000000000..d53c3f7c10b84 --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testMvExpandBeforeTopN/physical_optimization.expected @@ -0,0 +1,8 @@ +TopNExec[[Order[salary{f},ASC,LAST]],20[INTEGER],null] +\_ExchangeExec[[emp_no{f}, job_positions{r}, salary{f}],false] + \_FragmentExec[filter=null, estimatedRowSize=0, reducer=[], fragment=[<> +Project[[emp_no{f}, job_positions{r}, salary{f}]] +\_TopN[[Order[salary{f},ASC,LAST]],20[INTEGER],false] + \_MvExpand[job_positions{f},job_positions{r}] + \_Project[[emp_no{f}, job_positions{f}, salary{f}]] + \_EsRelation[employees][avg_worked_seconds{f}, birth_date{f}, emp_no{f}, first_name{f}, gender{f}, height{f}, height.float{f}, height.half_float{f}, height.scaled_float{f}, hire_date{f}, is_rehired{f}, job_positions{f}, languages{f}, languages.byte{f}, languages.long{f}, languages.short{f}, last_name{f}, salary{f}, salary_change{f}, salary_change.int{f}, salary_change.keyword{f}, salary_change.long{f}, still_hired{f}]<>]] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testMvExpandBeforeTopN/reduction_data.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testMvExpandBeforeTopN/reduction_data.expected new file mode 100644 index 0000000000000..5a4be4cccf576 --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testMvExpandBeforeTopN/reduction_data.expected @@ -0,0 +1,7 @@ +ExchangeSinkExec[[emp_no{f}, job_positions{r}, salary{f}],false] +\_FragmentExec[filter=null, estimatedRowSize=0, reducer=[], fragment=[<> +Project[[emp_no{f}, job_positions{r}, salary{f}]] +\_TopN[[Order[salary{f},ASC,LAST]],20[INTEGER],false] + \_MvExpand[job_positions{f},job_positions{r}] + \_Project[[emp_no{f}, job_positions{f}, salary{f}]] + \_EsRelation[employees][avg_worked_seconds{f}, birth_date{f}, emp_no{f}, first_name{f}, gender{f}, height{f}, height.float{f}, height.half_float{f}, height.scaled_float{f}, hire_date{f}, is_rehired{f}, job_positions{f}, languages{f}, languages.byte{f}, languages.long{f}, languages.short{f}, last_name{f}, salary{f}, salary_change{f}, salary_change.int{f}, salary_change.keyword{f}, salary_change.long{f}, still_hired{f}]<>]] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testMvExpandBeforeTopN/reduction_local_data.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testMvExpandBeforeTopN/reduction_local_data.expected new file mode 100644 index 0000000000000..2f239d653927e --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testMvExpandBeforeTopN/reduction_local_data.expected @@ -0,0 +1,7 @@ +ExchangeSinkExec[[emp_no{f}, job_positions{r}, salary{f}],false] +\_ProjectExec[[emp_no{f}, job_positions{r}, salary{f}]] + \_TopNExec[[Order[salary{f},ASC,LAST]],20[INTEGER],58] + \_MvExpandExec[job_positions{f},job_positions{r}] + \_ProjectExec[[emp_no{f}, job_positions{f}, salary{f}]] + \_FieldExtractExec[emp_no{f}, job_positions{f}, salary{f}]<[],[]> + \_EsQueryExec[employees], indexMode[standard], [_doc{f}], limit[], sort[] estimatedRowSize[62] queryBuilderAndTags [[QueryBuilderAndTags[query=null, tags=[]]]] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testMvExpandBeforeTopN/reduction_local_node_reduce.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testMvExpandBeforeTopN/reduction_local_node_reduce.expected new file mode 100644 index 0000000000000..0c801590c80b7 --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testMvExpandBeforeTopN/reduction_local_node_reduce.expected @@ -0,0 +1,3 @@ +ExchangeSinkExec[[emp_no{f}, job_positions{r}, salary{f}],false] +\_TopNExec[[Order[salary{f},ASC,LAST]],20[INTEGER],58] + \_ExchangeSourceExec[[emp_no{f}, job_positions{r}, salary{f}],false] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testMvExpandBeforeTopN/reduction_node_reduce.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testMvExpandBeforeTopN/reduction_node_reduce.expected new file mode 100644 index 0000000000000..0c801590c80b7 --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testMvExpandBeforeTopN/reduction_node_reduce.expected @@ -0,0 +1,3 @@ +ExchangeSinkExec[[emp_no{f}, job_positions{r}, salary{f}],false] +\_TopNExec[[Order[salary{f},ASC,LAST]],20[INTEGER],58] + \_ExchangeSourceExec[[emp_no{f}, job_positions{r}, salary{f}],false] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testPushedDownTopN/physical_optimization.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testPushedDownTopN/physical_optimization.expected new file mode 100644 index 0000000000000..896efe01a59ec --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testPushedDownTopN/physical_optimization.expected @@ -0,0 +1,7 @@ +ProjectExec[[emp_no{f}, height{f}]] +\_TopNExec[[Order[height{f},ASC,LAST]],20[INTEGER],null] + \_ExchangeExec[[emp_no{f}, height{f}],false] + \_FragmentExec[filter=null, estimatedRowSize=0, reducer=[], fragment=[<> +Project[[emp_no{f}, height{f}]] +\_TopN[[Order[height{f},ASC,LAST]],20[INTEGER],false] + \_EsRelation[employees][avg_worked_seconds{f}, birth_date{f}, emp_no{f}, first_name{f}, gender{f}, height{f}, height.float{f}, height.half_float{f}, height.scaled_float{f}, hire_date{f}, is_rehired{f}, job_positions{f}, languages{f}, languages.byte{f}, languages.long{f}, languages.short{f}, last_name{f}, salary{f}, salary_change{f}, salary_change.int{f}, salary_change.keyword{f}, salary_change.long{f}, still_hired{f}]<>]] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testPushedDownTopN/reduction_data.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testPushedDownTopN/reduction_data.expected new file mode 100644 index 0000000000000..bf2fa9c12991a --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testPushedDownTopN/reduction_data.expected @@ -0,0 +1,5 @@ +ExchangeSinkExec[[emp_no{f}, height{f}],false] +\_FragmentExec[filter=null, estimatedRowSize=0, reducer=[], fragment=[<> +Project[[_doc{f}, height{f}]] +\_TopN[[Order[height{f},ASC,LAST]],20[INTEGER],false] + \_EsRelation[employees][_doc{f}, avg_worked_seconds{f}, birth_date{f}, emp_no{f}, first_name{f}, gender{f}, height{f}, height.float{f}, height.half_float{f}, height.scaled_float{f}, hire_date{f}, is_rehired{f}, job_positions{f}, languages{f}, languages.byte{f}, languages.long{f}, languages.short{f}, last_name{f}, salary{f}, salary_change{f}, salary_change.int{f}, salary_change.keyword{f}, salary_change.long{f}, still_hired{f}]<>]] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testPushedDownTopN/reduction_local_data.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testPushedDownTopN/reduction_local_data.expected new file mode 100644 index 0000000000000..b49e189701890 --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testPushedDownTopN/reduction_local_data.expected @@ -0,0 +1,4 @@ +ExchangeSinkExec[[emp_no{f}, height{f}],false] +\_ProjectExec[[_doc{f}, height{f}]] + \_FieldExtractExec[height{f}]<[],[]> + \_EsQueryExec[employees], indexMode[standard], [_doc{f}], limit[20], sort[[FieldSort[field=height{f}, direction=ASC, nulls=LAST]]] estimatedRowSize[24] queryBuilderAndTags [[QueryBuilderAndTags[query=null, tags=[]]]] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testPushedDownTopN/reduction_local_node_reduce.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testPushedDownTopN/reduction_local_node_reduce.expected new file mode 100644 index 0000000000000..787b72a5c8f72 --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testPushedDownTopN/reduction_local_node_reduce.expected @@ -0,0 +1,5 @@ +ExchangeSinkExec[[emp_no{f}, height{f}],false] +\_ProjectExec[[emp_no{f}, height{f}]] + \_FieldExtractExec[emp_no{f}]<[],[]> + \_TopNExec[[Order[height{f},ASC,LAST]],20[INTEGER],32] + \_ExchangeSourceExec[[_doc{f}, height{f}],false] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testPushedDownTopN/reduction_node_reduce.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testPushedDownTopN/reduction_node_reduce.expected new file mode 100644 index 0000000000000..787b72a5c8f72 --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testPushedDownTopN/reduction_node_reduce.expected @@ -0,0 +1,5 @@ +ExchangeSinkExec[[emp_no{f}, height{f}],false] +\_ProjectExec[[emp_no{f}, height{f}]] + \_FieldExtractExec[emp_no{f}]<[],[]> + \_TopNExec[[Order[height{f},ASC,LAST]],20[INTEGER],32] + \_ExchangeSourceExec[[_doc{f}, height{f}],false] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testSomeFieldsNeededBeforeLateMaterialization/physical_optimization.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testSomeFieldsNeededBeforeLateMaterialization/physical_optimization.expected new file mode 100644 index 0000000000000..f356ac8daa272 --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testSomeFieldsNeededBeforeLateMaterialization/physical_optimization.expected @@ -0,0 +1,8 @@ +ProjectExec[[hire_date{f}, salary{f}, emp_no{f}]] +\_TopNExec[[Order[hire_date{f},ASC,LAST]],20[INTEGER],null] + \_ExchangeExec[[emp_no{f}, hire_date{f}, salary{f}],false] + \_FragmentExec[filter=null, estimatedRowSize=0, reducer=[], fragment=[<> +Project[[emp_no{f}, hire_date{f}, salary{f}]] +\_TopN[[Order[hire_date{f},ASC,LAST]],20[INTEGER],false] + \_Filter[salary{f} > 10000[INTEGER]] + \_EsRelation[employees][avg_worked_seconds{f}, birth_date{f}, emp_no{f}, first_name{f}, gender{f}, height{f}, height.float{f}, height.half_float{f}, height.scaled_float{f}, hire_date{f}, is_rehired{f}, job_positions{f}, languages{f}, languages.byte{f}, languages.long{f}, languages.short{f}, last_name{f}, salary{f}, salary_change{f}, salary_change.int{f}, salary_change.keyword{f}, salary_change.long{f}, still_hired{f}]<>]] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testSomeFieldsNeededBeforeLateMaterialization/reduction_data.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testSomeFieldsNeededBeforeLateMaterialization/reduction_data.expected new file mode 100644 index 0000000000000..041b22266a09e --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testSomeFieldsNeededBeforeLateMaterialization/reduction_data.expected @@ -0,0 +1,6 @@ +ExchangeSinkExec[[emp_no{f}, hire_date{f}, salary{f}],false] +\_FragmentExec[filter=null, estimatedRowSize=0, reducer=[], fragment=[<> +Project[[_doc{f}, salary{f}, hire_date{f}]] +\_TopN[[Order[hire_date{f},ASC,LAST]],20[INTEGER],false] + \_Filter[salary{f} > 10000[INTEGER]] + \_EsRelation[employees][_doc{f}, avg_worked_seconds{f}, birth_date{f}, emp_no{f}, first_name{f}, gender{f}, height{f}, height.float{f}, height.half_float{f}, height.scaled_float{f}, hire_date{f}, is_rehired{f}, job_positions{f}, languages{f}, languages.byte{f}, languages.long{f}, languages.short{f}, last_name{f}, salary{f}, salary_change{f}, salary_change.int{f}, salary_change.keyword{f}, salary_change.long{f}, still_hired{f}]<>]] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testSomeFieldsNeededBeforeLateMaterialization/reduction_local_data.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testSomeFieldsNeededBeforeLateMaterialization/reduction_local_data.expected new file mode 100644 index 0000000000000..7a2b16378c969 --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testSomeFieldsNeededBeforeLateMaterialization/reduction_local_data.expected @@ -0,0 +1,17 @@ +ExchangeSinkExec[[emp_no{f}, hire_date{f}, salary{f}],false] +\_ProjectExec[[_doc{f}, salary{f}, hire_date{f}]] + \_FieldExtractExec[salary{f}, hire_date{f}]<[],[]> + \_EsQueryExec[employees], indexMode[standard], [_doc{f}], limit[20], sort[[FieldSort[field=hire_date{f}, direction=ASC, nulls=LAST]]] estimatedRowSize[28] queryBuilderAndTags [[QueryBuilderAndTags[query={ + "esql_single_value" : { + "field" : "salary", + "next" : { + "range" : { + "salary" : { + "gt" : 10000, + "boost" : 0.0 + } + } + }, + "source" : "salary > 10000@3:9" + } +}, tags=[]]]] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testSomeFieldsNeededBeforeLateMaterialization/reduction_local_node_reduce.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testSomeFieldsNeededBeforeLateMaterialization/reduction_local_node_reduce.expected new file mode 100644 index 0000000000000..23b988ef09a77 --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testSomeFieldsNeededBeforeLateMaterialization/reduction_local_node_reduce.expected @@ -0,0 +1,5 @@ +ExchangeSinkExec[[emp_no{f}, hire_date{f}, salary{f}],false] +\_ProjectExec[[emp_no{f}, hire_date{f}, salary{f}]] + \_FieldExtractExec[emp_no{f}]<[],[]> + \_TopNExec[[Order[hire_date{f},ASC,LAST]],20[INTEGER],36] + \_ExchangeSourceExec[[_doc{f}, salary{f}, hire_date{f}],false] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testSomeFieldsNeededBeforeLateMaterialization/reduction_node_reduce.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testSomeFieldsNeededBeforeLateMaterialization/reduction_node_reduce.expected new file mode 100644 index 0000000000000..23b988ef09a77 --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testSomeFieldsNeededBeforeLateMaterialization/reduction_node_reduce.expected @@ -0,0 +1,5 @@ +ExchangeSinkExec[[emp_no{f}, hire_date{f}, salary{f}],false] +\_ProjectExec[[emp_no{f}, hire_date{f}, salary{f}]] + \_FieldExtractExec[emp_no{f}]<[],[]> + \_TopNExec[[Order[hire_date{f},ASC,LAST]],20[INTEGER],36] + \_ExchangeSourceExec[[_doc{f}, salary{f}, hire_date{f}],false] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testTopNThenStats/physical_optimization.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testTopNThenStats/physical_optimization.expected new file mode 100644 index 0000000000000..861afa9e16c8f --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testTopNThenStats/physical_optimization.expected @@ -0,0 +1,10 @@ +ProjectExec[[avg_salary{r}, count{r}]] +\_EvalExec[[$$SUM$avg_salary$0{r$} / $$COUNT$avg_salary$1{r$} AS avg_salary]] + \_LimitExec[10000[INTEGER],null] + \_AggregateExec[[],[SUM(salary{f},true[BOOLEAN],PT0S[TIME_DURATION],compensated[KEYWORD]) AS $$SUM$avg_salary$0, COUNT(salary{f},true[BOOLEAN],PT0S[TIME_DURATION]) AS $$COUNT$avg_salary$1, COUNT(*[KEYWORD],true[BOOLEAN],PT0S[TIME_DURATION]) AS count],SINGLE,[$$SUM$avg_salary$0$sum{r}, $$SUM$avg_salary$0$seen{r}, $$COUNT$avg_salary$1$count{r}, $$COUNT$avg_salary$1$seen{r}, $$count$count{r}, $$count$seen{r}],null] + \_TopNExec[[Order[hire_date{f},ASC,LAST]],20[INTEGER],null] + \_ExchangeExec[[hire_date{f}, salary{f}],false] + \_FragmentExec[filter=null, estimatedRowSize=0, reducer=[], fragment=[<> +Project[[hire_date{f}, salary{f}]] +\_TopN[[Order[hire_date{f},ASC,LAST]],20[INTEGER],false] + \_EsRelation[employees][avg_worked_seconds{f}, birth_date{f}, emp_no{f}, first_name{f}, gender{f}, height{f}, height.float{f}, height.half_float{f}, height.scaled_float{f}, hire_date{f}, is_rehired{f}, job_positions{f}, languages{f}, languages.byte{f}, languages.long{f}, languages.short{f}, last_name{f}, salary{f}, salary_change{f}, salary_change.int{f}, salary_change.keyword{f}, salary_change.long{f}, still_hired{f}]<>]] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testTopNThenStats/reduction_data.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testTopNThenStats/reduction_data.expected new file mode 100644 index 0000000000000..5cc08a59070fd --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testTopNThenStats/reduction_data.expected @@ -0,0 +1,5 @@ +ExchangeSinkExec[[hire_date{f}, salary{f}],false] +\_FragmentExec[filter=null, estimatedRowSize=0, reducer=[], fragment=[<> +Project[[_doc{f}, hire_date{f}]] +\_TopN[[Order[hire_date{f},ASC,LAST]],20[INTEGER],false] + \_EsRelation[employees][_doc{f}, avg_worked_seconds{f}, birth_date{f}, emp_no{f}, first_name{f}, gender{f}, height{f}, height.float{f}, height.half_float{f}, height.scaled_float{f}, hire_date{f}, is_rehired{f}, job_positions{f}, languages{f}, languages.byte{f}, languages.long{f}, languages.short{f}, last_name{f}, salary{f}, salary_change{f}, salary_change.int{f}, salary_change.keyword{f}, salary_change.long{f}, still_hired{f}]<>]] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testTopNThenStats/reduction_local_data.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testTopNThenStats/reduction_local_data.expected new file mode 100644 index 0000000000000..6d737b8a8eb59 --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testTopNThenStats/reduction_local_data.expected @@ -0,0 +1,4 @@ +ExchangeSinkExec[[hire_date{f}, salary{f}],false] +\_ProjectExec[[_doc{f}, hire_date{f}]] + \_FieldExtractExec[hire_date{f}]<[],[]> + \_EsQueryExec[employees], indexMode[standard], [_doc{f}], limit[20], sort[[FieldSort[field=hire_date{f}, direction=ASC, nulls=LAST]]] estimatedRowSize[24] queryBuilderAndTags [[QueryBuilderAndTags[query=null, tags=[]]]] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testTopNThenStats/reduction_local_node_reduce.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testTopNThenStats/reduction_local_node_reduce.expected new file mode 100644 index 0000000000000..89b94a06e2096 --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testTopNThenStats/reduction_local_node_reduce.expected @@ -0,0 +1,5 @@ +ExchangeSinkExec[[hire_date{f}, salary{f}],false] +\_ProjectExec[[hire_date{f}, salary{f}]] + \_FieldExtractExec[salary{f}]<[],[]> + \_TopNExec[[Order[hire_date{f},ASC,LAST]],20[INTEGER],32] + \_ExchangeSourceExec[[_doc{f}, hire_date{f}],false] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testTopNThenStats/reduction_node_reduce.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testTopNThenStats/reduction_node_reduce.expected new file mode 100644 index 0000000000000..89b94a06e2096 --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testTopNThenStats/reduction_node_reduce.expected @@ -0,0 +1,5 @@ +ExchangeSinkExec[[hire_date{f}, salary{f}],false] +\_ProjectExec[[hire_date{f}, salary{f}]] + \_FieldExtractExec[salary{f}]<[],[]> + \_TopNExec[[Order[hire_date{f},ASC,LAST]],20[INTEGER],32] + \_ExchangeSourceExec[[_doc{f}, hire_date{f}],false] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testTopNWithMissingSortField/physical_optimization.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testTopNWithMissingSortField/physical_optimization.expected new file mode 100644 index 0000000000000..cd76be3897e14 --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testTopNWithMissingSortField/physical_optimization.expected @@ -0,0 +1,7 @@ +ProjectExec[[hire_date{f}, salary{f}, emp_no{f}]] +\_TopNExec[[Order[hire_date{f},ASC,LAST]],20[INTEGER],null] + \_ExchangeExec[[emp_no{f}, hire_date{f}, salary{f}],false] + \_FragmentExec[filter=null, estimatedRowSize=0, reducer=[], fragment=[<> +Project[[emp_no{f}, hire_date{f}, salary{f}]] +\_TopN[[Order[hire_date{f},ASC,LAST]],20[INTEGER],false] + \_EsRelation[employees][avg_worked_seconds{f}, birth_date{f}, emp_no{f}, first_name{f}, gender{f}, height{f}, height.float{f}, height.half_float{f}, height.scaled_float{f}, hire_date{f}, is_rehired{f}, job_positions{f}, languages{f}, languages.byte{f}, languages.long{f}, languages.short{f}, last_name{f}, salary{f}, salary_change{f}, salary_change.int{f}, salary_change.keyword{f}, salary_change.long{f}, still_hired{f}]<>]] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testTopNWithMissingSortField/reduction_data.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testTopNWithMissingSortField/reduction_data.expected new file mode 100644 index 0000000000000..42c2f1deccb35 --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testTopNWithMissingSortField/reduction_data.expected @@ -0,0 +1,5 @@ +ExchangeSinkExec[[emp_no{f}, hire_date{f}, salary{f}],false] +\_FragmentExec[filter=null, estimatedRowSize=0, reducer=[], fragment=[<> +Project[[_doc{f}, hire_date{f}]] +\_TopN[[Order[hire_date{f},ASC,LAST]],20[INTEGER],false] + \_EsRelation[employees][_doc{f}, avg_worked_seconds{f}, birth_date{f}, emp_no{f}, first_name{f}, gender{f}, height{f}, height.float{f}, height.half_float{f}, height.scaled_float{f}, hire_date{f}, is_rehired{f}, job_positions{f}, languages{f}, languages.byte{f}, languages.long{f}, languages.short{f}, last_name{f}, salary{f}, salary_change{f}, salary_change.int{f}, salary_change.keyword{f}, salary_change.long{f}, still_hired{f}]<>]] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testTopNWithMissingSortField/reduction_local_data.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testTopNWithMissingSortField/reduction_local_data.expected new file mode 100644 index 0000000000000..86be6bee3c591 --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testTopNWithMissingSortField/reduction_local_data.expected @@ -0,0 +1,4 @@ +ExchangeSinkExec[[emp_no{f}, hire_date{f}, salary{f}],false] +\_ProjectExec[[_doc{f}, birth_date{r} AS hire_date]] + \_EvalExec[[null[DATETIME] AS birth_date]] + \_EsQueryExec[employees], indexMode[standard], [_doc{f}], limit[20], sort[] estimatedRowSize[12] queryBuilderAndTags [[QueryBuilderAndTags[query=null, tags=[]]]] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testTopNWithMissingSortField/reduction_local_node_reduce.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testTopNWithMissingSortField/reduction_local_node_reduce.expected new file mode 100644 index 0000000000000..378271a5e3f37 --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testTopNWithMissingSortField/reduction_local_node_reduce.expected @@ -0,0 +1,5 @@ +ExchangeSinkExec[[emp_no{f}, hire_date{f}, salary{f}],false] +\_ProjectExec[[emp_no{f}, hire_date{f}, salary{f}]] + \_FieldExtractExec[emp_no{f}, salary{f}]<[],[]> + \_TopNExec[[Order[hire_date{f},ASC,LAST]],20[INTEGER],36] + \_ExchangeSourceExec[[_doc{f}, hire_date{f}],false] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testTopNWithMissingSortField/reduction_node_reduce.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testTopNWithMissingSortField/reduction_node_reduce.expected new file mode 100644 index 0000000000000..378271a5e3f37 --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testTopNWithMissingSortField/reduction_node_reduce.expected @@ -0,0 +1,5 @@ +ExchangeSinkExec[[emp_no{f}, hire_date{f}, salary{f}],false] +\_ProjectExec[[emp_no{f}, hire_date{f}, salary{f}]] + \_FieldExtractExec[emp_no{f}, salary{f}]<[],[]> + \_TopNExec[[Order[hire_date{f},ASC,LAST]],20[INTEGER],36] + \_ExchangeSourceExec[[_doc{f}, hire_date{f}],false] \ No newline at end of file From 84976f57f2d9c404be2eb15b446eae2f08f73818 Mon Sep 17 00:00:00 2001 From: Gal Lalouche Date: Wed, 21 Jan 2026 23:48:05 +0200 Subject: [PATCH 02/25] Remove old test file --- ...ductionLateMaterializationGoldenTests.java | 37 ------------------- 1 file changed, 37 deletions(-) delete mode 100644 x-pack/plugin/esql/src/internalClusterTest/java/org/elasticsearch/xpack/esql/action/EsqlReductionLateMaterializationGoldenTests.java diff --git a/x-pack/plugin/esql/src/internalClusterTest/java/org/elasticsearch/xpack/esql/action/EsqlReductionLateMaterializationGoldenTests.java b/x-pack/plugin/esql/src/internalClusterTest/java/org/elasticsearch/xpack/esql/action/EsqlReductionLateMaterializationGoldenTests.java deleted file mode 100644 index 015676ebb099d..0000000000000 --- a/x-pack/plugin/esql/src/internalClusterTest/java/org/elasticsearch/xpack/esql/action/EsqlReductionLateMaterializationGoldenTests.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License - * 2.0; you may not use this file except in compliance with the Elastic License - * 2.0. - */ - -package org.elasticsearch.xpack.esql.action; - -import org.elasticsearch.xpack.esql.optimizer.GoldenTestCase; - -import java.util.EnumSet; - -public class EsqlReductionLateMaterializationGoldenTests extends GoldenTestCase { - /* - For instance, I'd like to see the data (and reduce) plans for cases such as: - queries with more than 1 topn - queries that have mv_expand (known problem due to preventing projections from bubbling up) - queries that have lookup joins on the data node - queries that have subsequent reducers that should end up on the coordinator (e.g. topn first, then stats) - queries where some fields need to be extracted before the topn, and others don't - queries where the topn sorts on expressions and/or sorts on more than 1 field - queries where the topn can be pushed down to Lucene in the data node plan, and queries where this isn't possible. - queries where the fields required for the TopN are missing on the data node (interactions with ReplaceFieldWithConstantOrNull can be subtle and only pop up as bugs months later) - */ - - public void testMultipleTopN() throws Exception { - String query = """ - FROM employees - | SORT hire_date - | LIMIT 20 - | SORT salary - | LIMIT 10 - """; - runGoldenTest(query, EnumSet.of(Stage.NODE_REDUCE)); - } -} From 34108412c1b1277da8702a7013e638242923b485 Mon Sep 17 00:00:00 2001 From: Gal Lalouche Date: Thu, 22 Jan 2026 13:12:00 +0200 Subject: [PATCH 03/25] Fix failing test --- .../xpack/esql/optimizer/GoldenTestCase.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/optimizer/GoldenTestCase.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/optimizer/GoldenTestCase.java index 8a3150f24e877..5595387c3ffce 100644 --- a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/optimizer/GoldenTestCase.java +++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/optimizer/GoldenTestCase.java @@ -226,8 +226,8 @@ private List> doTests() throws IOException { } if (stages.contains(Stage.NODE_REDUCE_LOCAL_PHYSICAL_OPTIMIZATION)) { var finalizedResult = new ReductionPlan( - localOptimize(reductionPlan.nodeReducePlan(), conf), - localOptimize(reductionPlan.dataNodePlan(), conf) + (ExchangeSinkExec) localOptimize(reductionPlan.nodeReducePlan(), conf), + (ExchangeSinkExec) localOptimize(reductionPlan.dataNodePlan(), conf) ); result.addAll( addDualPlanResult( @@ -304,8 +304,8 @@ private Path outputPath(String prefix, String suffix) { return PathUtils.get(basePath.toString(), paths); } - private ExchangeSinkExec localOptimize(PhysicalPlan plan, Configuration conf) { - return (ExchangeSinkExec) PlannerUtils.localPlan( + private PhysicalPlan localOptimize(PhysicalPlan plan, Configuration conf) { + return PlannerUtils.localPlan( EsqlTestUtils.TEST_PLANNER_SETTINGS, new EsqlFlags(false), conf, From 4066eb484f35b9de1dd136cdeb5a9054955a3005 Mon Sep 17 00:00:00 2001 From: Gal Lalouche Date: Thu, 22 Jan 2026 15:28:45 +0200 Subject: [PATCH 04/25] Small changes --- x-pack/plugin/esql/build.gradle | 6 +++--- .../elasticsearch/xpack/esql/optimizer/GoldenTestCase.java | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/x-pack/plugin/esql/build.gradle b/x-pack/plugin/esql/build.gradle index 35346969e8f23..336b63bdbdce8 100644 --- a/x-pack/plugin/esql/build.gradle +++ b/x-pack/plugin/esql/build.gradle @@ -626,12 +626,12 @@ tasks.named("test").configure { if (System.getProperty("golden.noactual") != null || project.hasProperty("golden.noactual")) { systemProperty "golden.noactual", "true" } - if (System.getProperty("golden.overwrite") != null || project.hasProperty("golden.overwrite")) { - systemProperty "golden.overwrite", "true" - } if (System.getProperty("golden.cleanactual") != null || project.hasProperty("golden.cleanactual")) { systemProperty "golden.cleanactual", "true" } + if (System.getProperty("golden.overwrite") != null || project.hasProperty("golden.overwrite")) { + systemProperty "golden.overwrite", "true" + } systemProperty "policy.directory", file("${projectDir}").absolutePath systemProperty "java.security.policy", file("${projectDir}/test.policy").absolutePath diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/optimizer/GoldenTestCase.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/optimizer/GoldenTestCase.java index 5595387c3ffce..54d0cb9183d6d 100644 --- a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/optimizer/GoldenTestCase.java +++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/optimizer/GoldenTestCase.java @@ -216,8 +216,8 @@ private List> doTests() throws IOException { conf, conf.newFoldContext(), sink, - true, // runNodeLevelReduction - true, // reduceNodeLateMaterialization + true, + true, new PlanTimeProfile() ); From 5635f49649ad0b1e5a239412f379bfef5df61621 Mon Sep 17 00:00:00 2001 From: Gal Lalouche Date: Fri, 30 Jan 2026 14:27:59 +0200 Subject: [PATCH 05/25] CR: Add minimum random transport version --- .../xpack/esql/optimizer/GoldenTestCase.java | 50 +++++++++++++++---- 1 file changed, 40 insertions(+), 10 deletions(-) diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/optimizer/GoldenTestCase.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/optimizer/GoldenTestCase.java index 54d0cb9183d6d..432d19182e2d2 100644 --- a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/optimizer/GoldenTestCase.java +++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/optimizer/GoldenTestCase.java @@ -61,6 +61,7 @@ import java.util.stream.Collectors; import static org.elasticsearch.xpack.esql.EsqlTestUtils.TEST_VERIFIER; +import static org.elasticsearch.xpack.esql.EsqlTestUtils.randomMinimumVersion; import static org.elasticsearch.xpack.esql.EsqlTestUtils.unboundLogicalOptimizerContext; import static org.elasticsearch.xpack.esql.EsqlTestUtils.withDefaultLimitWarning; import static org.elasticsearch.xpack.esql.analysis.AnalyzerTestUtils.defaultLookupResolution; @@ -83,12 +84,22 @@ public GoldenTestCase() { } protected void runGoldenTest(String esqlQuery, EnumSet stages, String... nestedPath) { - runGoldenTest(esqlQuery, stages, EsqlTestUtils.TEST_SEARCH_STATS, nestedPath); + builder(esqlQuery).stages(stages).nestedPath(nestedPath).run(); } protected void runGoldenTest(String esqlQuery, EnumSet stages, SearchStats searchStats, String... nestedPath) { + builder(esqlQuery).stages(stages).searchStats(searchStats).nestedPath(nestedPath).run(); + } + + protected void runGoldenTest( + String esqlQuery, + EnumSet stages, + SearchStats searchStats, + TransportVersion transportVersion, + String... nestedPath + ) { String testName = extractTestName(); - new Test(baseFile, testName, nestedPath, esqlQuery, stages, searchStats).doTest(); + new Test(baseFile, testName, nestedPath, esqlQuery, stages, searchStats, transportVersion).doTest(); } protected TestBuilder builder(String esqlQuery) { @@ -100,16 +111,24 @@ protected final class TestBuilder { private EnumSet stages; private SearchStats searchStats; private String[] nestedPath; - - private TestBuilder(String esqlQuery, EnumSet stages, SearchStats searchStats, String[] nestedPath) { + private TransportVersion transportVersion; + + private TestBuilder( + String esqlQuery, + EnumSet stages, + SearchStats searchStats, + String[] nestedPath, + TransportVersion transportVersion + ) { this.esqlQuery = esqlQuery; this.stages = stages; this.searchStats = searchStats; this.nestedPath = nestedPath; + this.transportVersion = transportVersion; } TestBuilder(String esqlQuery) { - this(esqlQuery, EnumSet.allOf(Stage.class), EsqlTestUtils.TEST_SEARCH_STATS, new String[0]); + this(esqlQuery, EnumSet.allOf(Stage.class), EsqlTestUtils.TEST_SEARCH_STATS, new String[0], randomMinimumVersion()); } public TestBuilder stages(EnumSet stages) { @@ -139,8 +158,17 @@ public String[] nestedPath() { return nestedPath; } + public TransportVersion transportVersion() { + return transportVersion; + } + + public TestBuilder transportVersion(TransportVersion transportVersion) { + this.transportVersion = transportVersion; + return this; + } + public void run() { - runGoldenTest(esqlQuery, stages, searchStats, nestedPath); + runGoldenTest(esqlQuery, stages, searchStats, transportVersion, nestedPath); } } @@ -150,7 +178,8 @@ private record Test( String[] nestedPath, String esqlQuery, EnumSet stages, - SearchStats searchStats + SearchStats searchStats, + TransportVersion transportVersion ) { private void doTest() { @@ -167,7 +196,6 @@ private void doTest() { private List> doTests() throws IOException { LogicalPlan parsedStatement = EsqlParser.INSTANCE.parseQuery(esqlQuery); - TransportVersion version = TransportVersion.current(); var analyzer = new Analyzer( new AnalyzerContext( EsqlTestUtils.TEST_CFG, @@ -176,7 +204,7 @@ private List> doTests() throws IOException { defaultLookupResolution(), new EnrichResolution(), InferenceResolution.EMPTY, - version, + transportVersion, UnmappedResolution.FAIL ), TEST_VERIFIER @@ -198,7 +226,9 @@ private List> doTests() throws IOException { || stages.contains(Stage.NODE_REDUCE_OPTIMIZATION) || stages.contains(Stage.NODE_REDUCE_LOCAL_PHYSICAL_OPTIMIZATION)) { var physicalPlanOptimizer = new PhysicalPlanOptimizer(new PhysicalOptimizerContext(null, null)); - PhysicalPlan physicalPlan = physicalPlanOptimizer.optimize(new Mapper().map(new Versioned<>(logicallyOptimized, version))); + PhysicalPlan physicalPlan = physicalPlanOptimizer.optimize( + new Mapper().map(new Versioned<>(logicallyOptimized, transportVersion)) + ); if (stages.contains(Stage.PHYSICAL_OPTIMIZATION)) { result.add(Tuple.tuple(Stage.PHYSICAL_OPTIMIZATION, verifyOrWrite(physicalPlan, Stage.PHYSICAL_OPTIMIZATION))); } From 84a15de949c769878c3a2911bacd4ad5b68177e9 Mon Sep 17 00:00:00 2001 From: Gal Lalouche Date: Fri, 30 Jan 2026 16:50:11 +0200 Subject: [PATCH 06/25] CR: Add ESQL query to the output --- .../xpack/esql/optimizer/GoldenTestCase.java | 29 ++++++++++++++----- .../query.esql | 4 +++ .../query.esql | 4 +++ .../query.esql | 2 ++ .../query.esql | 2 ++ .../query.esql | 2 ++ .../query.esql | 3 ++ .../query.esql | 2 ++ .../query.esql | 5 ++++ .../query.esql | 3 ++ .../query.esql | 2 ++ .../query.esql | 2 ++ .../query.esql | 4 +++ .../testExpressionSortTopN/query.esql | 4 +++ .../testLookupJoinOnDataNode/query.esql | 6 ++++ .../testMultipleFieldSortTopN/query.esql | 4 +++ .../testMultipleTopN/query.esql | 6 ++++ .../testMvExpandBeforeTopN/query.esql | 5 ++++ .../testPushedDownTopN/query.esql | 4 +++ .../query.esql | 5 ++++ .../testTopNThenStats/query.esql | 5 ++++ .../testTopNWithMissingSortField/query.esql | 4 +++ 22 files changed, 100 insertions(+), 7 deletions(-) create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testDateTruncBucketNotTransformToQueryAndTagsWithFork/query.esql create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testDateTruncBucketNotTransformToQueryAndTagsWithLookupJoin/query.esql create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testDateTruncBucketTransformToQueryAndTags/query.esql create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testDateTruncBucketTransformToQueryAndTagsWithEsFilter/query.esql create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testDateTruncBucketTransformToQueryAndTagsWithMultipleAggregates/query.esql create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testDateTruncBucketTransformToQueryAndTagsWithOtherPushdownFunctions/query.esql create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testDateTruncBucketTransformToQueryAndTagsWithWhereInsideAggregation/query.esql create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testDateTruncNotTransformToQueryAndTags/query.esql create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testForkWithStatsCountStarDateTrunc/query.esql create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testRoundToTransformToQueryAndTags/query.esql create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testSubqueryWithCountStarAndDateTrunc/query.esql create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testBasicTopNLateMaterialization/query.esql create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testExpressionSortTopN/query.esql create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testLookupJoinOnDataNode/query.esql create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testMultipleFieldSortTopN/query.esql create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testMultipleTopN/query.esql create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testMvExpandBeforeTopN/query.esql create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testPushedDownTopN/query.esql create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testSomeFieldsNeededBeforeLateMaterialization/query.esql create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testTopNThenStats/query.esql create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testTopNWithMissingSortField/query.esql diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/optimizer/GoldenTestCase.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/optimizer/GoldenTestCase.java index 432d19182e2d2..23bb65195c55f 100644 --- a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/optimizer/GoldenTestCase.java +++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/optimizer/GoldenTestCase.java @@ -25,6 +25,7 @@ import org.elasticsearch.xpack.esql.analysis.AnalyzerContext; import org.elasticsearch.xpack.esql.analysis.EnrichResolution; import org.elasticsearch.xpack.esql.analysis.UnmappedResolution; +import org.elasticsearch.xpack.esql.core.expression.FoldContext; import org.elasticsearch.xpack.esql.core.tree.Node; import org.elasticsearch.xpack.esql.expression.function.EsqlFunctionRegistry; import org.elasticsearch.xpack.esql.inference.InferenceResolution; @@ -62,7 +63,6 @@ import static org.elasticsearch.xpack.esql.EsqlTestUtils.TEST_VERIFIER; import static org.elasticsearch.xpack.esql.EsqlTestUtils.randomMinimumVersion; -import static org.elasticsearch.xpack.esql.EsqlTestUtils.unboundLogicalOptimizerContext; import static org.elasticsearch.xpack.esql.EsqlTestUtils.withDefaultLimitWarning; import static org.elasticsearch.xpack.esql.analysis.AnalyzerTestUtils.defaultLookupResolution; @@ -196,6 +196,7 @@ private void doTest() { private List> doTests() throws IOException { LogicalPlan parsedStatement = EsqlParser.INSTANCE.parseQuery(esqlQuery); + Files.writeString(PathUtils.get(basePath.toString(), testName, "query.esql"), esqlQuery); var analyzer = new Analyzer( new AnalyzerContext( EsqlTestUtils.TEST_CFG, @@ -217,7 +218,8 @@ private List> doTests() throws IOException { if (stages.equals(EnumSet.of(Stage.ANALYSIS))) { return result; } - var logicallyOptimized = new LogicalPlanOptimizer(unboundLogicalOptimizerContext()).optimize(analyzed); + var optimizerContext = new LogicalOptimizerContext(EsqlTestUtils.TEST_CFG, FoldContext.small(), transportVersion); + var logicallyOptimized = new LogicalPlanOptimizer(optimizerContext).optimize(analyzed); if (stages.contains(Stage.LOGICAL_OPTIMIZATION)) { result.add(Tuple.tuple(Stage.LOGICAL_OPTIMIZATION, verifyOrWrite(logicallyOptimized, Stage.LOGICAL_OPTIMIZATION))); } @@ -225,7 +227,9 @@ private List> doTests() throws IOException { || stages.contains(Stage.LOCAL_PHYSICAL_OPTIMIZATION) || stages.contains(Stage.NODE_REDUCE_OPTIMIZATION) || stages.contains(Stage.NODE_REDUCE_LOCAL_PHYSICAL_OPTIMIZATION)) { - var physicalPlanOptimizer = new PhysicalPlanOptimizer(new PhysicalOptimizerContext(null, null)); + var physicalPlanOptimizer = new PhysicalPlanOptimizer( + new PhysicalOptimizerContext(EsqlTestUtils.TEST_CFG, transportVersion) + ); PhysicalPlan physicalPlan = physicalPlanOptimizer.optimize( new Mapper().map(new Versioned<>(logicallyOptimized, transportVersion)) ); @@ -393,15 +397,26 @@ protected List filteredWarnings() { } protected enum Stage { + /** See {@link Analyzer}. */ ANALYSIS, + /** See {@link LogicalPlanOptimizer}. */ LOGICAL_OPTIMIZATION, + /** See {@link PhysicalPlanOptimizer}. */ PHYSICAL_OPTIMIZATION, - // There's no LOCAL_LOGICAL here since in production we use PlannerUtils.localPlan to produce the local physical plan directly from - // non-local physical plan. + /** + * See {@link LocalPhysicalPlanOptimizer}. There's no LOCAL_LOGICAL here since in production we use PlannerUtils.localPlan to + * produce the local physical plan directly from non-local physical plan. + */ LOCAL_PHYSICAL_OPTIMIZATION, - // Both node_reduce stages actually result in *two* plans: one for the node reduce driver and one for the data nodes. + /** + * See {@link ComputeService#reductionPlan}. Actually results in two plans: one for the node reduce driver and one for the + * data nodes. + */ NODE_REDUCE_OPTIMIZATION, - // Perform the local physical optimization on both node reduce and data node plans. + /** + * A combination of {@link Stage#NODE_REDUCE_OPTIMIZATION} and {@link Stage#LOCAL_PHYSICAL_OPTIMIZATION}: first produce the node + * reduce and data node plans, and then perform local physical optimization on both. + */ NODE_REDUCE_LOCAL_PHYSICAL_OPTIMIZATION } diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testDateTruncBucketNotTransformToQueryAndTagsWithFork/query.esql b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testDateTruncBucketNotTransformToQueryAndTagsWithFork/query.esql new file mode 100644 index 0000000000000..c8f08b2e6dd38 --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testDateTruncBucketNotTransformToQueryAndTagsWithFork/query.esql @@ -0,0 +1,4 @@ +from all_types +| fork (where integer > 100) +(where keyword : "keyword") +| stats count(*) by x = round_to(date, "2023-10-20", "2023-10-21", "2023-10-22", "2023-10-23") diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testDateTruncBucketNotTransformToQueryAndTagsWithLookupJoin/query.esql b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testDateTruncBucketNotTransformToQueryAndTagsWithLookupJoin/query.esql new file mode 100644 index 0000000000000..7472b3a4d943e --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testDateTruncBucketNotTransformToQueryAndTagsWithLookupJoin/query.esql @@ -0,0 +1,4 @@ +from all_types +| rename integer as language_code +| lookup join languages_lookup on language_code +| stats count(*) by x = round_to(date, "2023-10-20", "2023-10-21", "2023-10-22", "2023-10-23") diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testDateTruncBucketTransformToQueryAndTags/query.esql b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testDateTruncBucketTransformToQueryAndTags/query.esql new file mode 100644 index 0000000000000..46e5cd746c53f --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testDateTruncBucketTransformToQueryAndTags/query.esql @@ -0,0 +1,2 @@ +from all_types +| stats count(*) by x = round_to(date, "2023-10-20", "2023-10-21", "2023-10-22", "2023-10-23") diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testDateTruncBucketTransformToQueryAndTagsWithEsFilter/query.esql b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testDateTruncBucketTransformToQueryAndTagsWithEsFilter/query.esql new file mode 100644 index 0000000000000..46e5cd746c53f --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testDateTruncBucketTransformToQueryAndTagsWithEsFilter/query.esql @@ -0,0 +1,2 @@ +from all_types +| stats count(*) by x = round_to(date, "2023-10-20", "2023-10-21", "2023-10-22", "2023-10-23") diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testDateTruncBucketTransformToQueryAndTagsWithMultipleAggregates/query.esql b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testDateTruncBucketTransformToQueryAndTagsWithMultipleAggregates/query.esql new file mode 100644 index 0000000000000..48b94551ef462 --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testDateTruncBucketTransformToQueryAndTagsWithMultipleAggregates/query.esql @@ -0,0 +1,2 @@ +from all_types +| stats sum(long), count(*) by x = round_to(date, "2023-10-20", "2023-10-21", "2023-10-22", "2023-10-23") diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testDateTruncBucketTransformToQueryAndTagsWithOtherPushdownFunctions/query.esql b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testDateTruncBucketTransformToQueryAndTagsWithOtherPushdownFunctions/query.esql new file mode 100644 index 0000000000000..d252b63236f6b --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testDateTruncBucketTransformToQueryAndTagsWithOtherPushdownFunctions/query.esql @@ -0,0 +1,3 @@ +from all_types +| where keyword : "keyword" +| stats count(*) by x = round_to(date, "2023-10-20", "2023-10-21", "2023-10-22", "2023-10-23") diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testDateTruncBucketTransformToQueryAndTagsWithWhereInsideAggregation/query.esql b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testDateTruncBucketTransformToQueryAndTagsWithWhereInsideAggregation/query.esql new file mode 100644 index 0000000000000..33092020e833b --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testDateTruncBucketTransformToQueryAndTagsWithWhereInsideAggregation/query.esql @@ -0,0 +1,2 @@ +from all_types +| stats count(*) where long > 10 by x = round_to(date, "2023-10-20", "2023-10-21", "2023-10-22", "2023-10-23") diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testDateTruncNotTransformToQueryAndTags/query.esql b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testDateTruncNotTransformToQueryAndTags/query.esql new file mode 100644 index 0000000000000..327c15df1eb1c --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testDateTruncNotTransformToQueryAndTags/query.esql @@ -0,0 +1,5 @@ +from all_types +| sort date +| eval x = round_to(date, "2023-10-20", "2023-10-21", "2023-10-22", "2023-10-23") +| keep alias_integer, date, x +| limit 5 diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testForkWithStatsCountStarDateTrunc/query.esql b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testForkWithStatsCountStarDateTrunc/query.esql new file mode 100644 index 0000000000000..72b45c8bf9ea4 --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testForkWithStatsCountStarDateTrunc/query.esql @@ -0,0 +1,3 @@ +from all_types +| fork (stats x = count(*), y = max(long) by hd = date_trunc(1 day, date)) +(stats x = count(*), y = min(long) by hd = date_trunc(2 day, date)) diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testRoundToTransformToQueryAndTags/query.esql b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testRoundToTransformToQueryAndTags/query.esql new file mode 100644 index 0000000000000..2af1315b103ac --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testRoundToTransformToQueryAndTags/query.esql @@ -0,0 +1,2 @@ +from all_types +| stats count(*) by x = round_to(long, 1697760000000,1697846400000,1697932800000,1698019200000) diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testSubqueryWithCountStarAndDateTrunc/query.esql b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testSubqueryWithCountStarAndDateTrunc/query.esql new file mode 100644 index 0000000000000..948940292181b --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testSubqueryWithCountStarAndDateTrunc/query.esql @@ -0,0 +1,2 @@ +from all_types, (from all_types | stats cnt = count(*) by x = date_trunc(1 day, date)) +| keep x, cnt, date diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testBasicTopNLateMaterialization/query.esql b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testBasicTopNLateMaterialization/query.esql new file mode 100644 index 0000000000000..8d87154eaac5d --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testBasicTopNLateMaterialization/query.esql @@ -0,0 +1,4 @@ +FROM employees +| keep hire_date, salary, emp_no +| SORT hire_date +| LIMIT 20 diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testExpressionSortTopN/query.esql b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testExpressionSortTopN/query.esql new file mode 100644 index 0000000000000..fca907a58b931 --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testExpressionSortTopN/query.esql @@ -0,0 +1,4 @@ +FROM employees +| keep hire_date, height +| SORT sin(height) * 2 +| LIMIT 20 diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testLookupJoinOnDataNode/query.esql b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testLookupJoinOnDataNode/query.esql new file mode 100644 index 0000000000000..39ae29f7957c7 --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testLookupJoinOnDataNode/query.esql @@ -0,0 +1,6 @@ +FROM employees +| EVAL language_code = languages +| LOOKUP JOIN languages_lookup ON language_code +| WHERE emp_no >= 10091 AND emp_no < 10094 +| SORT emp_no +| LIMIT 20 diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testMultipleFieldSortTopN/query.esql b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testMultipleFieldSortTopN/query.esql new file mode 100644 index 0000000000000..f1fb24257897e --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testMultipleFieldSortTopN/query.esql @@ -0,0 +1,4 @@ +FROM employees +| keep hire_date, emp_no, height +| SORT hire_date, height +| LIMIT 20 diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testMultipleTopN/query.esql b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testMultipleTopN/query.esql new file mode 100644 index 0000000000000..99a7a471aeed3 --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testMultipleTopN/query.esql @@ -0,0 +1,6 @@ +FROM employees +| keep hire_date, salary, emp_no +| SORT hire_date +| LIMIT 20 +| SORT salary +| LIMIT 10 diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testMvExpandBeforeTopN/query.esql b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testMvExpandBeforeTopN/query.esql new file mode 100644 index 0000000000000..4420e13bc89f7 --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testMvExpandBeforeTopN/query.esql @@ -0,0 +1,5 @@ +FROM employees +| keep emp_no, job_positions, salary +| MV_EXPAND job_positions +| SORT salary +| LIMIT 20 diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testPushedDownTopN/query.esql b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testPushedDownTopN/query.esql new file mode 100644 index 0000000000000..d9d69d124a61b --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testPushedDownTopN/query.esql @@ -0,0 +1,4 @@ +FROM employees +| keep emp_no, height +| SORT height +| LIMIT 20 diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testSomeFieldsNeededBeforeLateMaterialization/query.esql b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testSomeFieldsNeededBeforeLateMaterialization/query.esql new file mode 100644 index 0000000000000..cb231bdf6f2dd --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testSomeFieldsNeededBeforeLateMaterialization/query.esql @@ -0,0 +1,5 @@ +FROM employees +| keep hire_date, salary, emp_no +| WHERE salary > 10000 +| SORT hire_date +| LIMIT 20 diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testTopNThenStats/query.esql b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testTopNThenStats/query.esql new file mode 100644 index 0000000000000..f80ab35edf35a --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testTopNThenStats/query.esql @@ -0,0 +1,5 @@ +FROM employees +| keep hire_date, salary, emp_no +| SORT hire_date +| LIMIT 20 +| STATS avg_salary = AVG(salary), count = COUNT(*) diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testTopNWithMissingSortField/query.esql b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testTopNWithMissingSortField/query.esql new file mode 100644 index 0000000000000..8d87154eaac5d --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testTopNWithMissingSortField/query.esql @@ -0,0 +1,4 @@ +FROM employees +| keep hire_date, salary, emp_no +| SORT hire_date +| LIMIT 20 From 06d4661776e91caa00e77c18963c38bb82e4cd35 Mon Sep 17 00:00:00 2001 From: Gal Lalouche Date: Fri, 30 Jan 2026 22:25:37 +0200 Subject: [PATCH 07/25] Remove local node reduction tests in some cases --- .../xpack/esql/planner/PlannerUtils.java | 2 + .../esql/plugin/ClusterComputeHandler.java | 1 + .../xpack/esql/plugin/ComputeService.java | 57 ++++++++++++++----- .../esql/plugin/DataNodeComputeHandler.java | 13 ++++- .../plugin/LateMaterializationPlanner.java | 2 +- .../NodeReduceLocalPhysicalOptimization.java | 14 +++++ .../xpack/esql/plugin/ReductionPlan.java | 10 +++- .../xpack/esql/optimizer/GoldenTestCase.java | 38 ++++++++----- .../reduction_local_node_reduce.expected | 5 -- .../reduction_local_node_reduce.expected | 5 -- .../reduction_local_node_reduce.expected | 5 -- .../reduction_local_node_reduce.expected | 5 -- .../reduction_local_node_reduce.expected | 5 -- .../reduction_local_node_reduce.expected | 5 -- .../reduction_local_node_reduce.expected | 5 -- .../reduction_local_node_reduce.expected | 5 -- .../reduction_local_node_reduce.expected | 5 -- 17 files changed, 106 insertions(+), 76 deletions(-) create mode 100644 x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/plugin/NodeReduceLocalPhysicalOptimization.java delete mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testBasicTopNLateMaterialization/reduction_local_node_reduce.expected delete mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testExpressionSortTopN/reduction_local_node_reduce.expected delete mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testLookupJoinOnDataNode/reduction_local_node_reduce.expected delete mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testMultipleFieldSortTopN/reduction_local_node_reduce.expected delete mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testMultipleTopN/reduction_local_node_reduce.expected delete mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testPushedDownTopN/reduction_local_node_reduce.expected delete mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testSomeFieldsNeededBeforeLateMaterialization/reduction_local_node_reduce.expected delete mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testTopNThenStats/reduction_local_node_reduce.expected delete mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testTopNWithMissingSortField/reduction_local_node_reduce.expected diff --git a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/planner/PlannerUtils.java b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/planner/PlannerUtils.java index 2755625502a7c..09c0f51857f0f 100644 --- a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/planner/PlannerUtils.java +++ b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/planner/PlannerUtils.java @@ -262,6 +262,8 @@ public static PhysicalPlan localPlan( return EstimatesRowSize.estimateRowSize(f.estimatedRowSize(), localOptimized); }); + // TODO add a test assertion for the consistency checker (see + // https://github.com/elastic/elasticsearch/pull/141082/changes#r2745334028); PhysicalPlan resultPlan = isCoordPlan.get() ? plan : localPhysicalPlan; return resultPlan; diff --git a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/plugin/ClusterComputeHandler.java b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/plugin/ClusterComputeHandler.java index 6abdf64654a7c..07c82f9efb71d 100644 --- a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/plugin/ClusterComputeHandler.java +++ b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/plugin/ClusterComputeHandler.java @@ -303,6 +303,7 @@ void runComputeOnRemoteCluster( () -> exchangeSink.createExchangeSink(() -> {}) ), coordinatorPlan, + NodeReduceLocalPhysicalOptimization.ENABLED, configuration.profile() ? new PlanTimeProfile() : null, computeListener.acquireCompute() ); diff --git a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/plugin/ComputeService.java b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/plugin/ComputeService.java index 6684fdf55b37b..768e3663e6776 100644 --- a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/plugin/ComputeService.java +++ b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/plugin/ComputeService.java @@ -206,7 +206,7 @@ public void execute( ActionListener listener ) { assert ThreadPool.assertCurrentThreadPool( - EsqlPlugin.ESQL_WORKER_THREAD_POOL_NAME, + ESQL_WORKER_THREAD_POOL_NAME, ThreadPool.Names.SYSTEM_READ, ThreadPool.Names.SEARCH, ThreadPool.Names.SEARCH_COORDINATION @@ -284,7 +284,14 @@ public void execute( }) ) ) { - runCompute(rootTask, computeContext, mainPlan, planTimeProfile, localListener.acquireCompute()); + runCompute( + rootTask, + computeContext, + mainPlan, + NodeReduceLocalPhysicalOptimization.ENABLED, + planTimeProfile, + localListener.acquireCompute() + ); for (int i = 0; i < subplans.size(); i++) { var subplan = subplans.get(i); @@ -387,7 +394,14 @@ public void executePlan( }) ) ) { - runCompute(rootTask, computeContext, coordinatorPlan, planTimeProfile, computeListener.acquireCompute()); + runCompute( + rootTask, + computeContext, + coordinatorPlan, + NodeReduceLocalPhysicalOptimization.ENABLED, + planTimeProfile, + computeListener.acquireCompute() + ); return; } } else { @@ -468,6 +482,7 @@ public void executePlan( exchangeSinkSupplier ), coordinatorPlan, + NodeReduceLocalPhysicalOptimization.ENABLED, planTimeProfile, localListener.acquireCompute() ); @@ -642,6 +657,7 @@ void runCompute( CancellableTask task, ComputeContext context, PhysicalPlan plan, + NodeReduceLocalPhysicalOptimization nodeReduceLocalPhysicalOptimization, PlanTimeProfile planTimeProfile, ActionListener listener ) { @@ -674,15 +690,18 @@ void runCompute( List localContexts = new ArrayList<>(); context.searchExecutionContexts().iterable().forEach(localContexts::add); - var localPlan = PlannerUtils.localPlan( - plannerSettings, - context.flags(), - localContexts, - context.configuration(), - context.foldCtx(), - plan, - planTimeProfile - ); + var localPlan = switch (nodeReduceLocalPhysicalOptimization) { + case ENABLED -> PlannerUtils.localPlan( + plannerSettings, + context.flags(), + localContexts, + context.configuration(), + context.foldCtx(), + plan, + planTimeProfile + ); + case DISABLED -> plan; + }; if (LOGGER.isDebugEnabled()) { LOGGER.debug("Local plan for {}:\n{}", context.description(), localPlan); } @@ -771,14 +790,19 @@ public static ReductionPlan reductionPlan( ) { long startTime = planTimeProfile == null ? 0 : System.nanoTime(); PhysicalPlan source = new ExchangeSourceExec(originalPlan.source(), originalPlan.output(), originalPlan.isIntermediateAgg()); - ReductionPlan defaultResult = new ReductionPlan(originalPlan.replaceChild(source), originalPlan); + ReductionPlan defaultResult = new ReductionPlan( + originalPlan.replaceChild(source), + originalPlan, + NodeReduceLocalPhysicalOptimization.ENABLED + ); if (reduceNodeLateMaterialization == false && runNodeLevelReduction == false) { return defaultResult; } Function placePlanBetweenExchanges = p -> new ReductionPlan( originalPlan.replaceChild(p.replaceChildren(List.of(source))), - originalPlan + originalPlan, + NodeReduceLocalPhysicalOptimization.ENABLED ); // The default plan is just the exchange source piped directly into the exchange sink. ReductionPlan reductionPlan = switch (PlannerUtils.reductionPlan(originalPlan)) { @@ -792,7 +816,10 @@ public static ReductionPlan reductionPlan( ) // Fallback to the behavior listed below, i.e., a regular top n reduction without loading new fields. .orElseGet(() -> runNodeLevelReduction ? placePlanBetweenExchanges.apply(topN.plan()) : defaultResult); - case PlannerUtils.TopNReduction topN when runNodeLevelReduction -> placePlanBetweenExchanges.apply(topN.plan()); + case PlannerUtils.TopNReduction topN when runNodeLevelReduction -> + // The TopN reduction plan should not be further optimized locally on the node reduce driver, since we took great pains to + // preplan in advance, including all the necessary field extractions! + placePlanBetweenExchanges.apply(topN.plan()).withoutNodeReduceLocalPhysicalOptimization(); case PlannerUtils.ReducedPlan rp when runNodeLevelReduction -> placePlanBetweenExchanges.apply(rp.plan()); default -> defaultResult; }; diff --git a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/plugin/DataNodeComputeHandler.java b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/plugin/DataNodeComputeHandler.java index 5e17b436e03a0..a63a8cbcf6b46 100644 --- a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/plugin/DataNodeComputeHandler.java +++ b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/plugin/DataNodeComputeHandler.java @@ -350,6 +350,7 @@ public void onFailure(Exception e) { parentTask, computeContext, request.plan(), + NodeReduceLocalPhysicalOptimization.ENABLED, planTimeProfile, sub.acquireCompute() ); @@ -367,7 +368,14 @@ public void onFailure(Exception e) { null, () -> exchangeSink.createExchangeSink(pagesProduced::incrementAndGet) ); - computeService.runCompute(parentTask, computeContext, request.plan(), planTimeProfile, batchListener); + computeService.runCompute( + parentTask, + computeContext, + request.plan(), + NodeReduceLocalPhysicalOptimization.ENABLED, + planTimeProfile, + batchListener + ); } }, batchListener::onFailure) ); @@ -471,6 +479,7 @@ private void runComputeOnDataNode( CancellableTask task, String externalId, PhysicalPlan reducePlan, + NodeReduceLocalPhysicalOptimization nodeReduceLocalPhysicalOptimization, DataNodeRequest request, boolean failFastOnShardFailure, AcquiredSearchContexts searchContexts, @@ -532,6 +541,7 @@ private void runComputeOnDataNode( () -> externalSink.createExchangeSink(() -> {}) ), reducePlan, + nodeReduceLocalPhysicalOptimization, planTimeProfile, ActionListener.wrap(resp -> { // don't return until all pages are fetched @@ -600,6 +610,7 @@ public void messageReceived(DataNodeRequest request, TransportChannel channel, T (CancellableTask) task, sessionId, reductionPlan.nodeReducePlan(), + reductionPlan.nodeReduceLocalPhysicalOptimization(), request.withPlan(reductionPlan.dataNodePlan()), failFastOnShardFailures, computeSearchContexts, diff --git a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/plugin/LateMaterializationPlanner.java b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/plugin/LateMaterializationPlanner.java index 793e3846a1734..678d3a7540242 100644 --- a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/plugin/LateMaterializationPlanner.java +++ b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/plugin/LateMaterializationPlanner.java @@ -139,7 +139,7 @@ public static Optional planReduceDriverTopN( EstimatesRowSize.estimateRowSize(updatedFragmentExec.estimatedRowSize(), reductionPlan) ); - return Optional.of(new ReductionPlan(reductionPlanWithSize, updatedDataPlan)); + return Optional.of(new ReductionPlan(reductionPlanWithSize, updatedDataPlan, NodeReduceLocalPhysicalOptimization.DISABLED)); } private static PhysicalPlan toPhysical(LogicalPlan plan, LocalPhysicalOptimizerContext context) { diff --git a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/plugin/NodeReduceLocalPhysicalOptimization.java b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/plugin/NodeReduceLocalPhysicalOptimization.java new file mode 100644 index 0000000000000..449befb396cdc --- /dev/null +++ b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/plugin/NodeReduceLocalPhysicalOptimization.java @@ -0,0 +1,14 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. + */ + +package org.elasticsearch.xpack.esql.plugin; + +/** This class is {@code public} for testing. */ +public enum NodeReduceLocalPhysicalOptimization { + ENABLED, + DISABLED +} diff --git a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/plugin/ReductionPlan.java b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/plugin/ReductionPlan.java index 9e7ee12aa3e03..83a0e27808586 100644 --- a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/plugin/ReductionPlan.java +++ b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/plugin/ReductionPlan.java @@ -17,4 +17,12 @@ * @param dataNodePlan The plan to be executed on the data driver. This may contain a * {@link org.elasticsearch.xpack.esql.plan.physical.FragmentExec}. */ -public record ReductionPlan(ExchangeSinkExec nodeReducePlan, ExchangeSinkExec dataNodePlan) {} +public record ReductionPlan( + ExchangeSinkExec nodeReducePlan, + ExchangeSinkExec dataNodePlan, + NodeReduceLocalPhysicalOptimization nodeReduceLocalPhysicalOptimization +) { + public ReductionPlan withoutNodeReduceLocalPhysicalOptimization() { + return new ReductionPlan(nodeReducePlan, dataNodePlan, NodeReduceLocalPhysicalOptimization.DISABLED); + } +} diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/optimizer/GoldenTestCase.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/optimizer/GoldenTestCase.java index 23bb65195c55f..86b2be3329d1a 100644 --- a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/optimizer/GoldenTestCase.java +++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/optimizer/GoldenTestCase.java @@ -196,6 +196,7 @@ private void doTest() { private List> doTests() throws IOException { LogicalPlan parsedStatement = EsqlParser.INSTANCE.parseQuery(esqlQuery); + Files.createDirectories(PathUtils.get(basePath.toString(), testName)); Files.writeString(PathUtils.get(basePath.toString(), testName, "query.esql"), esqlQuery); var analyzer = new Analyzer( new AnalyzerContext( @@ -258,19 +259,31 @@ private List> doTests() throws IOException { if (stages.contains(Stage.NODE_REDUCE_OPTIMIZATION)) { result.addAll(addDualPlanResult(Stage.NODE_REDUCE_OPTIMIZATION, reductionPlan, "node_reduce", "data")); } + // FIXME(gal, NOCOMMIT) Simplify this, this shouldn't only perform the local optimization on the data plan. if (stages.contains(Stage.NODE_REDUCE_LOCAL_PHYSICAL_OPTIMIZATION)) { - var finalizedResult = new ReductionPlan( - (ExchangeSinkExec) localOptimize(reductionPlan.nodeReducePlan(), conf), - (ExchangeSinkExec) localOptimize(reductionPlan.dataNodePlan(), conf) - ); - result.addAll( - addDualPlanResult( - Stage.NODE_REDUCE_LOCAL_PHYSICAL_OPTIMIZATION, - finalizedResult, - "local_node_reduce", - "local_data" - ) - ); + switch (reductionPlan.nodeReduceLocalPhysicalOptimization()) { + // FIXME(gal, NOCOMMIT) document + case DISABLED -> { + var foo = localOptimize(reductionPlan.dataNodePlan(), conf); + var bar = verifyOrWrite(foo, outputPath("reduction_", "local_data")); + result.add(Tuple.tuple(Stage.NODE_REDUCE_LOCAL_PHYSICAL_OPTIMIZATION, bar)); + } + case ENABLED -> { + var finalizedResult = new ReductionPlan( + (ExchangeSinkExec) localOptimize(reductionPlan.nodeReducePlan(), conf), + (ExchangeSinkExec) localOptimize(reductionPlan.dataNodePlan(), conf), + reductionPlan.nodeReduceLocalPhysicalOptimization() + ); + result.addAll( + addDualPlanResult( + Stage.NODE_REDUCE_LOCAL_PHYSICAL_OPTIMIZATION, + finalizedResult, + "local_node_reduce", + "local_data" + ) + ); + } + } } } } @@ -352,7 +365,6 @@ private PhysicalPlan localOptimize(PhysicalPlan plan, Configuration conf) { } private static Test.TestResult createNewOutput(Path output, QueryPlan plan) throws IOException { - Files.createDirectories(output.getParent()); Files.writeString(output, toString(plan), StandardCharsets.UTF_8); return Test.TestResult.CREATED; } diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testBasicTopNLateMaterialization/reduction_local_node_reduce.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testBasicTopNLateMaterialization/reduction_local_node_reduce.expected deleted file mode 100644 index 378271a5e3f37..0000000000000 --- a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testBasicTopNLateMaterialization/reduction_local_node_reduce.expected +++ /dev/null @@ -1,5 +0,0 @@ -ExchangeSinkExec[[emp_no{f}, hire_date{f}, salary{f}],false] -\_ProjectExec[[emp_no{f}, hire_date{f}, salary{f}]] - \_FieldExtractExec[emp_no{f}, salary{f}]<[],[]> - \_TopNExec[[Order[hire_date{f},ASC,LAST]],20[INTEGER],36] - \_ExchangeSourceExec[[_doc{f}, hire_date{f}],false] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testExpressionSortTopN/reduction_local_node_reduce.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testExpressionSortTopN/reduction_local_node_reduce.expected deleted file mode 100644 index d23a70cf756e6..0000000000000 --- a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testExpressionSortTopN/reduction_local_node_reduce.expected +++ /dev/null @@ -1,5 +0,0 @@ -ExchangeSinkExec[[height{f}, hire_date{f}, $$order_by$0$0{r}],false] -\_ProjectExec[[height{f}, hire_date{f}, $$order_by$0$0{r}]] - \_FieldExtractExec[hire_date{f}]<[],[]> - \_TopNExec[[Order[$$order_by$0$0{r},ASC,LAST]],20[INTEGER],44] - \_ExchangeSourceExec[[_doc{f}, height{f}, $$order_by$0$0{r}],false] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testLookupJoinOnDataNode/reduction_local_node_reduce.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testLookupJoinOnDataNode/reduction_local_node_reduce.expected deleted file mode 100644 index 1c739d108e561..0000000000000 --- a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testLookupJoinOnDataNode/reduction_local_node_reduce.expected +++ /dev/null @@ -1,5 +0,0 @@ -ExchangeSinkExec[[avg_worked_seconds{f}, birth_date{f}, emp_no{f}, first_name{f}, gender{f}, height{f}, height.float{f}, height.half_float{f}, height.scaled_float{f}, hire_date{f}, is_rehired{f}, job_positions{f}, languages{f}, languages.byte{f}, languages.long{f}, languages.short{f}, last_name{f}, salary{f}, salary_change{f}, salary_change.int{f}, salary_change.keyword{f}, salary_change.long{f}, still_hired{f}, language_code{r}, language_name{f}],false] -\_ProjectExec[[avg_worked_seconds{f}, birth_date{f}, emp_no{f}, first_name{f}, gender{f}, height{f}, height.float{f}, height.half_float{f}, height.scaled_float{f}, hire_date{f}, is_rehired{f}, job_positions{f}, languages{f}, languages.byte{f}, languages.long{f}, languages.short{f}, last_name{f}, salary{f}, salary_change{f}, salary_change.int{f}, salary_change.keyword{f}, salary_change.long{f}, still_hired{f}, language_code{r}, language_name{f}]] - \_FieldExtractExec[avg_worked_seconds{f}, birth_date{f}, first_name{f}, gender{f}, height{f}, height.float{f}, height.half_float{f}, height.scaled_float{f}, hire_date{f}, is_rehired{f}, job_positions{f}, languages.byte{f}, languages.long{f}, languages.short{f}, last_name{f}, salary{f}, salary_change{f}, salary_change.int{f}, salary_change.keyword{f}, salary_change.long{f}, still_hired{f}]<[],[]> - \_TopNExec[[Order[emp_no{f},ASC,LAST]],20[INTEGER],430] - \_ExchangeSourceExec[[_doc{f}, emp_no{f}, languages{f}, language_code{r}, language_name{f}],false] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testMultipleFieldSortTopN/reduction_local_node_reduce.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testMultipleFieldSortTopN/reduction_local_node_reduce.expected deleted file mode 100644 index b4903131e7355..0000000000000 --- a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testMultipleFieldSortTopN/reduction_local_node_reduce.expected +++ /dev/null @@ -1,5 +0,0 @@ -ExchangeSinkExec[[emp_no{f}, height{f}, hire_date{f}],false] -\_ProjectExec[[emp_no{f}, height{f}, hire_date{f}]] - \_FieldExtractExec[emp_no{f}]<[],[]> - \_TopNExec[[Order[hire_date{f},ASC,LAST], Order[height{f},ASC,LAST]],20[INTEGER],40] - \_ExchangeSourceExec[[_doc{f}, hire_date{f}, height{f}],false] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testMultipleTopN/reduction_local_node_reduce.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testMultipleTopN/reduction_local_node_reduce.expected deleted file mode 100644 index 378271a5e3f37..0000000000000 --- a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testMultipleTopN/reduction_local_node_reduce.expected +++ /dev/null @@ -1,5 +0,0 @@ -ExchangeSinkExec[[emp_no{f}, hire_date{f}, salary{f}],false] -\_ProjectExec[[emp_no{f}, hire_date{f}, salary{f}]] - \_FieldExtractExec[emp_no{f}, salary{f}]<[],[]> - \_TopNExec[[Order[hire_date{f},ASC,LAST]],20[INTEGER],36] - \_ExchangeSourceExec[[_doc{f}, hire_date{f}],false] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testPushedDownTopN/reduction_local_node_reduce.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testPushedDownTopN/reduction_local_node_reduce.expected deleted file mode 100644 index 787b72a5c8f72..0000000000000 --- a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testPushedDownTopN/reduction_local_node_reduce.expected +++ /dev/null @@ -1,5 +0,0 @@ -ExchangeSinkExec[[emp_no{f}, height{f}],false] -\_ProjectExec[[emp_no{f}, height{f}]] - \_FieldExtractExec[emp_no{f}]<[],[]> - \_TopNExec[[Order[height{f},ASC,LAST]],20[INTEGER],32] - \_ExchangeSourceExec[[_doc{f}, height{f}],false] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testSomeFieldsNeededBeforeLateMaterialization/reduction_local_node_reduce.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testSomeFieldsNeededBeforeLateMaterialization/reduction_local_node_reduce.expected deleted file mode 100644 index 23b988ef09a77..0000000000000 --- a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testSomeFieldsNeededBeforeLateMaterialization/reduction_local_node_reduce.expected +++ /dev/null @@ -1,5 +0,0 @@ -ExchangeSinkExec[[emp_no{f}, hire_date{f}, salary{f}],false] -\_ProjectExec[[emp_no{f}, hire_date{f}, salary{f}]] - \_FieldExtractExec[emp_no{f}]<[],[]> - \_TopNExec[[Order[hire_date{f},ASC,LAST]],20[INTEGER],36] - \_ExchangeSourceExec[[_doc{f}, salary{f}, hire_date{f}],false] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testTopNThenStats/reduction_local_node_reduce.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testTopNThenStats/reduction_local_node_reduce.expected deleted file mode 100644 index 89b94a06e2096..0000000000000 --- a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testTopNThenStats/reduction_local_node_reduce.expected +++ /dev/null @@ -1,5 +0,0 @@ -ExchangeSinkExec[[hire_date{f}, salary{f}],false] -\_ProjectExec[[hire_date{f}, salary{f}]] - \_FieldExtractExec[salary{f}]<[],[]> - \_TopNExec[[Order[hire_date{f},ASC,LAST]],20[INTEGER],32] - \_ExchangeSourceExec[[_doc{f}, hire_date{f}],false] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testTopNWithMissingSortField/reduction_local_node_reduce.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testTopNWithMissingSortField/reduction_local_node_reduce.expected deleted file mode 100644 index 378271a5e3f37..0000000000000 --- a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testTopNWithMissingSortField/reduction_local_node_reduce.expected +++ /dev/null @@ -1,5 +0,0 @@ -ExchangeSinkExec[[emp_no{f}, hire_date{f}, salary{f}],false] -\_ProjectExec[[emp_no{f}, hire_date{f}, salary{f}]] - \_FieldExtractExec[emp_no{f}, salary{f}]<[],[]> - \_TopNExec[[Order[hire_date{f},ASC,LAST]],20[INTEGER],36] - \_ExchangeSourceExec[[_doc{f}, hire_date{f}],false] \ No newline at end of file From f82a95a373915b7b8222f1aef8c5108d23f78b91 Mon Sep 17 00:00:00 2001 From: Gal Lalouche Date: Mon, 2 Feb 2026 20:24:21 +0200 Subject: [PATCH 08/25] More CR Fixes --- .../plugin/LateMaterializationPlanner.java | 1 + .../xpack/esql/optimizer/GoldenTestCase.java | 76 +++++++++++++------ ...LateMaterializationPlannerGoldenTests.java | 14 +++- ...hysical_optimization_data_driver.expected} | 0 ...local_reduce_planned_data_driver.expected} | 0 ...cal_reduce_planned_reduce_driver.expected} | 0 .../reduction_node_reduce.expected | 5 -- ...hysical_optimization_data_driver.expected} | 4 +- ...local_reduce_planned_data_driver.expected} | 4 +- ...ocal_reduce_planned_reduce_driver.expected | 5 ++ .../physical_optimization.expected | 6 +- .../query.esql | 4 + ...physical_optimization_data_driver.expected | 6 ++ .../local_reduce_planned_data_driver.expected | 6 ++ ...ocal_reduce_planned_reduce_driver.expected | 5 ++ .../physical_optimization.expected | 8 ++ .../query.esql | 0 ...hysical_optimization_data_driver.expected} | 0 ...local_reduce_planned_data_driver.expected} | 0 ...cal_reduce_planned_reduce_driver.expected} | 0 ...hysical_optimization_data_driver.expected} | 0 ...local_reduce_planned_data_driver.expected} | 0 ...cal_reduce_planned_reduce_driver.expected} | 0 ...hysical_optimization_data_driver.expected} | 0 ...local_reduce_planned_data_driver.expected} | 0 ...cal_reduce_planned_reduce_driver.expected} | 0 ...hysical_optimization_data_driver.expected} | 0 ...sical_optimization_reduce_driver.expected} | 0 ...local_reduce_planned_data_driver.expected} | 0 ...cal_reduce_planned_reduce_driver.expected} | 0 ...hysical_optimization_data_driver.expected} | 0 ...local_reduce_planned_data_driver.expected} | 0 ...cal_reduce_planned_reduce_driver.expected} | 0 ...hysical_optimization_data_driver.expected} | 0 ...local_reduce_planned_data_driver.expected} | 0 ...cal_reduce_planned_reduce_driver.expected} | 0 ...hysical_optimization_data_driver.expected} | 0 ...local_reduce_planned_data_driver.expected} | 0 ...cal_reduce_planned_reduce_driver.expected} | 0 ...hysical_optimization_data_driver.expected} | 0 ...local_reduce_planned_data_driver.expected} | 0 ...cal_reduce_planned_reduce_driver.expected} | 0 42 files changed, 108 insertions(+), 36 deletions(-) rename x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testBasicTopNLateMaterialization/{reduction_local_data.expected => local_reduce_physical_optimization_data_driver.expected} (100%) rename x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testBasicTopNLateMaterialization/{reduction_data.expected => local_reduce_planned_data_driver.expected} (100%) rename x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testBasicTopNLateMaterialization/{reduction_node_reduce.expected => local_reduce_planned_reduce_driver.expected} (100%) delete mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testExpressionSortTopN/reduction_node_reduce.expected rename x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/{testExpressionSortTopN/reduction_local_data.expected => testExpressionSortTopNKeepAfterSort/local_reduce_physical_optimization_data_driver.expected} (73%) rename x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/{testExpressionSortTopN/reduction_data.expected => testExpressionSortTopNKeepAfterSort/local_reduce_planned_data_driver.expected} (84%) create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testExpressionSortTopNKeepAfterSort/local_reduce_planned_reduce_driver.expected rename x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/{testExpressionSortTopN => testExpressionSortTopNKeepAfterSort}/physical_optimization.expected (81%) create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testExpressionSortTopNKeepAfterSort/query.esql create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testExpressionSortTopNKeepBeforeSort/local_reduce_physical_optimization_data_driver.expected create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testExpressionSortTopNKeepBeforeSort/local_reduce_planned_data_driver.expected create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testExpressionSortTopNKeepBeforeSort/local_reduce_planned_reduce_driver.expected create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testExpressionSortTopNKeepBeforeSort/physical_optimization.expected rename x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/{testExpressionSortTopN => testExpressionSortTopNKeepBeforeSort}/query.esql (100%) rename x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testLookupJoinOnDataNode/{reduction_local_data.expected => local_reduce_physical_optimization_data_driver.expected} (100%) rename x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testLookupJoinOnDataNode/{reduction_data.expected => local_reduce_planned_data_driver.expected} (100%) rename x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testLookupJoinOnDataNode/{reduction_node_reduce.expected => local_reduce_planned_reduce_driver.expected} (100%) rename x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testMultipleFieldSortTopN/{reduction_local_data.expected => local_reduce_physical_optimization_data_driver.expected} (100%) rename x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testMultipleFieldSortTopN/{reduction_data.expected => local_reduce_planned_data_driver.expected} (100%) rename x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testMultipleFieldSortTopN/{reduction_node_reduce.expected => local_reduce_planned_reduce_driver.expected} (100%) rename x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testMultipleTopN/{reduction_local_data.expected => local_reduce_physical_optimization_data_driver.expected} (100%) rename x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testMultipleTopN/{reduction_data.expected => local_reduce_planned_data_driver.expected} (100%) rename x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testMultipleTopN/{reduction_node_reduce.expected => local_reduce_planned_reduce_driver.expected} (100%) rename x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testMvExpandBeforeTopN/{reduction_local_data.expected => local_reduce_physical_optimization_data_driver.expected} (100%) rename x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testMvExpandBeforeTopN/{reduction_local_node_reduce.expected => local_reduce_physical_optimization_reduce_driver.expected} (100%) rename x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testMvExpandBeforeTopN/{reduction_data.expected => local_reduce_planned_data_driver.expected} (100%) rename x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testMvExpandBeforeTopN/{reduction_node_reduce.expected => local_reduce_planned_reduce_driver.expected} (100%) rename x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testPushedDownTopN/{reduction_local_data.expected => local_reduce_physical_optimization_data_driver.expected} (100%) rename x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testPushedDownTopN/{reduction_data.expected => local_reduce_planned_data_driver.expected} (100%) rename x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testPushedDownTopN/{reduction_node_reduce.expected => local_reduce_planned_reduce_driver.expected} (100%) rename x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testSomeFieldsNeededBeforeLateMaterialization/{reduction_local_data.expected => local_reduce_physical_optimization_data_driver.expected} (100%) rename x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testSomeFieldsNeededBeforeLateMaterialization/{reduction_data.expected => local_reduce_planned_data_driver.expected} (100%) rename x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testSomeFieldsNeededBeforeLateMaterialization/{reduction_node_reduce.expected => local_reduce_planned_reduce_driver.expected} (100%) rename x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testTopNThenStats/{reduction_local_data.expected => local_reduce_physical_optimization_data_driver.expected} (100%) rename x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testTopNThenStats/{reduction_data.expected => local_reduce_planned_data_driver.expected} (100%) rename x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testTopNThenStats/{reduction_node_reduce.expected => local_reduce_planned_reduce_driver.expected} (100%) rename x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testTopNWithMissingSortField/{reduction_local_data.expected => local_reduce_physical_optimization_data_driver.expected} (100%) rename x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testTopNWithMissingSortField/{reduction_data.expected => local_reduce_planned_data_driver.expected} (100%) rename x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testTopNWithMissingSortField/{reduction_node_reduce.expected => local_reduce_planned_reduce_driver.expected} (100%) diff --git a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/plugin/LateMaterializationPlanner.java b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/plugin/LateMaterializationPlanner.java index 678d3a7540242..6660fa9e4d843 100644 --- a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/plugin/LateMaterializationPlanner.java +++ b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/plugin/LateMaterializationPlanner.java @@ -128,6 +128,7 @@ public static Optional planReduceDriverTopN( } var updatedFragment = new Project(Source.EMPTY, withAddedDocToRelation, expectedDataOutput); FragmentExec updatedFragmentExec = fragmentExec.withFragment(updatedFragment); + // TODO This ignores the possible change in output, see #141654 ExchangeSinkExec updatedDataPlan = originalPlan.replaceChild(updatedFragmentExec); // Replace the TopN child with the data driver as the source. diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/optimizer/GoldenTestCase.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/optimizer/GoldenTestCase.java index 86b2be3329d1a..4976d5e1db864 100644 --- a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/optimizer/GoldenTestCase.java +++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/optimizer/GoldenTestCase.java @@ -9,6 +9,7 @@ import com.carrotsearch.randomizedtesting.annotations.Listeners; +import org.apache.lucene.tests.util.LuceneTestCase; import org.elasticsearch.TransportVersion; import org.elasticsearch.common.Strings; import org.elasticsearch.compute.operator.PlanTimeProfile; @@ -57,7 +58,6 @@ import java.util.ArrayList; import java.util.EnumSet; import java.util.List; -import java.util.Locale; import java.util.regex.Pattern; import java.util.stream.Collectors; @@ -68,6 +68,7 @@ /** See GoldenTestsReadme.md for more information about these tests. */ @Listeners({ GoldenTestCase.GoldenTestReproduceInfoPrinter.class }) +@LuceneTestCase.SuppressFileSystems("ExtrasFS") // ExtraFS can create extraneous files in the output directory. public abstract class GoldenTestCase extends ESTestCase { private static final Logger logger = LogManager.getLogger(GoldenTestCase.class); private final Path baseFile; @@ -226,7 +227,7 @@ private List> doTests() throws IOException { } if (stages.contains(Stage.PHYSICAL_OPTIMIZATION) || stages.contains(Stage.LOCAL_PHYSICAL_OPTIMIZATION) - || stages.contains(Stage.NODE_REDUCE_OPTIMIZATION) + || stages.contains(Stage.NODE_REDUCE) || stages.contains(Stage.NODE_REDUCE_LOCAL_PHYSICAL_OPTIMIZATION)) { var physicalPlanOptimizer = new PhysicalPlanOptimizer( new PhysicalOptimizerContext(EsqlTestUtils.TEST_CFG, transportVersion) @@ -242,7 +243,7 @@ private List> doTests() throws IOException { TestResult localPhysicalResult = verifyOrWrite(localOptimize(physicalPlan, conf), Stage.LOCAL_PHYSICAL_OPTIMIZATION); result.add(Tuple.tuple(Stage.LOCAL_PHYSICAL_OPTIMIZATION, localPhysicalResult)); } - if (stages.contains(Stage.NODE_REDUCE_OPTIMIZATION) || stages.contains(Stage.NODE_REDUCE_LOCAL_PHYSICAL_OPTIMIZATION)) { + if (stages.contains(Stage.NODE_REDUCE) || stages.contains(Stage.NODE_REDUCE_LOCAL_PHYSICAL_OPTIMIZATION)) { ExchangeExec exec = EsqlTestUtils.singleValue(physicalPlan.collect(ExchangeExec.class)); var sink = new ExchangeSinkExec(exec.source(), exec.output(), false, exec.child()); var reductionPlan = ComputeService.reductionPlan( @@ -256,16 +257,24 @@ private List> doTests() throws IOException { new PlanTimeProfile() ); - if (stages.contains(Stage.NODE_REDUCE_OPTIMIZATION)) { - result.addAll(addDualPlanResult(Stage.NODE_REDUCE_OPTIMIZATION, reductionPlan, "node_reduce", "data")); + if (stages.contains(Stage.NODE_REDUCE)) { + var dualFileOutput = (DualFileOutput) Stage.NODE_REDUCE.fileOutput; + result.addAll( + addDualPlanResult( + Stage.NODE_REDUCE, + reductionPlan, + dualFileOutput.nodeReduceOutput(), + dualFileOutput.dataNodeOutput() + ) + ); } - // FIXME(gal, NOCOMMIT) Simplify this, this shouldn't only perform the local optimization on the data plan. if (stages.contains(Stage.NODE_REDUCE_LOCAL_PHYSICAL_OPTIMIZATION)) { + var dualFileOutput = (DualFileOutput) Stage.NODE_REDUCE_LOCAL_PHYSICAL_OPTIMIZATION.fileOutput; switch (reductionPlan.nodeReduceLocalPhysicalOptimization()) { - // FIXME(gal, NOCOMMIT) document + // If there is no local node-reduce physical optimization, there's nothing to verify! case DISABLED -> { var foo = localOptimize(reductionPlan.dataNodePlan(), conf); - var bar = verifyOrWrite(foo, outputPath("reduction_", "local_data")); + var bar = verifyOrWrite(foo, outputPath(dualFileOutput.dataNodeOutput())); result.add(Tuple.tuple(Stage.NODE_REDUCE_LOCAL_PHYSICAL_OPTIMIZATION, bar)); } case ENABLED -> { @@ -278,8 +287,8 @@ private List> doTests() throws IOException { addDualPlanResult( Stage.NODE_REDUCE_LOCAL_PHYSICAL_OPTIMIZATION, finalizedResult, - "local_node_reduce", - "local_data" + dualFileOutput.nodeReduceOutput(), + dualFileOutput.dataNodeOutput() ) ); } @@ -302,8 +311,8 @@ private List> addDualPlanResult( String nodeReduceName, String dataNodeName ) throws IOException { - var reduceResult = verifyOrWrite(plan.nodeReducePlan(), outputPath("reduction_", nodeReduceName)); - var dataResult = verifyOrWrite(plan.dataNodePlan(), outputPath("reduction_", dataNodeName)); + var reduceResult = verifyOrWrite(plan.nodeReducePlan(), outputPath(nodeReduceName)); + var dataResult = verifyOrWrite(plan.dataNodePlan(), outputPath(dataNodeName)); var result = new ArrayList>(); if (reduceResult == TestResult.FAILURE || dataResult == TestResult.FAILURE) { result.add(Tuple.tuple(stage, TestResult.FAILURE)); @@ -340,14 +349,14 @@ private > TestResult verifyOrWrite(T plan, Path outputFil } private Path outputPath(Stage stage) { - return outputPath("", stage.name().toLowerCase(Locale.ROOT)); + return outputPath(((SingleFileOutput) stage.fileOutput).output()); } - private Path outputPath(String prefix, String suffix) { + private Path outputPath(String stageName) { var paths = new String[nestedPath.length + 2]; paths[0] = testName; System.arraycopy(nestedPath, 0, paths, 1, nestedPath.length); - paths[paths.length - 1] = Strings.format("%s%s.expected", prefix, suffix); + paths[paths.length - 1] = Strings.format("%s.expected", stageName); return PathUtils.get(basePath.toString(), paths); } @@ -365,6 +374,9 @@ private PhysicalPlan localOptimize(PhysicalPlan plan, Configuration conf) { } private static Test.TestResult createNewOutput(Path output, QueryPlan plan) throws IOException { + if (output.toString().contains("extra")) { + throw new IllegalStateException("Extra output files should not be created automatically:" + output); + } Files.writeString(output, toString(plan), StandardCharsets.UTF_8); return Test.TestResult.CREATED; } @@ -408,30 +420,50 @@ protected List filteredWarnings() { return withDefaultLimitWarning(super.filteredWarnings()); } + private sealed interface StageOutput {} + + private record SingleFileOutput(String output) implements StageOutput {} + + private record DualFileOutput(String nodeReduceOutput, String dataNodeOutput) implements StageOutput {} + protected enum Stage { /** See {@link Analyzer}. */ - ANALYSIS, + ANALYSIS(new SingleFileOutput("analysis")), /** See {@link LogicalPlanOptimizer}. */ - LOGICAL_OPTIMIZATION, + LOGICAL_OPTIMIZATION(new SingleFileOutput("logical_optimization")), /** See {@link PhysicalPlanOptimizer}. */ - PHYSICAL_OPTIMIZATION, + PHYSICAL_OPTIMIZATION(new SingleFileOutput("physical_optimization")), /** * See {@link LocalPhysicalPlanOptimizer}. There's no LOCAL_LOGICAL here since in production we use PlannerUtils.localPlan to * produce the local physical plan directly from non-local physical plan. */ - LOCAL_PHYSICAL_OPTIMIZATION, + LOCAL_PHYSICAL_OPTIMIZATION(new SingleFileOutput("local_physical_optimization")), /** * See {@link ComputeService#reductionPlan}. Actually results in two plans: one for the node reduce driver and one for the * data nodes. */ - NODE_REDUCE_OPTIMIZATION, + NODE_REDUCE(new DualFileOutput("local_reduce_planned_reduce_driver", "local_reduce_planned_data_driver")), /** - * A combination of {@link Stage#NODE_REDUCE_OPTIMIZATION} and {@link Stage#LOCAL_PHYSICAL_OPTIMIZATION}: first produce the node + * A combination of {@link Stage#NODE_REDUCE} and {@link Stage#LOCAL_PHYSICAL_OPTIMIZATION}: first produce the node * reduce and data node plans, and then perform local physical optimization on both. */ - NODE_REDUCE_LOCAL_PHYSICAL_OPTIMIZATION + NODE_REDUCE_LOCAL_PHYSICAL_OPTIMIZATION( + new DualFileOutput("local_reduce_physical_optimization_reduce_driver", "local_reduce_physical_optimization_data_driver") + ); + + private final StageOutput fileOutput; + + Stage(StageOutput fileOutput) { + this.fileOutput = fileOutput; + } } + private sealed interface TestOutput {} + + private record SingleTestOutput(String output) implements TestOutput {} + + private record DualTestOutput(String nodeReduceOutput, String dataNodeOutput) implements TestOutput {} + private static String normalize(String s) { return s.lines().map(String::strip).collect(Collectors.joining("\n")); } diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/plugin/LateMaterializationPlannerGoldenTests.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/plugin/LateMaterializationPlannerGoldenTests.java index c27e6de78f056..8c0f139aadc7a 100644 --- a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/plugin/LateMaterializationPlannerGoldenTests.java +++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/plugin/LateMaterializationPlannerGoldenTests.java @@ -16,7 +16,7 @@ public class LateMaterializationPlannerGoldenTests extends GoldenTestCase { private static final EnumSet STAGES = EnumSet.of( Stage.PHYSICAL_OPTIMIZATION, - Stage.NODE_REDUCE_OPTIMIZATION, + Stage.NODE_REDUCE, Stage.NODE_REDUCE_LOCAL_PHYSICAL_OPTIMIZATION ); @@ -63,7 +63,7 @@ public void testMultipleFieldSortTopN() throws Exception { runGoldenTest(query, STAGES, unindexedStats()); } - public void testExpressionSortTopN() throws Exception { + public void testExpressionSortTopNKeepBeforeSort() throws Exception { String query = """ FROM employees | keep hire_date, height @@ -73,6 +73,16 @@ public void testExpressionSortTopN() throws Exception { runGoldenTest(query, STAGES, unindexedStats()); } + public void testExpressionSortTopNKeepAfterSort() throws Exception { + String query = """ + FROM employees + | SORT sin(height) * 2 + | keep hire_date + | LIMIT 20 + """; + runGoldenTest(query, STAGES, unindexedStats()); + } + public void testPushedDownTopN() throws Exception { String query = """ FROM employees diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testBasicTopNLateMaterialization/reduction_local_data.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testBasicTopNLateMaterialization/local_reduce_physical_optimization_data_driver.expected similarity index 100% rename from x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testBasicTopNLateMaterialization/reduction_local_data.expected rename to x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testBasicTopNLateMaterialization/local_reduce_physical_optimization_data_driver.expected diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testBasicTopNLateMaterialization/reduction_data.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testBasicTopNLateMaterialization/local_reduce_planned_data_driver.expected similarity index 100% rename from x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testBasicTopNLateMaterialization/reduction_data.expected rename to x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testBasicTopNLateMaterialization/local_reduce_planned_data_driver.expected diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testBasicTopNLateMaterialization/reduction_node_reduce.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testBasicTopNLateMaterialization/local_reduce_planned_reduce_driver.expected similarity index 100% rename from x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testBasicTopNLateMaterialization/reduction_node_reduce.expected rename to x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testBasicTopNLateMaterialization/local_reduce_planned_reduce_driver.expected diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testExpressionSortTopN/reduction_node_reduce.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testExpressionSortTopN/reduction_node_reduce.expected deleted file mode 100644 index d23a70cf756e6..0000000000000 --- a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testExpressionSortTopN/reduction_node_reduce.expected +++ /dev/null @@ -1,5 +0,0 @@ -ExchangeSinkExec[[height{f}, hire_date{f}, $$order_by$0$0{r}],false] -\_ProjectExec[[height{f}, hire_date{f}, $$order_by$0$0{r}]] - \_FieldExtractExec[hire_date{f}]<[],[]> - \_TopNExec[[Order[$$order_by$0$0{r},ASC,LAST]],20[INTEGER],44] - \_ExchangeSourceExec[[_doc{f}, height{f}, $$order_by$0$0{r}],false] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testExpressionSortTopN/reduction_local_data.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testExpressionSortTopNKeepAfterSort/local_reduce_physical_optimization_data_driver.expected similarity index 73% rename from x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testExpressionSortTopN/reduction_local_data.expected rename to x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testExpressionSortTopNKeepAfterSort/local_reduce_physical_optimization_data_driver.expected index 843bf41435308..830cf56ade52d 100644 --- a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testExpressionSortTopN/reduction_local_data.expected +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testExpressionSortTopNKeepAfterSort/local_reduce_physical_optimization_data_driver.expected @@ -1,5 +1,5 @@ -ExchangeSinkExec[[height{f}, hire_date{f}, $$order_by$0$0{r}],false] -\_ProjectExec[[_doc{f}, height{f}, $$order_by$0$0{r}]] +ExchangeSinkExec[[hire_date{f}, $$order_by$0$0{r}],false] +\_ProjectExec[[_doc{f}, $$order_by$0$0{r}]] \_TopNExec[[Order[$$order_by$0$0{r},ASC,LAST]],20[INTEGER],36] \_EvalExec[[SIN(height{f}) * 2[INTEGER] AS $$order_by$0$0]] \_FieldExtractExec[height{f}]<[],[]> diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testExpressionSortTopN/reduction_data.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testExpressionSortTopNKeepAfterSort/local_reduce_planned_data_driver.expected similarity index 84% rename from x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testExpressionSortTopN/reduction_data.expected rename to x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testExpressionSortTopNKeepAfterSort/local_reduce_planned_data_driver.expected index 79ce101ea8de7..aa8139d1c1f41 100644 --- a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testExpressionSortTopN/reduction_data.expected +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testExpressionSortTopNKeepAfterSort/local_reduce_planned_data_driver.expected @@ -1,6 +1,6 @@ -ExchangeSinkExec[[height{f}, hire_date{f}, $$order_by$0$0{r}],false] +ExchangeSinkExec[[hire_date{f}, $$order_by$0$0{r}],false] \_FragmentExec[filter=null, estimatedRowSize=0, reducer=[], fragment=[<> -Project[[_doc{f}, height{f}, $$order_by$0$0{r}]] +Project[[_doc{f}, $$order_by$0$0{r}]] \_TopN[[Order[$$order_by$0$0{r},ASC,LAST]],20[INTEGER],false] \_Eval[[SIN(height{f}) * 2[INTEGER] AS $$order_by$0$0]] \_EsRelation[employees][_doc{f}, avg_worked_seconds{f}, birth_date{f}, emp_no{f}, first_name{f}, gender{f}, height{f}, height.float{f}, height.half_float{f}, height.scaled_float{f}, hire_date{f}, is_rehired{f}, job_positions{f}, languages{f}, languages.byte{f}, languages.long{f}, languages.short{f}, last_name{f}, salary{f}, salary_change{f}, salary_change.int{f}, salary_change.keyword{f}, salary_change.long{f}, still_hired{f}]<>]] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testExpressionSortTopNKeepAfterSort/local_reduce_planned_reduce_driver.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testExpressionSortTopNKeepAfterSort/local_reduce_planned_reduce_driver.expected new file mode 100644 index 0000000000000..c80d2a2b96cfe --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testExpressionSortTopNKeepAfterSort/local_reduce_planned_reduce_driver.expected @@ -0,0 +1,5 @@ +ExchangeSinkExec[[hire_date{f}, $$order_by$0$0{r}],false] +\_ProjectExec[[hire_date{f}, $$order_by$0$0{r}]] + \_FieldExtractExec[hire_date{f}]<[],[]> + \_TopNExec[[Order[$$order_by$0$0{r},ASC,LAST]],20[INTEGER],36] + \_ExchangeSourceExec[[_doc{f}, $$order_by$0$0{r}],false] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testExpressionSortTopN/physical_optimization.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testExpressionSortTopNKeepAfterSort/physical_optimization.expected similarity index 81% rename from x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testExpressionSortTopN/physical_optimization.expected rename to x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testExpressionSortTopNKeepAfterSort/physical_optimization.expected index 10cc006e32b1b..b0412e9185ba3 100644 --- a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testExpressionSortTopN/physical_optimization.expected +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testExpressionSortTopNKeepAfterSort/physical_optimization.expected @@ -1,8 +1,8 @@ -ProjectExec[[hire_date{f}, height{f}]] +ProjectExec[[hire_date{f}]] \_TopNExec[[Order[$$order_by$0$0{r},ASC,LAST]],20[INTEGER],null] - \_ExchangeExec[[height{f}, hire_date{f}, $$order_by$0$0{r}],false] + \_ExchangeExec[[hire_date{f}, $$order_by$0$0{r}],false] \_FragmentExec[filter=null, estimatedRowSize=0, reducer=[], fragment=[<> -Project[[height{f}, hire_date{f}, $$order_by$0$0{r}]] +Project[[hire_date{f}, $$order_by$0$0{r}]] \_TopN[[Order[$$order_by$0$0{r},ASC,LAST]],20[INTEGER],false] \_Eval[[SIN(height{f}) * 2[INTEGER] AS $$order_by$0$0]] \_EsRelation[employees][avg_worked_seconds{f}, birth_date{f}, emp_no{f}, first_name{f}, gender{f}, height{f}, height.float{f}, height.half_float{f}, height.scaled_float{f}, hire_date{f}, is_rehired{f}, job_positions{f}, languages{f}, languages.byte{f}, languages.long{f}, languages.short{f}, last_name{f}, salary{f}, salary_change{f}, salary_change.int{f}, salary_change.keyword{f}, salary_change.long{f}, still_hired{f}]<>]] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testExpressionSortTopNKeepAfterSort/query.esql b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testExpressionSortTopNKeepAfterSort/query.esql new file mode 100644 index 0000000000000..97b426ab3ee96 --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testExpressionSortTopNKeepAfterSort/query.esql @@ -0,0 +1,4 @@ +FROM employees +| SORT sin(height) * 2 +| keep hire_date +| LIMIT 20 diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testExpressionSortTopNKeepBeforeSort/local_reduce_physical_optimization_data_driver.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testExpressionSortTopNKeepBeforeSort/local_reduce_physical_optimization_data_driver.expected new file mode 100644 index 0000000000000..c3f5fe614747f --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testExpressionSortTopNKeepBeforeSort/local_reduce_physical_optimization_data_driver.expected @@ -0,0 +1,6 @@ +ExchangeSinkExec[[height{f}, hire_date{f}, $$order_by$0$1{r}],false] +\_ProjectExec[[_doc{f}, height{f}, $$order_by$0$1{r}]] + \_TopNExec[[Order[$$order_by$0$1{r},ASC,LAST]],20[INTEGER],36] + \_EvalExec[[SIN(height{f}) * 2[INTEGER] AS $$order_by$0$1]] + \_FieldExtractExec[height{f}]<[],[]> + \_EsQueryExec[employees], indexMode[standard], [_doc{f}], limit[], sort[] estimatedRowSize[20] queryBuilderAndTags [[QueryBuilderAndTags[query=null, tags=[]]]] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testExpressionSortTopNKeepBeforeSort/local_reduce_planned_data_driver.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testExpressionSortTopNKeepBeforeSort/local_reduce_planned_data_driver.expected new file mode 100644 index 0000000000000..7d646f2bfd4b7 --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testExpressionSortTopNKeepBeforeSort/local_reduce_planned_data_driver.expected @@ -0,0 +1,6 @@ +ExchangeSinkExec[[height{f}, hire_date{f}, $$order_by$0$1{r}],false] +\_FragmentExec[filter=null, estimatedRowSize=0, reducer=[], fragment=[<> +Project[[_doc{f}, height{f}, $$order_by$0$1{r}]] +\_TopN[[Order[$$order_by$0$1{r},ASC,LAST]],20[INTEGER],false] + \_Eval[[SIN(height{f}) * 2[INTEGER] AS $$order_by$0$1]] + \_EsRelation[employees][_doc{f}, avg_worked_seconds{f}, birth_date{f}, emp_no{f}, first_name{f}, gender{f}, height{f}, height.float{f}, height.half_float{f}, height.scaled_float{f}, hire_date{f}, is_rehired{f}, job_positions{f}, languages{f}, languages.byte{f}, languages.long{f}, languages.short{f}, last_name{f}, salary{f}, salary_change{f}, salary_change.int{f}, salary_change.keyword{f}, salary_change.long{f}, still_hired{f}]<>]] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testExpressionSortTopNKeepBeforeSort/local_reduce_planned_reduce_driver.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testExpressionSortTopNKeepBeforeSort/local_reduce_planned_reduce_driver.expected new file mode 100644 index 0000000000000..4eb53127fc9c8 --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testExpressionSortTopNKeepBeforeSort/local_reduce_planned_reduce_driver.expected @@ -0,0 +1,5 @@ +ExchangeSinkExec[[height{f}, hire_date{f}, $$order_by$0$1{r}],false] +\_ProjectExec[[height{f}, hire_date{f}, $$order_by$0$1{r}]] + \_FieldExtractExec[hire_date{f}]<[],[]> + \_TopNExec[[Order[$$order_by$0$1{r},ASC,LAST]],20[INTEGER],44] + \_ExchangeSourceExec[[_doc{f}, height{f}, $$order_by$0$1{r}],false] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testExpressionSortTopNKeepBeforeSort/physical_optimization.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testExpressionSortTopNKeepBeforeSort/physical_optimization.expected new file mode 100644 index 0000000000000..12d0908ec7c1d --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testExpressionSortTopNKeepBeforeSort/physical_optimization.expected @@ -0,0 +1,8 @@ +ProjectExec[[hire_date{f}, height{f}]] +\_TopNExec[[Order[$$order_by$0$1{r},ASC,LAST]],20[INTEGER],null] + \_ExchangeExec[[height{f}, hire_date{f}, $$order_by$0$1{r}],false] + \_FragmentExec[filter=null, estimatedRowSize=0, reducer=[], fragment=[<> +Project[[height{f}, hire_date{f}, $$order_by$0$1{r}]] +\_TopN[[Order[$$order_by$0$1{r},ASC,LAST]],20[INTEGER],false] + \_Eval[[SIN(height{f}) * 2[INTEGER] AS $$order_by$0$1]] + \_EsRelation[employees][avg_worked_seconds{f}, birth_date{f}, emp_no{f}, first_name{f}, gender{f}, height{f}, height.float{f}, height.half_float{f}, height.scaled_float{f}, hire_date{f}, is_rehired{f}, job_positions{f}, languages{f}, languages.byte{f}, languages.long{f}, languages.short{f}, last_name{f}, salary{f}, salary_change{f}, salary_change.int{f}, salary_change.keyword{f}, salary_change.long{f}, still_hired{f}]<>]] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testExpressionSortTopN/query.esql b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testExpressionSortTopNKeepBeforeSort/query.esql similarity index 100% rename from x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testExpressionSortTopN/query.esql rename to x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testExpressionSortTopNKeepBeforeSort/query.esql diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testLookupJoinOnDataNode/reduction_local_data.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testLookupJoinOnDataNode/local_reduce_physical_optimization_data_driver.expected similarity index 100% rename from x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testLookupJoinOnDataNode/reduction_local_data.expected rename to x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testLookupJoinOnDataNode/local_reduce_physical_optimization_data_driver.expected diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testLookupJoinOnDataNode/reduction_data.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testLookupJoinOnDataNode/local_reduce_planned_data_driver.expected similarity index 100% rename from x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testLookupJoinOnDataNode/reduction_data.expected rename to x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testLookupJoinOnDataNode/local_reduce_planned_data_driver.expected diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testLookupJoinOnDataNode/reduction_node_reduce.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testLookupJoinOnDataNode/local_reduce_planned_reduce_driver.expected similarity index 100% rename from x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testLookupJoinOnDataNode/reduction_node_reduce.expected rename to x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testLookupJoinOnDataNode/local_reduce_planned_reduce_driver.expected diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testMultipleFieldSortTopN/reduction_local_data.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testMultipleFieldSortTopN/local_reduce_physical_optimization_data_driver.expected similarity index 100% rename from x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testMultipleFieldSortTopN/reduction_local_data.expected rename to x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testMultipleFieldSortTopN/local_reduce_physical_optimization_data_driver.expected diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testMultipleFieldSortTopN/reduction_data.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testMultipleFieldSortTopN/local_reduce_planned_data_driver.expected similarity index 100% rename from x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testMultipleFieldSortTopN/reduction_data.expected rename to x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testMultipleFieldSortTopN/local_reduce_planned_data_driver.expected diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testMultipleFieldSortTopN/reduction_node_reduce.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testMultipleFieldSortTopN/local_reduce_planned_reduce_driver.expected similarity index 100% rename from x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testMultipleFieldSortTopN/reduction_node_reduce.expected rename to x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testMultipleFieldSortTopN/local_reduce_planned_reduce_driver.expected diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testMultipleTopN/reduction_local_data.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testMultipleTopN/local_reduce_physical_optimization_data_driver.expected similarity index 100% rename from x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testMultipleTopN/reduction_local_data.expected rename to x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testMultipleTopN/local_reduce_physical_optimization_data_driver.expected diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testMultipleTopN/reduction_data.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testMultipleTopN/local_reduce_planned_data_driver.expected similarity index 100% rename from x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testMultipleTopN/reduction_data.expected rename to x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testMultipleTopN/local_reduce_planned_data_driver.expected diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testMultipleTopN/reduction_node_reduce.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testMultipleTopN/local_reduce_planned_reduce_driver.expected similarity index 100% rename from x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testMultipleTopN/reduction_node_reduce.expected rename to x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testMultipleTopN/local_reduce_planned_reduce_driver.expected diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testMvExpandBeforeTopN/reduction_local_data.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testMvExpandBeforeTopN/local_reduce_physical_optimization_data_driver.expected similarity index 100% rename from x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testMvExpandBeforeTopN/reduction_local_data.expected rename to x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testMvExpandBeforeTopN/local_reduce_physical_optimization_data_driver.expected diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testMvExpandBeforeTopN/reduction_local_node_reduce.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testMvExpandBeforeTopN/local_reduce_physical_optimization_reduce_driver.expected similarity index 100% rename from x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testMvExpandBeforeTopN/reduction_local_node_reduce.expected rename to x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testMvExpandBeforeTopN/local_reduce_physical_optimization_reduce_driver.expected diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testMvExpandBeforeTopN/reduction_data.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testMvExpandBeforeTopN/local_reduce_planned_data_driver.expected similarity index 100% rename from x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testMvExpandBeforeTopN/reduction_data.expected rename to x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testMvExpandBeforeTopN/local_reduce_planned_data_driver.expected diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testMvExpandBeforeTopN/reduction_node_reduce.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testMvExpandBeforeTopN/local_reduce_planned_reduce_driver.expected similarity index 100% rename from x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testMvExpandBeforeTopN/reduction_node_reduce.expected rename to x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testMvExpandBeforeTopN/local_reduce_planned_reduce_driver.expected diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testPushedDownTopN/reduction_local_data.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testPushedDownTopN/local_reduce_physical_optimization_data_driver.expected similarity index 100% rename from x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testPushedDownTopN/reduction_local_data.expected rename to x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testPushedDownTopN/local_reduce_physical_optimization_data_driver.expected diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testPushedDownTopN/reduction_data.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testPushedDownTopN/local_reduce_planned_data_driver.expected similarity index 100% rename from x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testPushedDownTopN/reduction_data.expected rename to x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testPushedDownTopN/local_reduce_planned_data_driver.expected diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testPushedDownTopN/reduction_node_reduce.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testPushedDownTopN/local_reduce_planned_reduce_driver.expected similarity index 100% rename from x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testPushedDownTopN/reduction_node_reduce.expected rename to x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testPushedDownTopN/local_reduce_planned_reduce_driver.expected diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testSomeFieldsNeededBeforeLateMaterialization/reduction_local_data.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testSomeFieldsNeededBeforeLateMaterialization/local_reduce_physical_optimization_data_driver.expected similarity index 100% rename from x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testSomeFieldsNeededBeforeLateMaterialization/reduction_local_data.expected rename to x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testSomeFieldsNeededBeforeLateMaterialization/local_reduce_physical_optimization_data_driver.expected diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testSomeFieldsNeededBeforeLateMaterialization/reduction_data.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testSomeFieldsNeededBeforeLateMaterialization/local_reduce_planned_data_driver.expected similarity index 100% rename from x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testSomeFieldsNeededBeforeLateMaterialization/reduction_data.expected rename to x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testSomeFieldsNeededBeforeLateMaterialization/local_reduce_planned_data_driver.expected diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testSomeFieldsNeededBeforeLateMaterialization/reduction_node_reduce.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testSomeFieldsNeededBeforeLateMaterialization/local_reduce_planned_reduce_driver.expected similarity index 100% rename from x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testSomeFieldsNeededBeforeLateMaterialization/reduction_node_reduce.expected rename to x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testSomeFieldsNeededBeforeLateMaterialization/local_reduce_planned_reduce_driver.expected diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testTopNThenStats/reduction_local_data.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testTopNThenStats/local_reduce_physical_optimization_data_driver.expected similarity index 100% rename from x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testTopNThenStats/reduction_local_data.expected rename to x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testTopNThenStats/local_reduce_physical_optimization_data_driver.expected diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testTopNThenStats/reduction_data.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testTopNThenStats/local_reduce_planned_data_driver.expected similarity index 100% rename from x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testTopNThenStats/reduction_data.expected rename to x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testTopNThenStats/local_reduce_planned_data_driver.expected diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testTopNThenStats/reduction_node_reduce.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testTopNThenStats/local_reduce_planned_reduce_driver.expected similarity index 100% rename from x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testTopNThenStats/reduction_node_reduce.expected rename to x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testTopNThenStats/local_reduce_planned_reduce_driver.expected diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testTopNWithMissingSortField/reduction_local_data.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testTopNWithMissingSortField/local_reduce_physical_optimization_data_driver.expected similarity index 100% rename from x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testTopNWithMissingSortField/reduction_local_data.expected rename to x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testTopNWithMissingSortField/local_reduce_physical_optimization_data_driver.expected diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testTopNWithMissingSortField/reduction_data.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testTopNWithMissingSortField/local_reduce_planned_data_driver.expected similarity index 100% rename from x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testTopNWithMissingSortField/reduction_data.expected rename to x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testTopNWithMissingSortField/local_reduce_planned_data_driver.expected diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testTopNWithMissingSortField/reduction_node_reduce.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testTopNWithMissingSortField/local_reduce_planned_reduce_driver.expected similarity index 100% rename from x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testTopNWithMissingSortField/reduction_node_reduce.expected rename to x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testTopNWithMissingSortField/local_reduce_planned_reduce_driver.expected From a0eace366b2eec777fe4c05436109fa82d497a97 Mon Sep 17 00:00:00 2001 From: Gal Lalouche Date: Mon, 2 Feb 2026 21:52:36 +0200 Subject: [PATCH 09/25] Fix bug with synthetic names --- .../xpack/esql/optimizer/GoldenTestCase.java | 7 ++++++- ...l_reduce_physical_optimization_data_driver.expected | 8 ++++---- .../local_reduce_planned_data_driver.expected | 8 ++++---- .../local_reduce_planned_reduce_driver.expected | 8 ++++---- .../physical_optimization.expected | 10 +++++----- ...l_reduce_physical_optimization_data_driver.expected | 8 ++++---- .../local_reduce_planned_data_driver.expected | 8 ++++---- .../local_reduce_planned_reduce_driver.expected | 8 ++++---- .../physical_optimization.expected | 10 +++++----- 9 files changed, 40 insertions(+), 35 deletions(-) diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/optimizer/GoldenTestCase.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/optimizer/GoldenTestCase.java index 4976d5e1db864..483582f999214 100644 --- a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/optimizer/GoldenTestCase.java +++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/optimizer/GoldenTestCase.java @@ -382,9 +382,14 @@ private static Test.TestResult createNewOutput(Path output, QueryPlan plan) t } private static String toString(Node plan) { - return IDENTIFIER_PATTERN.matcher(plan.toString(Node.NodeStringFormat.FULL)).replaceAll(""); + String planString = plan.toString(Node.NodeStringFormat.FULL); + String withoutSyntheticPatterns = SYNTHETIC_PATTERN.matcher(planString).replaceAll("\\$\\$$1"); + return IDENTIFIER_PATTERN.matcher(withoutSyntheticPatterns).replaceAll(""); } + // Matches synthetic names like $$alias$1$2#3, since those $digits are generated during the test run and may differ each time. The + // #digit are removed by the next pattern. + private static final Pattern SYNTHETIC_PATTERN = Pattern.compile("\\$\\$([^$\\s]+)(\\$\\d+)*(?=[{#])"); private static final Pattern IDENTIFIER_PATTERN = Pattern.compile("#\\d+"); private static Test.TestResult verifyExisting(Path output, QueryPlan plan) throws IOException { diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testExpressionSortTopNKeepAfterSort/local_reduce_physical_optimization_data_driver.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testExpressionSortTopNKeepAfterSort/local_reduce_physical_optimization_data_driver.expected index 830cf56ade52d..6c0cb294fc861 100644 --- a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testExpressionSortTopNKeepAfterSort/local_reduce_physical_optimization_data_driver.expected +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testExpressionSortTopNKeepAfterSort/local_reduce_physical_optimization_data_driver.expected @@ -1,6 +1,6 @@ -ExchangeSinkExec[[hire_date{f}, $$order_by$0$0{r}],false] -\_ProjectExec[[_doc{f}, $$order_by$0$0{r}]] - \_TopNExec[[Order[$$order_by$0$0{r},ASC,LAST]],20[INTEGER],36] - \_EvalExec[[SIN(height{f}) * 2[INTEGER] AS $$order_by$0$0]] +ExchangeSinkExec[[hire_date{f}, $$order_by{r}],false] +\_ProjectExec[[_doc{f}, $$order_by{r}]] + \_TopNExec[[Order[$$order_by{r},ASC,LAST]],20[INTEGER],36] + \_EvalExec[[SIN(height{f}) * 2[INTEGER] AS $$order_by]] \_FieldExtractExec[height{f}]<[],[]> \_EsQueryExec[employees], indexMode[standard], [_doc{f}], limit[], sort[] estimatedRowSize[20] queryBuilderAndTags [[QueryBuilderAndTags[query=null, tags=[]]]] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testExpressionSortTopNKeepAfterSort/local_reduce_planned_data_driver.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testExpressionSortTopNKeepAfterSort/local_reduce_planned_data_driver.expected index aa8139d1c1f41..2c2c810fdcd5f 100644 --- a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testExpressionSortTopNKeepAfterSort/local_reduce_planned_data_driver.expected +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testExpressionSortTopNKeepAfterSort/local_reduce_planned_data_driver.expected @@ -1,6 +1,6 @@ -ExchangeSinkExec[[hire_date{f}, $$order_by$0$0{r}],false] +ExchangeSinkExec[[hire_date{f}, $$order_by{r}],false] \_FragmentExec[filter=null, estimatedRowSize=0, reducer=[], fragment=[<> -Project[[_doc{f}, $$order_by$0$0{r}]] -\_TopN[[Order[$$order_by$0$0{r},ASC,LAST]],20[INTEGER],false] - \_Eval[[SIN(height{f}) * 2[INTEGER] AS $$order_by$0$0]] +Project[[_doc{f}, $$order_by{r}]] +\_TopN[[Order[$$order_by{r},ASC,LAST]],20[INTEGER],false] + \_Eval[[SIN(height{f}) * 2[INTEGER] AS $$order_by]] \_EsRelation[employees][_doc{f}, avg_worked_seconds{f}, birth_date{f}, emp_no{f}, first_name{f}, gender{f}, height{f}, height.float{f}, height.half_float{f}, height.scaled_float{f}, hire_date{f}, is_rehired{f}, job_positions{f}, languages{f}, languages.byte{f}, languages.long{f}, languages.short{f}, last_name{f}, salary{f}, salary_change{f}, salary_change.int{f}, salary_change.keyword{f}, salary_change.long{f}, still_hired{f}]<>]] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testExpressionSortTopNKeepAfterSort/local_reduce_planned_reduce_driver.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testExpressionSortTopNKeepAfterSort/local_reduce_planned_reduce_driver.expected index c80d2a2b96cfe..6122b8f73ddfa 100644 --- a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testExpressionSortTopNKeepAfterSort/local_reduce_planned_reduce_driver.expected +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testExpressionSortTopNKeepAfterSort/local_reduce_planned_reduce_driver.expected @@ -1,5 +1,5 @@ -ExchangeSinkExec[[hire_date{f}, $$order_by$0$0{r}],false] -\_ProjectExec[[hire_date{f}, $$order_by$0$0{r}]] +ExchangeSinkExec[[hire_date{f}, $$order_by{r}],false] +\_ProjectExec[[hire_date{f}, $$order_by{r}]] \_FieldExtractExec[hire_date{f}]<[],[]> - \_TopNExec[[Order[$$order_by$0$0{r},ASC,LAST]],20[INTEGER],36] - \_ExchangeSourceExec[[_doc{f}, $$order_by$0$0{r}],false] \ No newline at end of file + \_TopNExec[[Order[$$order_by{r},ASC,LAST]],20[INTEGER],36] + \_ExchangeSourceExec[[_doc{f}, $$order_by{r}],false] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testExpressionSortTopNKeepAfterSort/physical_optimization.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testExpressionSortTopNKeepAfterSort/physical_optimization.expected index b0412e9185ba3..379de6ff82e29 100644 --- a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testExpressionSortTopNKeepAfterSort/physical_optimization.expected +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testExpressionSortTopNKeepAfterSort/physical_optimization.expected @@ -1,8 +1,8 @@ ProjectExec[[hire_date{f}]] -\_TopNExec[[Order[$$order_by$0$0{r},ASC,LAST]],20[INTEGER],null] - \_ExchangeExec[[hire_date{f}, $$order_by$0$0{r}],false] +\_TopNExec[[Order[$$order_by{r},ASC,LAST]],20[INTEGER],null] + \_ExchangeExec[[hire_date{f}, $$order_by{r}],false] \_FragmentExec[filter=null, estimatedRowSize=0, reducer=[], fragment=[<> -Project[[hire_date{f}, $$order_by$0$0{r}]] -\_TopN[[Order[$$order_by$0$0{r},ASC,LAST]],20[INTEGER],false] - \_Eval[[SIN(height{f}) * 2[INTEGER] AS $$order_by$0$0]] +Project[[hire_date{f}, $$order_by{r}]] +\_TopN[[Order[$$order_by{r},ASC,LAST]],20[INTEGER],false] + \_Eval[[SIN(height{f}) * 2[INTEGER] AS $$order_by]] \_EsRelation[employees][avg_worked_seconds{f}, birth_date{f}, emp_no{f}, first_name{f}, gender{f}, height{f}, height.float{f}, height.half_float{f}, height.scaled_float{f}, hire_date{f}, is_rehired{f}, job_positions{f}, languages{f}, languages.byte{f}, languages.long{f}, languages.short{f}, last_name{f}, salary{f}, salary_change{f}, salary_change.int{f}, salary_change.keyword{f}, salary_change.long{f}, still_hired{f}]<>]] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testExpressionSortTopNKeepBeforeSort/local_reduce_physical_optimization_data_driver.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testExpressionSortTopNKeepBeforeSort/local_reduce_physical_optimization_data_driver.expected index c3f5fe614747f..abec74e514128 100644 --- a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testExpressionSortTopNKeepBeforeSort/local_reduce_physical_optimization_data_driver.expected +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testExpressionSortTopNKeepBeforeSort/local_reduce_physical_optimization_data_driver.expected @@ -1,6 +1,6 @@ -ExchangeSinkExec[[height{f}, hire_date{f}, $$order_by$0$1{r}],false] -\_ProjectExec[[_doc{f}, height{f}, $$order_by$0$1{r}]] - \_TopNExec[[Order[$$order_by$0$1{r},ASC,LAST]],20[INTEGER],36] - \_EvalExec[[SIN(height{f}) * 2[INTEGER] AS $$order_by$0$1]] +ExchangeSinkExec[[height{f}, hire_date{f}, $$order_by{r}],false] +\_ProjectExec[[_doc{f}, height{f}, $$order_by{r}]] + \_TopNExec[[Order[$$order_by{r},ASC,LAST]],20[INTEGER],36] + \_EvalExec[[SIN(height{f}) * 2[INTEGER] AS $$order_by]] \_FieldExtractExec[height{f}]<[],[]> \_EsQueryExec[employees], indexMode[standard], [_doc{f}], limit[], sort[] estimatedRowSize[20] queryBuilderAndTags [[QueryBuilderAndTags[query=null, tags=[]]]] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testExpressionSortTopNKeepBeforeSort/local_reduce_planned_data_driver.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testExpressionSortTopNKeepBeforeSort/local_reduce_planned_data_driver.expected index 7d646f2bfd4b7..d6d06ec07d272 100644 --- a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testExpressionSortTopNKeepBeforeSort/local_reduce_planned_data_driver.expected +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testExpressionSortTopNKeepBeforeSort/local_reduce_planned_data_driver.expected @@ -1,6 +1,6 @@ -ExchangeSinkExec[[height{f}, hire_date{f}, $$order_by$0$1{r}],false] +ExchangeSinkExec[[height{f}, hire_date{f}, $$order_by{r}],false] \_FragmentExec[filter=null, estimatedRowSize=0, reducer=[], fragment=[<> -Project[[_doc{f}, height{f}, $$order_by$0$1{r}]] -\_TopN[[Order[$$order_by$0$1{r},ASC,LAST]],20[INTEGER],false] - \_Eval[[SIN(height{f}) * 2[INTEGER] AS $$order_by$0$1]] +Project[[_doc{f}, height{f}, $$order_by{r}]] +\_TopN[[Order[$$order_by{r},ASC,LAST]],20[INTEGER],false] + \_Eval[[SIN(height{f}) * 2[INTEGER] AS $$order_by]] \_EsRelation[employees][_doc{f}, avg_worked_seconds{f}, birth_date{f}, emp_no{f}, first_name{f}, gender{f}, height{f}, height.float{f}, height.half_float{f}, height.scaled_float{f}, hire_date{f}, is_rehired{f}, job_positions{f}, languages{f}, languages.byte{f}, languages.long{f}, languages.short{f}, last_name{f}, salary{f}, salary_change{f}, salary_change.int{f}, salary_change.keyword{f}, salary_change.long{f}, still_hired{f}]<>]] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testExpressionSortTopNKeepBeforeSort/local_reduce_planned_reduce_driver.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testExpressionSortTopNKeepBeforeSort/local_reduce_planned_reduce_driver.expected index 4eb53127fc9c8..e19d24b8b2b9f 100644 --- a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testExpressionSortTopNKeepBeforeSort/local_reduce_planned_reduce_driver.expected +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testExpressionSortTopNKeepBeforeSort/local_reduce_planned_reduce_driver.expected @@ -1,5 +1,5 @@ -ExchangeSinkExec[[height{f}, hire_date{f}, $$order_by$0$1{r}],false] -\_ProjectExec[[height{f}, hire_date{f}, $$order_by$0$1{r}]] +ExchangeSinkExec[[height{f}, hire_date{f}, $$order_by{r}],false] +\_ProjectExec[[height{f}, hire_date{f}, $$order_by{r}]] \_FieldExtractExec[hire_date{f}]<[],[]> - \_TopNExec[[Order[$$order_by$0$1{r},ASC,LAST]],20[INTEGER],44] - \_ExchangeSourceExec[[_doc{f}, height{f}, $$order_by$0$1{r}],false] \ No newline at end of file + \_TopNExec[[Order[$$order_by{r},ASC,LAST]],20[INTEGER],44] + \_ExchangeSourceExec[[_doc{f}, height{f}, $$order_by{r}],false] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testExpressionSortTopNKeepBeforeSort/physical_optimization.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testExpressionSortTopNKeepBeforeSort/physical_optimization.expected index 12d0908ec7c1d..dd1f613d8bedf 100644 --- a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testExpressionSortTopNKeepBeforeSort/physical_optimization.expected +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testExpressionSortTopNKeepBeforeSort/physical_optimization.expected @@ -1,8 +1,8 @@ ProjectExec[[hire_date{f}, height{f}]] -\_TopNExec[[Order[$$order_by$0$1{r},ASC,LAST]],20[INTEGER],null] - \_ExchangeExec[[height{f}, hire_date{f}, $$order_by$0$1{r}],false] +\_TopNExec[[Order[$$order_by{r},ASC,LAST]],20[INTEGER],null] + \_ExchangeExec[[height{f}, hire_date{f}, $$order_by{r}],false] \_FragmentExec[filter=null, estimatedRowSize=0, reducer=[], fragment=[<> -Project[[height{f}, hire_date{f}, $$order_by$0$1{r}]] -\_TopN[[Order[$$order_by$0$1{r},ASC,LAST]],20[INTEGER],false] - \_Eval[[SIN(height{f}) * 2[INTEGER] AS $$order_by$0$1]] +Project[[height{f}, hire_date{f}, $$order_by{r}]] +\_TopN[[Order[$$order_by{r},ASC,LAST]],20[INTEGER],false] + \_Eval[[SIN(height{f}) * 2[INTEGER] AS $$order_by]] \_EsRelation[employees][avg_worked_seconds{f}, birth_date{f}, emp_no{f}, first_name{f}, gender{f}, height{f}, height.float{f}, height.half_float{f}, height.scaled_float{f}, hire_date{f}, is_rehired{f}, job_positions{f}, languages{f}, languages.byte{f}, languages.long{f}, languages.short{f}, last_name{f}, salary{f}, salary_change{f}, salary_change.int{f}, salary_change.keyword{f}, salary_change.long{f}, still_hired{f}]<>]] \ No newline at end of file From 5fec441c9624682415375d20e7de531ae4b6843d Mon Sep 17 00:00:00 2001 From: Gal Lalouche Date: Tue, 3 Feb 2026 14:41:51 +0200 Subject: [PATCH 10/25] Add name IDs --- .../xpack/esql/optimizer/GoldenTestCase.java | 62 ++++++++++++++++--- .../local_physical_optimization.expected | 26 ++++---- .../local_physical_optimization.expected | 26 ++++---- .../local_physical_optimization.expected | 26 ++++---- .../local_physical_optimization.expected | 18 +++--- .../local_physical_optimization.expected | 18 +++--- .../local_physical_optimization.expected | 18 +++--- .../local_physical_optimization.expected | 8 +-- .../local_physical_optimization.expected | 8 +-- .../local_physical_optimization.expected | 8 +-- .../local_physical_optimization.expected | 8 +-- .../local_physical_optimization.expected | 8 +-- .../local_physical_optimization.expected | 8 +-- .../local_physical_optimization.expected | 12 ++-- .../local_physical_optimization.expected | 12 ++-- .../local_physical_optimization.expected | 12 ++-- .../local_physical_optimization.expected | 8 +-- .../local_physical_optimization.expected | 10 +-- .../local_physical_optimization.expected | 10 +-- .../local_physical_optimization.expected | 8 +-- .../local_physical_optimization.expected | 10 +-- .../local_physical_optimization.expected | 10 +-- .../local_physical_optimization.expected | 8 +-- .../local_physical_optimization.expected | 10 +-- .../local_physical_optimization.expected | 10 +-- .../local_physical_optimization.expected | 12 ++-- .../local_physical_optimization.expected | 12 ++-- .../local_physical_optimization.expected | 12 ++-- .../local_physical_optimization.expected | 14 ++--- .../local_physical_optimization.expected | 14 ++--- .../local_physical_optimization.expected | 36 +++++------ .../byte/local_physical_optimization.expected | 8 +-- .../date/local_physical_optimization.expected | 8 +-- .../local_physical_optimization.expected | 8 +-- .../local_physical_optimization.expected | 8 +-- .../local_physical_optimization.expected | 8 +-- .../local_physical_optimization.expected | 8 +-- .../local_physical_optimization.expected | 8 +-- .../long/local_physical_optimization.expected | 8 +-- .../local_physical_optimization.expected | 8 +-- .../local_physical_optimization.expected | 8 +-- .../local_physical_optimization.expected | 26 ++++---- ...physical_optimization_data_driver.expected | 8 +-- .../local_reduce_planned_data_driver.expected | 8 +-- ...ocal_reduce_planned_reduce_driver.expected | 10 +-- .../physical_optimization.expected | 12 ++-- ...physical_optimization_data_driver.expected | 12 ++-- .../local_reduce_planned_data_driver.expected | 10 +-- ...ocal_reduce_planned_reduce_driver.expected | 10 +-- .../physical_optimization.expected | 14 ++--- ...physical_optimization_data_driver.expected | 12 ++-- .../local_reduce_planned_data_driver.expected | 10 +-- ...ocal_reduce_planned_reduce_driver.expected | 10 +-- .../physical_optimization.expected | 14 ++--- ...physical_optimization_data_driver.expected | 18 +++--- .../local_reduce_planned_data_driver.expected | 16 ++--- ...ocal_reduce_planned_reduce_driver.expected | 10 +-- .../physical_optimization.expected | 18 +++--- ...physical_optimization_data_driver.expected | 8 +-- .../local_reduce_planned_data_driver.expected | 8 +-- ...ocal_reduce_planned_reduce_driver.expected | 10 +-- .../physical_optimization.expected | 12 ++-- ...physical_optimization_data_driver.expected | 8 +-- .../local_reduce_planned_data_driver.expected | 8 +-- ...ocal_reduce_planned_reduce_driver.expected | 10 +-- .../physical_optimization.expected | 14 ++--- ...physical_optimization_data_driver.expected | 14 ++--- ...ysical_optimization_reduce_driver.expected | 6 +- .../local_reduce_planned_data_driver.expected | 12 ++-- ...ocal_reduce_planned_reduce_driver.expected | 6 +- .../physical_optimization.expected | 14 ++--- ...physical_optimization_data_driver.expected | 8 +-- .../local_reduce_planned_data_driver.expected | 8 +-- ...ocal_reduce_planned_reduce_driver.expected | 10 +-- .../physical_optimization.expected | 12 ++-- ...physical_optimization_data_driver.expected | 8 +-- .../local_reduce_planned_data_driver.expected | 10 +-- ...ocal_reduce_planned_reduce_driver.expected | 10 +-- .../physical_optimization.expected | 14 ++--- ...physical_optimization_data_driver.expected | 8 +-- .../local_reduce_planned_data_driver.expected | 8 +-- ...ocal_reduce_planned_reduce_driver.expected | 10 +-- .../physical_optimization.expected | 16 ++--- ...physical_optimization_data_driver.expected | 8 +-- .../local_reduce_planned_data_driver.expected | 8 +-- ...ocal_reduce_planned_reduce_driver.expected | 10 +-- .../physical_optimization.expected | 12 ++-- 87 files changed, 547 insertions(+), 503 deletions(-) diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/optimizer/GoldenTestCase.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/optimizer/GoldenTestCase.java index 483582f999214..e6f833bad54c6 100644 --- a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/optimizer/GoldenTestCase.java +++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/optimizer/GoldenTestCase.java @@ -28,6 +28,7 @@ import org.elasticsearch.xpack.esql.analysis.UnmappedResolution; import org.elasticsearch.xpack.esql.core.expression.FoldContext; import org.elasticsearch.xpack.esql.core.tree.Node; +import org.elasticsearch.xpack.esql.core.util.Holder; import org.elasticsearch.xpack.esql.expression.function.EsqlFunctionRegistry; import org.elasticsearch.xpack.esql.inference.InferenceResolution; import org.elasticsearch.xpack.esql.parser.EsqlParser; @@ -57,7 +58,10 @@ import java.nio.file.Path; import java.util.ArrayList; import java.util.EnumSet; +import java.util.HashMap; import java.util.List; +import java.util.Map; +import java.util.regex.Matcher; import java.util.regex.Pattern; import java.util.stream.Collectors; @@ -377,23 +381,63 @@ private static Test.TestResult createNewOutput(Path output, QueryPlan plan) t if (output.toString().contains("extra")) { throw new IllegalStateException("Extra output files should not be created automatically:" + output); } - Files.writeString(output, toString(plan), StandardCharsets.UTF_8); + Files.writeString(output, normalizeNameIds(plan), StandardCharsets.UTF_8); return Test.TestResult.CREATED; } - private static String toString(Node plan) { - String planString = plan.toString(Node.NodeStringFormat.FULL); - String withoutSyntheticPatterns = SYNTHETIC_PATTERN.matcher(planString).replaceAll("\\$\\$$1"); - return IDENTIFIER_PATTERN.matcher(withoutSyntheticPatterns).replaceAll(""); + private static String normalizeNameIds(Node plan) { + String full = plan.toString(Node.NodeStringFormat.FULL); + // full = normalizeSyntheticNames(full); + Matcher matcher = IDENTIFIER_PATTERN.matcher(full); + StringBuilder sb = new StringBuilder(); + int lastEnd = 0; + Holder counterHolder = new Holder<>(0); + Map idMap = new HashMap<>(); + while (matcher.find()) { + sb.append(full, lastEnd, matcher.start()); + int originalId = Integer.parseInt(matcher.group().substring(1)); // Drop the initial '#' prefix + int newId = idMap.computeIfAbsent(originalId, k -> { + int current = counterHolder.get(); + counterHolder.set(current + 1); + return current; + }); + sb.append("#").append(newId); + lastEnd = matcher.end(); + } + sb.append(full, lastEnd, full.length()); + return sb.toString(); + } + + /** + * Normalizes synthetic attribute names of the form $$something($something)* that are followed by # (node id). + * Replaces them with $$firstSegment$runningInt so golden output is stable across runs. + */ + private static String normalizeSyntheticNames(String full) { + Matcher matcher = SYNTHETIC_PATTERN.matcher(full); + StringBuilder sb = new StringBuilder(); + int lastEnd = 0; + Holder runningInt = new Holder<>(0); + Map idMap = new HashMap<>(); + while (matcher.find()) { + sb.append(full, lastEnd, matcher.start()); + String firstSegment = matcher.group(1); + int newId = idMap.computeIfAbsent(firstSegment, k -> { + int current = runningInt.get(); + runningInt.set(current + 1); + return current; + }); + sb.append("$$").append(firstSegment).append("$").append(newId); + lastEnd = matcher.end(); + } + sb.append(full, lastEnd, full.length()); + return sb.toString(); } - // Matches synthetic names like $$alias$1$2#3, since those $digits are generated during the test run and may differ each time. The - // #digit are removed by the next pattern. - private static final Pattern SYNTHETIC_PATTERN = Pattern.compile("\\$\\$([^$\\s]+)(\\$\\d+)*(?=[{#])"); + private static final Pattern SYNTHETIC_PATTERN = Pattern.compile("\\$\\$([^$\\s]+)(\\$\\d+)+(?=[{#])"); private static final Pattern IDENTIFIER_PATTERN = Pattern.compile("#\\d+"); private static Test.TestResult verifyExisting(Path output, QueryPlan plan) throws IOException { - String testString = normalize(toString(plan)); + String testString = normalize(normalizeNameIds(plan)); if (testString.equals(normalize(Files.readString(output)))) { if (System.getProperty("golden.cleanactual") != null) { Path path = actualPath(output); diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testDateTruncBucketNotTransformToQueryAndTagsWithFork/bucket/local_physical_optimization.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testDateTruncBucketNotTransformToQueryAndTagsWithFork/bucket/local_physical_optimization.expected index 961fe3106b9dd..504e54c3064ee 100644 --- a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testDateTruncBucketNotTransformToQueryAndTagsWithFork/bucket/local_physical_optimization.expected +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testDateTruncBucketNotTransformToQueryAndTagsWithFork/bucket/local_physical_optimization.expected @@ -1,13 +1,13 @@ LimitExec[1000[INTEGER],null] -\_AggregateExec[[x{r}],[COUNT(*[KEYWORD],true[BOOLEAN],PT0S[TIME_DURATION]) AS count(*), x{r}],SINGLE,[x{r}, $$count(*)$count{r}, $$count(*)$seen{r}],null] - \_EvalExec[[BUCKET(date{r},P1D[DATE_PERIOD]) AS x]] - \_MergeExec[[date{r}]] - |_ProjectExec[[date{f}]] +\_AggregateExec[[x{r}#0],[COUNT(*[KEYWORD],true[BOOLEAN],PT0S[TIME_DURATION]) AS count(*)#1, x{r}#0],SINGLE,[x{r}#0, $$count(*)$count{r}#2, $$count(*)$seen{r}#3],null] + \_EvalExec[[BUCKET(date{r}#4,P1D[DATE_PERIOD]) AS x#0]] + \_MergeExec[[date{r}#4]] + |_ProjectExec[[date{f}#5]] | \_LimitExec[1000[INTEGER],null] - | \_ExchangeExec[[date{f}],false] - | \_ProjectExec[[date{f}]] - | \_FieldExtractExec[date{f}]<[],[]> - | \_EsQueryExec[all_types], indexMode[standard], [_doc{f}], limit[1000], sort[] estimatedRowSize[12] queryBuilderAndTags [[QueryBuilderAndTags[query={ + | \_ExchangeExec[[date{f}#5],false] + | \_ProjectExec[[date{f}#5]] + | \_FieldExtractExec[date{f}#5]<[],[]> + | \_EsQueryExec[all_types], indexMode[standard], [_doc{f}#6], limit[1000], sort[] estimatedRowSize[12] queryBuilderAndTags [[QueryBuilderAndTags[query={ "esql_single_value" : { "field" : "integer", "next" : { @@ -21,12 +21,12 @@ LimitExec[1000[INTEGER],null] "source" : "integer > 100@2:15" } }, tags=[]]]] - \_ProjectExec[[date{f}]] + \_ProjectExec[[date{f}#7]] \_LimitExec[1000[INTEGER],null] - \_ExchangeExec[[date{f}],false] - \_ProjectExec[[date{f}]] - \_FieldExtractExec[date{f}]<[],[]> - \_EsQueryExec[all_types], indexMode[standard], [_doc{f}], limit[1000], sort[] estimatedRowSize[12] queryBuilderAndTags [[QueryBuilderAndTags[query={ + \_ExchangeExec[[date{f}#7],false] + \_ProjectExec[[date{f}#7]] + \_FieldExtractExec[date{f}#7]<[],[]> + \_EsQueryExec[all_types], indexMode[standard], [_doc{f}#8], limit[1000], sort[] estimatedRowSize[12] queryBuilderAndTags [[QueryBuilderAndTags[query={ "match" : { "keyword" : { "query" : "keyword", diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testDateTruncBucketNotTransformToQueryAndTagsWithFork/date_trunc/local_physical_optimization.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testDateTruncBucketNotTransformToQueryAndTagsWithFork/date_trunc/local_physical_optimization.expected index 427b439ba70cb..72dbdcc974f68 100644 --- a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testDateTruncBucketNotTransformToQueryAndTagsWithFork/date_trunc/local_physical_optimization.expected +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testDateTruncBucketNotTransformToQueryAndTagsWithFork/date_trunc/local_physical_optimization.expected @@ -1,13 +1,13 @@ LimitExec[1000[INTEGER],null] -\_AggregateExec[[x{r}],[COUNT(*[KEYWORD],true[BOOLEAN],PT0S[TIME_DURATION]) AS count(*), x{r}],SINGLE,[x{r}, $$count(*)$count{r}, $$count(*)$seen{r}],null] - \_EvalExec[[DATETRUNC(P1D[DATE_PERIOD],date{r}) AS x]] - \_MergeExec[[date{r}]] - |_ProjectExec[[date{f}]] +\_AggregateExec[[x{r}#0],[COUNT(*[KEYWORD],true[BOOLEAN],PT0S[TIME_DURATION]) AS count(*)#1, x{r}#0],SINGLE,[x{r}#0, $$count(*)$count{r}#2, $$count(*)$seen{r}#3],null] + \_EvalExec[[DATETRUNC(P1D[DATE_PERIOD],date{r}#4) AS x#0]] + \_MergeExec[[date{r}#4]] + |_ProjectExec[[date{f}#5]] | \_LimitExec[1000[INTEGER],null] - | \_ExchangeExec[[date{f}],false] - | \_ProjectExec[[date{f}]] - | \_FieldExtractExec[date{f}]<[],[]> - | \_EsQueryExec[all_types], indexMode[standard], [_doc{f}], limit[1000], sort[] estimatedRowSize[12] queryBuilderAndTags [[QueryBuilderAndTags[query={ + | \_ExchangeExec[[date{f}#5],false] + | \_ProjectExec[[date{f}#5]] + | \_FieldExtractExec[date{f}#5]<[],[]> + | \_EsQueryExec[all_types], indexMode[standard], [_doc{f}#6], limit[1000], sort[] estimatedRowSize[12] queryBuilderAndTags [[QueryBuilderAndTags[query={ "esql_single_value" : { "field" : "integer", "next" : { @@ -21,12 +21,12 @@ LimitExec[1000[INTEGER],null] "source" : "integer > 100@2:15" } }, tags=[]]]] - \_ProjectExec[[date{f}]] + \_ProjectExec[[date{f}#7]] \_LimitExec[1000[INTEGER],null] - \_ExchangeExec[[date{f}],false] - \_ProjectExec[[date{f}]] - \_FieldExtractExec[date{f}]<[],[]> - \_EsQueryExec[all_types], indexMode[standard], [_doc{f}], limit[1000], sort[] estimatedRowSize[12] queryBuilderAndTags [[QueryBuilderAndTags[query={ + \_ExchangeExec[[date{f}#7],false] + \_ProjectExec[[date{f}#7]] + \_FieldExtractExec[date{f}#7]<[],[]> + \_EsQueryExec[all_types], indexMode[standard], [_doc{f}#8], limit[1000], sort[] estimatedRowSize[12] queryBuilderAndTags [[QueryBuilderAndTags[query={ "match" : { "keyword" : { "query" : "keyword", diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testDateTruncBucketNotTransformToQueryAndTagsWithFork/round_to/local_physical_optimization.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testDateTruncBucketNotTransformToQueryAndTagsWithFork/round_to/local_physical_optimization.expected index 668bab853e771..5c5cb8da952c2 100644 --- a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testDateTruncBucketNotTransformToQueryAndTagsWithFork/round_to/local_physical_optimization.expected +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testDateTruncBucketNotTransformToQueryAndTagsWithFork/round_to/local_physical_optimization.expected @@ -1,13 +1,13 @@ LimitExec[1000[INTEGER],null] -\_AggregateExec[[x{r}],[COUNT(*[KEYWORD],true[BOOLEAN],PT0S[TIME_DURATION]) AS count(*), x{r}],SINGLE,[x{r}, $$count(*)$count{r}, $$count(*)$seen{r}],null] - \_EvalExec[[ROUNDTO(date{r},1697760000000[DATETIME],1697846400000[DATETIME],1697932800000[DATETIME],1698019200000[DATETIME]) AS x]] - \_MergeExec[[date{r}]] - |_ProjectExec[[date{f}]] +\_AggregateExec[[x{r}#0],[COUNT(*[KEYWORD],true[BOOLEAN],PT0S[TIME_DURATION]) AS count(*)#1, x{r}#0],SINGLE,[x{r}#0, $$count(*)$count{r}#2, $$count(*)$seen{r}#3],null] + \_EvalExec[[ROUNDTO(date{r}#4,1697760000000[DATETIME],1697846400000[DATETIME],1697932800000[DATETIME],1698019200000[DATETIME]) AS x#0]] + \_MergeExec[[date{r}#4]] + |_ProjectExec[[date{f}#5]] | \_LimitExec[1000[INTEGER],null] - | \_ExchangeExec[[date{f}],false] - | \_ProjectExec[[date{f}]] - | \_FieldExtractExec[date{f}]<[],[]> - | \_EsQueryExec[all_types], indexMode[standard], [_doc{f}], limit[1000], sort[] estimatedRowSize[12] queryBuilderAndTags [[QueryBuilderAndTags[query={ + | \_ExchangeExec[[date{f}#5],false] + | \_ProjectExec[[date{f}#5]] + | \_FieldExtractExec[date{f}#5]<[],[]> + | \_EsQueryExec[all_types], indexMode[standard], [_doc{f}#6], limit[1000], sort[] estimatedRowSize[12] queryBuilderAndTags [[QueryBuilderAndTags[query={ "esql_single_value" : { "field" : "integer", "next" : { @@ -21,12 +21,12 @@ LimitExec[1000[INTEGER],null] "source" : "integer > 100@2:15" } }, tags=[]]]] - \_ProjectExec[[date{f}]] + \_ProjectExec[[date{f}#7]] \_LimitExec[1000[INTEGER],null] - \_ExchangeExec[[date{f}],false] - \_ProjectExec[[date{f}]] - \_FieldExtractExec[date{f}]<[],[]> - \_EsQueryExec[all_types], indexMode[standard], [_doc{f}], limit[1000], sort[] estimatedRowSize[12] queryBuilderAndTags [[QueryBuilderAndTags[query={ + \_ExchangeExec[[date{f}#7],false] + \_ProjectExec[[date{f}#7]] + \_FieldExtractExec[date{f}#7]<[],[]> + \_EsQueryExec[all_types], indexMode[standard], [_doc{f}#8], limit[1000], sort[] estimatedRowSize[12] queryBuilderAndTags [[QueryBuilderAndTags[query={ "match" : { "keyword" : { "query" : "keyword", diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testDateTruncBucketNotTransformToQueryAndTagsWithLookupJoin/bucket/local_physical_optimization.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testDateTruncBucketNotTransformToQueryAndTagsWithLookupJoin/bucket/local_physical_optimization.expected index 474d85c27e113..37d5c04ccc89b 100644 --- a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testDateTruncBucketNotTransformToQueryAndTagsWithLookupJoin/bucket/local_physical_optimization.expected +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testDateTruncBucketNotTransformToQueryAndTagsWithLookupJoin/bucket/local_physical_optimization.expected @@ -1,11 +1,11 @@ LimitExec[1000[INTEGER],null] -\_AggregateExec[[x{r}],[COUNT(*[KEYWORD],true[BOOLEAN],PT0S[TIME_DURATION]) AS count(*), x{r}],FINAL,[x{r}, $$count(*)$count{r}, $$count(*)$seen{r}],null] - \_ExchangeExec[[x{r}, $$count(*)$count{r}, $$count(*)$seen{r}],true] - \_AggregateExec[[x{r}],[COUNT(*[KEYWORD],true[BOOLEAN],PT0S[TIME_DURATION]) AS count(*), x{r}],INITIAL,[x{r}, $$count(*)$count{r}, $$count(*)$seen{r}],16] - \_EvalExec[[ROUNDTO(date{f},1697760000000[DATETIME],1697846400000[DATETIME],1697932800000[DATETIME],1698019200000[DATETIME]) AS x]] - \_FieldExtractExec[date{f}]<[],[]> - \_LookupJoinExec[[integer{f}],[language_code{f}],[],null] - |_FieldExtractExec[integer{f}]<[],[]> - | \_EsQueryExec[all_types], indexMode[standard], [_doc{f}], limit[], sort[] estimatedRowSize[24] queryBuilderAndTags [[QueryBuilderAndTags[query=null, tags=[]]]] +\_AggregateExec[[x{r}#0],[COUNT(*[KEYWORD],true[BOOLEAN],PT0S[TIME_DURATION]) AS count(*)#1, x{r}#0],FINAL,[x{r}#0, $$count(*)$count{r}#2, $$count(*)$seen{r}#3],null] + \_ExchangeExec[[x{r}#0, $$count(*)$count{r}#2, $$count(*)$seen{r}#3],true] + \_AggregateExec[[x{r}#0],[COUNT(*[KEYWORD],true[BOOLEAN],PT0S[TIME_DURATION]) AS count(*)#1, x{r}#0],INITIAL,[x{r}#0, $$count(*)$count{r}#4, $$count(*)$seen{r}#5],16] + \_EvalExec[[ROUNDTO(date{f}#6,1697760000000[DATETIME],1697846400000[DATETIME],1697932800000[DATETIME],1698019200000[DATETIME]) AS x#0]] + \_FieldExtractExec[date{f}#6]<[],[]> + \_LookupJoinExec[[integer{f}#7],[language_code{f}#8],[],null] + |_FieldExtractExec[integer{f}#7]<[],[]> + | \_EsQueryExec[all_types], indexMode[standard], [_doc{f}#9], limit[], sort[] estimatedRowSize[24] queryBuilderAndTags [[QueryBuilderAndTags[query=null, tags=[]]]] \_FragmentExec[filter=null, estimatedRowSize=0, reducer=[], fragment=[<> -EsRelation[languages_lookup][LOOKUP][language_code{f}]<>]] \ No newline at end of file +EsRelation[languages_lookup][LOOKUP][language_code{f}#8]<>]] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testDateTruncBucketNotTransformToQueryAndTagsWithLookupJoin/date_trunc/local_physical_optimization.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testDateTruncBucketNotTransformToQueryAndTagsWithLookupJoin/date_trunc/local_physical_optimization.expected index 474d85c27e113..37d5c04ccc89b 100644 --- a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testDateTruncBucketNotTransformToQueryAndTagsWithLookupJoin/date_trunc/local_physical_optimization.expected +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testDateTruncBucketNotTransformToQueryAndTagsWithLookupJoin/date_trunc/local_physical_optimization.expected @@ -1,11 +1,11 @@ LimitExec[1000[INTEGER],null] -\_AggregateExec[[x{r}],[COUNT(*[KEYWORD],true[BOOLEAN],PT0S[TIME_DURATION]) AS count(*), x{r}],FINAL,[x{r}, $$count(*)$count{r}, $$count(*)$seen{r}],null] - \_ExchangeExec[[x{r}, $$count(*)$count{r}, $$count(*)$seen{r}],true] - \_AggregateExec[[x{r}],[COUNT(*[KEYWORD],true[BOOLEAN],PT0S[TIME_DURATION]) AS count(*), x{r}],INITIAL,[x{r}, $$count(*)$count{r}, $$count(*)$seen{r}],16] - \_EvalExec[[ROUNDTO(date{f},1697760000000[DATETIME],1697846400000[DATETIME],1697932800000[DATETIME],1698019200000[DATETIME]) AS x]] - \_FieldExtractExec[date{f}]<[],[]> - \_LookupJoinExec[[integer{f}],[language_code{f}],[],null] - |_FieldExtractExec[integer{f}]<[],[]> - | \_EsQueryExec[all_types], indexMode[standard], [_doc{f}], limit[], sort[] estimatedRowSize[24] queryBuilderAndTags [[QueryBuilderAndTags[query=null, tags=[]]]] +\_AggregateExec[[x{r}#0],[COUNT(*[KEYWORD],true[BOOLEAN],PT0S[TIME_DURATION]) AS count(*)#1, x{r}#0],FINAL,[x{r}#0, $$count(*)$count{r}#2, $$count(*)$seen{r}#3],null] + \_ExchangeExec[[x{r}#0, $$count(*)$count{r}#2, $$count(*)$seen{r}#3],true] + \_AggregateExec[[x{r}#0],[COUNT(*[KEYWORD],true[BOOLEAN],PT0S[TIME_DURATION]) AS count(*)#1, x{r}#0],INITIAL,[x{r}#0, $$count(*)$count{r}#4, $$count(*)$seen{r}#5],16] + \_EvalExec[[ROUNDTO(date{f}#6,1697760000000[DATETIME],1697846400000[DATETIME],1697932800000[DATETIME],1698019200000[DATETIME]) AS x#0]] + \_FieldExtractExec[date{f}#6]<[],[]> + \_LookupJoinExec[[integer{f}#7],[language_code{f}#8],[],null] + |_FieldExtractExec[integer{f}#7]<[],[]> + | \_EsQueryExec[all_types], indexMode[standard], [_doc{f}#9], limit[], sort[] estimatedRowSize[24] queryBuilderAndTags [[QueryBuilderAndTags[query=null, tags=[]]]] \_FragmentExec[filter=null, estimatedRowSize=0, reducer=[], fragment=[<> -EsRelation[languages_lookup][LOOKUP][language_code{f}]<>]] \ No newline at end of file +EsRelation[languages_lookup][LOOKUP][language_code{f}#8]<>]] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testDateTruncBucketNotTransformToQueryAndTagsWithLookupJoin/round_to/local_physical_optimization.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testDateTruncBucketNotTransformToQueryAndTagsWithLookupJoin/round_to/local_physical_optimization.expected index 474d85c27e113..37d5c04ccc89b 100644 --- a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testDateTruncBucketNotTransformToQueryAndTagsWithLookupJoin/round_to/local_physical_optimization.expected +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testDateTruncBucketNotTransformToQueryAndTagsWithLookupJoin/round_to/local_physical_optimization.expected @@ -1,11 +1,11 @@ LimitExec[1000[INTEGER],null] -\_AggregateExec[[x{r}],[COUNT(*[KEYWORD],true[BOOLEAN],PT0S[TIME_DURATION]) AS count(*), x{r}],FINAL,[x{r}, $$count(*)$count{r}, $$count(*)$seen{r}],null] - \_ExchangeExec[[x{r}, $$count(*)$count{r}, $$count(*)$seen{r}],true] - \_AggregateExec[[x{r}],[COUNT(*[KEYWORD],true[BOOLEAN],PT0S[TIME_DURATION]) AS count(*), x{r}],INITIAL,[x{r}, $$count(*)$count{r}, $$count(*)$seen{r}],16] - \_EvalExec[[ROUNDTO(date{f},1697760000000[DATETIME],1697846400000[DATETIME],1697932800000[DATETIME],1698019200000[DATETIME]) AS x]] - \_FieldExtractExec[date{f}]<[],[]> - \_LookupJoinExec[[integer{f}],[language_code{f}],[],null] - |_FieldExtractExec[integer{f}]<[],[]> - | \_EsQueryExec[all_types], indexMode[standard], [_doc{f}], limit[], sort[] estimatedRowSize[24] queryBuilderAndTags [[QueryBuilderAndTags[query=null, tags=[]]]] +\_AggregateExec[[x{r}#0],[COUNT(*[KEYWORD],true[BOOLEAN],PT0S[TIME_DURATION]) AS count(*)#1, x{r}#0],FINAL,[x{r}#0, $$count(*)$count{r}#2, $$count(*)$seen{r}#3],null] + \_ExchangeExec[[x{r}#0, $$count(*)$count{r}#2, $$count(*)$seen{r}#3],true] + \_AggregateExec[[x{r}#0],[COUNT(*[KEYWORD],true[BOOLEAN],PT0S[TIME_DURATION]) AS count(*)#1, x{r}#0],INITIAL,[x{r}#0, $$count(*)$count{r}#4, $$count(*)$seen{r}#5],16] + \_EvalExec[[ROUNDTO(date{f}#6,1697760000000[DATETIME],1697846400000[DATETIME],1697932800000[DATETIME],1698019200000[DATETIME]) AS x#0]] + \_FieldExtractExec[date{f}#6]<[],[]> + \_LookupJoinExec[[integer{f}#7],[language_code{f}#8],[],null] + |_FieldExtractExec[integer{f}#7]<[],[]> + | \_EsQueryExec[all_types], indexMode[standard], [_doc{f}#9], limit[], sort[] estimatedRowSize[24] queryBuilderAndTags [[QueryBuilderAndTags[query=null, tags=[]]]] \_FragmentExec[filter=null, estimatedRowSize=0, reducer=[], fragment=[<> -EsRelation[languages_lookup][LOOKUP][language_code{f}]<>]] \ No newline at end of file +EsRelation[languages_lookup][LOOKUP][language_code{f}#8]<>]] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testDateTruncBucketTransformToQueryAndTags/bucket/local_physical_optimization.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testDateTruncBucketTransformToQueryAndTags/bucket/local_physical_optimization.expected index ef1ef15736930..452b37138c025 100644 --- a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testDateTruncBucketTransformToQueryAndTags/bucket/local_physical_optimization.expected +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testDateTruncBucketTransformToQueryAndTags/bucket/local_physical_optimization.expected @@ -1,7 +1,7 @@ LimitExec[1000[INTEGER],null] -\_AggregateExec[[x{r}],[COUNT(*[KEYWORD],true[BOOLEAN],PT0S[TIME_DURATION]) AS count(*), x{r}],FINAL,[x{r}, $$count(*)$count{r}, $$count(*)$seen{r}],null] - \_ExchangeExec[[x{r}, $$count(*)$count{r}, $$count(*)$seen{r}],true] - \_FilterExec[$$count(*)$count{r} > 0[LONG]] +\_AggregateExec[[x{r}#0],[COUNT(*[KEYWORD],true[BOOLEAN],PT0S[TIME_DURATION]) AS count(*)#1, x{r}#0],FINAL,[x{r}#0, $$count(*)$count{r}#2, $$count(*)$seen{r}#3],null] + \_ExchangeExec[[x{r}#0, $$count(*)$count{r}#2, $$count(*)$seen{r}#3],true] + \_FilterExec[$$count(*)$count{r}#4 > 0[LONG]] \_EsStatsQueryExec[all_types], statsByStat{queryBuilderAndTags=[QueryBuilderAndTags[query={ "esql_single_value" : { "field" : "date", @@ -76,4 +76,4 @@ LimitExec[1000[INTEGER],null] ], "boost" : 1.0 } -}, tags=[null]]]}], query[][x{r}, $$count(*)$count{r}, $$count(*)$seen{r}], limit[], \ No newline at end of file +}, tags=[null]]]}], query[][x{r}#0, $$count(*)$count{r}#4, $$count(*)$seen{r}#5], limit[], \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testDateTruncBucketTransformToQueryAndTags/date_trunc/local_physical_optimization.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testDateTruncBucketTransformToQueryAndTags/date_trunc/local_physical_optimization.expected index f5a5c391169bb..b1eba3348e69d 100644 --- a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testDateTruncBucketTransformToQueryAndTags/date_trunc/local_physical_optimization.expected +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testDateTruncBucketTransformToQueryAndTags/date_trunc/local_physical_optimization.expected @@ -1,7 +1,7 @@ LimitExec[1000[INTEGER],null] -\_AggregateExec[[x{r}],[COUNT(*[KEYWORD],true[BOOLEAN],PT0S[TIME_DURATION]) AS count(*), x{r}],FINAL,[x{r}, $$count(*)$count{r}, $$count(*)$seen{r}],null] - \_ExchangeExec[[x{r}, $$count(*)$count{r}, $$count(*)$seen{r}],true] - \_FilterExec[$$count(*)$count{r} > 0[LONG]] +\_AggregateExec[[x{r}#0],[COUNT(*[KEYWORD],true[BOOLEAN],PT0S[TIME_DURATION]) AS count(*)#1, x{r}#0],FINAL,[x{r}#0, $$count(*)$count{r}#2, $$count(*)$seen{r}#3],null] + \_ExchangeExec[[x{r}#0, $$count(*)$count{r}#2, $$count(*)$seen{r}#3],true] + \_FilterExec[$$count(*)$count{r}#4 > 0[LONG]] \_EsStatsQueryExec[all_types], statsByStat{queryBuilderAndTags=[QueryBuilderAndTags[query={ "esql_single_value" : { "field" : "date", @@ -76,4 +76,4 @@ LimitExec[1000[INTEGER],null] ], "boost" : 1.0 } -}, tags=[null]]]}], query[][x{r}, $$count(*)$count{r}, $$count(*)$seen{r}], limit[], \ No newline at end of file +}, tags=[null]]]}], query[][x{r}#0, $$count(*)$count{r}#4, $$count(*)$seen{r}#5], limit[], \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testDateTruncBucketTransformToQueryAndTags/round_to/local_physical_optimization.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testDateTruncBucketTransformToQueryAndTags/round_to/local_physical_optimization.expected index cf999b9b04435..ee48e2b81fe3e 100644 --- a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testDateTruncBucketTransformToQueryAndTags/round_to/local_physical_optimization.expected +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testDateTruncBucketTransformToQueryAndTags/round_to/local_physical_optimization.expected @@ -1,7 +1,7 @@ LimitExec[1000[INTEGER],null] -\_AggregateExec[[x{r}],[COUNT(*[KEYWORD],true[BOOLEAN],PT0S[TIME_DURATION]) AS count(*), x{r}],FINAL,[x{r}, $$count(*)$count{r}, $$count(*)$seen{r}],null] - \_ExchangeExec[[x{r}, $$count(*)$count{r}, $$count(*)$seen{r}],true] - \_FilterExec[$$count(*)$count{r} > 0[LONG]] +\_AggregateExec[[x{r}#0],[COUNT(*[KEYWORD],true[BOOLEAN],PT0S[TIME_DURATION]) AS count(*)#1, x{r}#0],FINAL,[x{r}#0, $$count(*)$count{r}#2, $$count(*)$seen{r}#3],null] + \_ExchangeExec[[x{r}#0, $$count(*)$count{r}#2, $$count(*)$seen{r}#3],true] + \_FilterExec[$$count(*)$count{r}#4 > 0[LONG]] \_EsStatsQueryExec[all_types], statsByStat{queryBuilderAndTags=[QueryBuilderAndTags[query={ "esql_single_value" : { "field" : "date", @@ -76,4 +76,4 @@ LimitExec[1000[INTEGER],null] ], "boost" : 1.0 } -}, tags=[null]]]}], query[][x{r}, $$count(*)$count{r}, $$count(*)$seen{r}], limit[], \ No newline at end of file +}, tags=[null]]]}], query[][x{r}#0, $$count(*)$count{r}#4, $$count(*)$seen{r}#5], limit[], \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testDateTruncBucketTransformToQueryAndTagsWithEsFilter/bucket/local_physical_optimization.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testDateTruncBucketTransformToQueryAndTagsWithEsFilter/bucket/local_physical_optimization.expected index ef1ef15736930..452b37138c025 100644 --- a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testDateTruncBucketTransformToQueryAndTagsWithEsFilter/bucket/local_physical_optimization.expected +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testDateTruncBucketTransformToQueryAndTagsWithEsFilter/bucket/local_physical_optimization.expected @@ -1,7 +1,7 @@ LimitExec[1000[INTEGER],null] -\_AggregateExec[[x{r}],[COUNT(*[KEYWORD],true[BOOLEAN],PT0S[TIME_DURATION]) AS count(*), x{r}],FINAL,[x{r}, $$count(*)$count{r}, $$count(*)$seen{r}],null] - \_ExchangeExec[[x{r}, $$count(*)$count{r}, $$count(*)$seen{r}],true] - \_FilterExec[$$count(*)$count{r} > 0[LONG]] +\_AggregateExec[[x{r}#0],[COUNT(*[KEYWORD],true[BOOLEAN],PT0S[TIME_DURATION]) AS count(*)#1, x{r}#0],FINAL,[x{r}#0, $$count(*)$count{r}#2, $$count(*)$seen{r}#3],null] + \_ExchangeExec[[x{r}#0, $$count(*)$count{r}#2, $$count(*)$seen{r}#3],true] + \_FilterExec[$$count(*)$count{r}#4 > 0[LONG]] \_EsStatsQueryExec[all_types], statsByStat{queryBuilderAndTags=[QueryBuilderAndTags[query={ "esql_single_value" : { "field" : "date", @@ -76,4 +76,4 @@ LimitExec[1000[INTEGER],null] ], "boost" : 1.0 } -}, tags=[null]]]}], query[][x{r}, $$count(*)$count{r}, $$count(*)$seen{r}], limit[], \ No newline at end of file +}, tags=[null]]]}], query[][x{r}#0, $$count(*)$count{r}#4, $$count(*)$seen{r}#5], limit[], \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testDateTruncBucketTransformToQueryAndTagsWithEsFilter/date_trunc/local_physical_optimization.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testDateTruncBucketTransformToQueryAndTagsWithEsFilter/date_trunc/local_physical_optimization.expected index f5a5c391169bb..b1eba3348e69d 100644 --- a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testDateTruncBucketTransformToQueryAndTagsWithEsFilter/date_trunc/local_physical_optimization.expected +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testDateTruncBucketTransformToQueryAndTagsWithEsFilter/date_trunc/local_physical_optimization.expected @@ -1,7 +1,7 @@ LimitExec[1000[INTEGER],null] -\_AggregateExec[[x{r}],[COUNT(*[KEYWORD],true[BOOLEAN],PT0S[TIME_DURATION]) AS count(*), x{r}],FINAL,[x{r}, $$count(*)$count{r}, $$count(*)$seen{r}],null] - \_ExchangeExec[[x{r}, $$count(*)$count{r}, $$count(*)$seen{r}],true] - \_FilterExec[$$count(*)$count{r} > 0[LONG]] +\_AggregateExec[[x{r}#0],[COUNT(*[KEYWORD],true[BOOLEAN],PT0S[TIME_DURATION]) AS count(*)#1, x{r}#0],FINAL,[x{r}#0, $$count(*)$count{r}#2, $$count(*)$seen{r}#3],null] + \_ExchangeExec[[x{r}#0, $$count(*)$count{r}#2, $$count(*)$seen{r}#3],true] + \_FilterExec[$$count(*)$count{r}#4 > 0[LONG]] \_EsStatsQueryExec[all_types], statsByStat{queryBuilderAndTags=[QueryBuilderAndTags[query={ "esql_single_value" : { "field" : "date", @@ -76,4 +76,4 @@ LimitExec[1000[INTEGER],null] ], "boost" : 1.0 } -}, tags=[null]]]}], query[][x{r}, $$count(*)$count{r}, $$count(*)$seen{r}], limit[], \ No newline at end of file +}, tags=[null]]]}], query[][x{r}#0, $$count(*)$count{r}#4, $$count(*)$seen{r}#5], limit[], \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testDateTruncBucketTransformToQueryAndTagsWithEsFilter/round_to/local_physical_optimization.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testDateTruncBucketTransformToQueryAndTagsWithEsFilter/round_to/local_physical_optimization.expected index cf999b9b04435..ee48e2b81fe3e 100644 --- a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testDateTruncBucketTransformToQueryAndTagsWithEsFilter/round_to/local_physical_optimization.expected +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testDateTruncBucketTransformToQueryAndTagsWithEsFilter/round_to/local_physical_optimization.expected @@ -1,7 +1,7 @@ LimitExec[1000[INTEGER],null] -\_AggregateExec[[x{r}],[COUNT(*[KEYWORD],true[BOOLEAN],PT0S[TIME_DURATION]) AS count(*), x{r}],FINAL,[x{r}, $$count(*)$count{r}, $$count(*)$seen{r}],null] - \_ExchangeExec[[x{r}, $$count(*)$count{r}, $$count(*)$seen{r}],true] - \_FilterExec[$$count(*)$count{r} > 0[LONG]] +\_AggregateExec[[x{r}#0],[COUNT(*[KEYWORD],true[BOOLEAN],PT0S[TIME_DURATION]) AS count(*)#1, x{r}#0],FINAL,[x{r}#0, $$count(*)$count{r}#2, $$count(*)$seen{r}#3],null] + \_ExchangeExec[[x{r}#0, $$count(*)$count{r}#2, $$count(*)$seen{r}#3],true] + \_FilterExec[$$count(*)$count{r}#4 > 0[LONG]] \_EsStatsQueryExec[all_types], statsByStat{queryBuilderAndTags=[QueryBuilderAndTags[query={ "esql_single_value" : { "field" : "date", @@ -76,4 +76,4 @@ LimitExec[1000[INTEGER],null] ], "boost" : 1.0 } -}, tags=[null]]]}], query[][x{r}, $$count(*)$count{r}, $$count(*)$seen{r}], limit[], \ No newline at end of file +}, tags=[null]]]}], query[][x{r}#0, $$count(*)$count{r}#4, $$count(*)$seen{r}#5], limit[], \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testDateTruncBucketTransformToQueryAndTagsWithMultipleAggregates/bucket/local_physical_optimization.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testDateTruncBucketTransformToQueryAndTagsWithMultipleAggregates/bucket/local_physical_optimization.expected index 63a896f2a8f23..9bed443f7dbca 100644 --- a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testDateTruncBucketTransformToQueryAndTagsWithMultipleAggregates/bucket/local_physical_optimization.expected +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testDateTruncBucketTransformToQueryAndTagsWithMultipleAggregates/bucket/local_physical_optimization.expected @@ -1,10 +1,10 @@ LimitExec[1000[INTEGER],null] -\_AggregateExec[[x{r}],[SUM(long{f},true[BOOLEAN],PT0S[TIME_DURATION],compensated[KEYWORD]) AS sum(long), COUNT(*[KEYWORD],true[BOOLEAN],PT0S[TIME_DURATION]) AS count(*), x{r}],FINAL,[x{r}, $$sum(long)$sum{r}, $$sum(long)$seen{r}, $$count(*)$count{r}, $$count(*)$seen{r}],null] - \_ExchangeExec[[x{r}, $$sum(long)$sum{r}, $$sum(long)$seen{r}, $$count(*)$count{r}, $$count(*)$seen{r}],true] - \_AggregateExec[[x{r}],[SUM(long{f},true[BOOLEAN],PT0S[TIME_DURATION],compensated[KEYWORD]) AS sum(long), COUNT(*[KEYWORD],true[BOOLEAN],PT0S[TIME_DURATION]) AS count(*), x{r}],INITIAL,[x{r}, $$sum(long)$sum{r}, $$sum(long)$seen{r}, $$count(*)$count{r}, $$count(*)$seen{r}],24] - \_FieldExtractExec[long{f}]<[],[]> - \_EvalExec[[$$date$round_to$datetime{f} AS x]] - \_EsQueryExec[all_types], indexMode[standard], [_doc{f}, $$date$round_to$datetime{f}], limit[], sort[] estimatedRowSize[20] queryBuilderAndTags [[QueryBuilderAndTags[query={ +\_AggregateExec[[x{r}#0],[SUM(long{f}#1,true[BOOLEAN],PT0S[TIME_DURATION],compensated[KEYWORD]) AS sum(long)#2, COUNT(*[KEYWORD],true[BOOLEAN],PT0S[TIME_DURATION]) AS count(*)#3, x{r}#0],FINAL,[x{r}#0, $$sum(long)$sum{r}#4, $$sum(long)$seen{r}#5, $$count(*)$count{r}#6, $$count(*)$seen{r}#7],null] + \_ExchangeExec[[x{r}#0, $$sum(long)$sum{r}#4, $$sum(long)$seen{r}#5, $$count(*)$count{r}#6, $$count(*)$seen{r}#7],true] + \_AggregateExec[[x{r}#0],[SUM(long{f}#1,true[BOOLEAN],PT0S[TIME_DURATION],compensated[KEYWORD]) AS sum(long)#2, COUNT(*[KEYWORD],true[BOOLEAN],PT0S[TIME_DURATION]) AS count(*)#3, x{r}#0],INITIAL,[x{r}#0, $$sum(long)$sum{r}#8, $$sum(long)$seen{r}#9, $$count(*)$count{r}#10, $$count(*)$seen{r}#11],24] + \_FieldExtractExec[long{f}#1]<[],[]> + \_EvalExec[[$$date$round_to$datetime{f}#12 AS x#0]] + \_EsQueryExec[all_types], indexMode[standard], [_doc{f}#13, $$date$round_to$datetime{f}#12], limit[], sort[] estimatedRowSize[20] queryBuilderAndTags [[QueryBuilderAndTags[query={ "esql_single_value" : { "field" : "date", "next" : { diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testDateTruncBucketTransformToQueryAndTagsWithMultipleAggregates/date_trunc/local_physical_optimization.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testDateTruncBucketTransformToQueryAndTagsWithMultipleAggregates/date_trunc/local_physical_optimization.expected index 0605eac068d20..8a37befcc7c7e 100644 --- a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testDateTruncBucketTransformToQueryAndTagsWithMultipleAggregates/date_trunc/local_physical_optimization.expected +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testDateTruncBucketTransformToQueryAndTagsWithMultipleAggregates/date_trunc/local_physical_optimization.expected @@ -1,10 +1,10 @@ LimitExec[1000[INTEGER],null] -\_AggregateExec[[x{r}],[SUM(long{f},true[BOOLEAN],PT0S[TIME_DURATION],compensated[KEYWORD]) AS sum(long), COUNT(*[KEYWORD],true[BOOLEAN],PT0S[TIME_DURATION]) AS count(*), x{r}],FINAL,[x{r}, $$sum(long)$sum{r}, $$sum(long)$seen{r}, $$count(*)$count{r}, $$count(*)$seen{r}],null] - \_ExchangeExec[[x{r}, $$sum(long)$sum{r}, $$sum(long)$seen{r}, $$count(*)$count{r}, $$count(*)$seen{r}],true] - \_AggregateExec[[x{r}],[SUM(long{f},true[BOOLEAN],PT0S[TIME_DURATION],compensated[KEYWORD]) AS sum(long), COUNT(*[KEYWORD],true[BOOLEAN],PT0S[TIME_DURATION]) AS count(*), x{r}],INITIAL,[x{r}, $$sum(long)$sum{r}, $$sum(long)$seen{r}, $$count(*)$count{r}, $$count(*)$seen{r}],24] - \_FieldExtractExec[long{f}]<[],[]> - \_EvalExec[[$$date$round_to$datetime{f} AS x]] - \_EsQueryExec[all_types], indexMode[standard], [_doc{f}, $$date$round_to$datetime{f}], limit[], sort[] estimatedRowSize[20] queryBuilderAndTags [[QueryBuilderAndTags[query={ +\_AggregateExec[[x{r}#0],[SUM(long{f}#1,true[BOOLEAN],PT0S[TIME_DURATION],compensated[KEYWORD]) AS sum(long)#2, COUNT(*[KEYWORD],true[BOOLEAN],PT0S[TIME_DURATION]) AS count(*)#3, x{r}#0],FINAL,[x{r}#0, $$sum(long)$sum{r}#4, $$sum(long)$seen{r}#5, $$count(*)$count{r}#6, $$count(*)$seen{r}#7],null] + \_ExchangeExec[[x{r}#0, $$sum(long)$sum{r}#4, $$sum(long)$seen{r}#5, $$count(*)$count{r}#6, $$count(*)$seen{r}#7],true] + \_AggregateExec[[x{r}#0],[SUM(long{f}#1,true[BOOLEAN],PT0S[TIME_DURATION],compensated[KEYWORD]) AS sum(long)#2, COUNT(*[KEYWORD],true[BOOLEAN],PT0S[TIME_DURATION]) AS count(*)#3, x{r}#0],INITIAL,[x{r}#0, $$sum(long)$sum{r}#8, $$sum(long)$seen{r}#9, $$count(*)$count{r}#10, $$count(*)$seen{r}#11],24] + \_FieldExtractExec[long{f}#1]<[],[]> + \_EvalExec[[$$date$round_to$datetime{f}#12 AS x#0]] + \_EsQueryExec[all_types], indexMode[standard], [_doc{f}#13, $$date$round_to$datetime{f}#12], limit[], sort[] estimatedRowSize[20] queryBuilderAndTags [[QueryBuilderAndTags[query={ "esql_single_value" : { "field" : "date", "next" : { diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testDateTruncBucketTransformToQueryAndTagsWithMultipleAggregates/round_to/local_physical_optimization.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testDateTruncBucketTransformToQueryAndTagsWithMultipleAggregates/round_to/local_physical_optimization.expected index 6b66c077f925b..dd6350bd70a36 100644 --- a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testDateTruncBucketTransformToQueryAndTagsWithMultipleAggregates/round_to/local_physical_optimization.expected +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testDateTruncBucketTransformToQueryAndTagsWithMultipleAggregates/round_to/local_physical_optimization.expected @@ -1,10 +1,10 @@ LimitExec[1000[INTEGER],null] -\_AggregateExec[[x{r}],[SUM(long{f},true[BOOLEAN],PT0S[TIME_DURATION],compensated[KEYWORD]) AS sum(long), COUNT(*[KEYWORD],true[BOOLEAN],PT0S[TIME_DURATION]) AS count(*), x{r}],FINAL,[x{r}, $$sum(long)$sum{r}, $$sum(long)$seen{r}, $$count(*)$count{r}, $$count(*)$seen{r}],null] - \_ExchangeExec[[x{r}, $$sum(long)$sum{r}, $$sum(long)$seen{r}, $$count(*)$count{r}, $$count(*)$seen{r}],true] - \_AggregateExec[[x{r}],[SUM(long{f},true[BOOLEAN],PT0S[TIME_DURATION],compensated[KEYWORD]) AS sum(long), COUNT(*[KEYWORD],true[BOOLEAN],PT0S[TIME_DURATION]) AS count(*), x{r}],INITIAL,[x{r}, $$sum(long)$sum{r}, $$sum(long)$seen{r}, $$count(*)$count{r}, $$count(*)$seen{r}],24] - \_FieldExtractExec[long{f}]<[],[]> - \_EvalExec[[$$date$round_to$datetime{f} AS x]] - \_EsQueryExec[all_types], indexMode[standard], [_doc{f}, $$date$round_to$datetime{f}], limit[], sort[] estimatedRowSize[20] queryBuilderAndTags [[QueryBuilderAndTags[query={ +\_AggregateExec[[x{r}#0],[SUM(long{f}#1,true[BOOLEAN],PT0S[TIME_DURATION],compensated[KEYWORD]) AS sum(long)#2, COUNT(*[KEYWORD],true[BOOLEAN],PT0S[TIME_DURATION]) AS count(*)#3, x{r}#0],FINAL,[x{r}#0, $$sum(long)$sum{r}#4, $$sum(long)$seen{r}#5, $$count(*)$count{r}#6, $$count(*)$seen{r}#7],null] + \_ExchangeExec[[x{r}#0, $$sum(long)$sum{r}#4, $$sum(long)$seen{r}#5, $$count(*)$count{r}#6, $$count(*)$seen{r}#7],true] + \_AggregateExec[[x{r}#0],[SUM(long{f}#1,true[BOOLEAN],PT0S[TIME_DURATION],compensated[KEYWORD]) AS sum(long)#2, COUNT(*[KEYWORD],true[BOOLEAN],PT0S[TIME_DURATION]) AS count(*)#3, x{r}#0],INITIAL,[x{r}#0, $$sum(long)$sum{r}#8, $$sum(long)$seen{r}#9, $$count(*)$count{r}#10, $$count(*)$seen{r}#11],24] + \_FieldExtractExec[long{f}#1]<[],[]> + \_EvalExec[[$$date$round_to$datetime{f}#12 AS x#0]] + \_EsQueryExec[all_types], indexMode[standard], [_doc{f}#13, $$date$round_to$datetime{f}#12], limit[], sort[] estimatedRowSize[20] queryBuilderAndTags [[QueryBuilderAndTags[query={ "esql_single_value" : { "field" : "date", "next" : { diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testDateTruncBucketTransformToQueryAndTagsWithOtherPushdownFunctions/bucket/date_range/local_physical_optimization.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testDateTruncBucketTransformToQueryAndTagsWithOtherPushdownFunctions/bucket/date_range/local_physical_optimization.expected index dc56c28f87e93..6af84798b0c5b 100644 --- a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testDateTruncBucketTransformToQueryAndTagsWithOtherPushdownFunctions/bucket/date_range/local_physical_optimization.expected +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testDateTruncBucketTransformToQueryAndTagsWithOtherPushdownFunctions/bucket/date_range/local_physical_optimization.expected @@ -1,7 +1,7 @@ LimitExec[1000[INTEGER],null] -\_AggregateExec[[x{r}],[COUNT(*[KEYWORD],true[BOOLEAN],PT0S[TIME_DURATION]) AS count(*), x{r}],FINAL,[x{r}, $$count(*)$count{r}, $$count(*)$seen{r}],null] - \_ExchangeExec[[x{r}, $$count(*)$count{r}, $$count(*)$seen{r}],true] - \_FilterExec[$$count(*)$count{r} > 0[LONG]] +\_AggregateExec[[x{r}#0],[COUNT(*[KEYWORD],true[BOOLEAN],PT0S[TIME_DURATION]) AS count(*)#1, x{r}#0],FINAL,[x{r}#0, $$count(*)$count{r}#2, $$count(*)$seen{r}#3],null] + \_ExchangeExec[[x{r}#0, $$count(*)$count{r}#2, $$count(*)$seen{r}#3],true] + \_FilterExec[$$count(*)$count{r}#4 > 0[LONG]] \_EsStatsQueryExec[all_types], statsByStat{queryBuilderAndTags=[QueryBuilderAndTags[query={ "range" : { "date" : { @@ -42,4 +42,4 @@ LimitExec[1000[INTEGER],null] "boost" : 0.0 } } -}, tags=[1698019200000]]]}], query[][x{r}, $$count(*)$count{r}, $$count(*)$seen{r}], limit[], \ No newline at end of file +}, tags=[1698019200000]]]}], query[][x{r}#0, $$count(*)$count{r}#4, $$count(*)$seen{r}#5], limit[], \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testDateTruncBucketTransformToQueryAndTagsWithOtherPushdownFunctions/bucket/keyword_equality/local_physical_optimization.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testDateTruncBucketTransformToQueryAndTagsWithOtherPushdownFunctions/bucket/keyword_equality/local_physical_optimization.expected index 395483c2bb606..8b039c4db5c27 100644 --- a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testDateTruncBucketTransformToQueryAndTagsWithOtherPushdownFunctions/bucket/keyword_equality/local_physical_optimization.expected +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testDateTruncBucketTransformToQueryAndTagsWithOtherPushdownFunctions/bucket/keyword_equality/local_physical_optimization.expected @@ -1,9 +1,9 @@ LimitExec[1000[INTEGER],null] -\_AggregateExec[[x{r}],[COUNT(*[KEYWORD],true[BOOLEAN],PT0S[TIME_DURATION]) AS count(*), x{r}],FINAL,[x{r}, $$count(*)$count{r}, $$count(*)$seen{r}],null] - \_ExchangeExec[[x{r}, $$count(*)$count{r}, $$count(*)$seen{r}],true] - \_AggregateExec[[x{r}],[COUNT(*[KEYWORD],true[BOOLEAN],PT0S[TIME_DURATION]) AS count(*), x{r}],INITIAL,[x{r}, $$count(*)$count{r}, $$count(*)$seen{r}],16] - \_EvalExec[[$$date$round_to$datetime{f} AS x]] - \_EsQueryExec[all_types], indexMode[standard], [_doc{f}, $$date$round_to$datetime{f}], limit[], sort[] estimatedRowSize[12] queryBuilderAndTags [[QueryBuilderAndTags[query={ +\_AggregateExec[[x{r}#0],[COUNT(*[KEYWORD],true[BOOLEAN],PT0S[TIME_DURATION]) AS count(*)#1, x{r}#0],FINAL,[x{r}#0, $$count(*)$count{r}#2, $$count(*)$seen{r}#3],null] + \_ExchangeExec[[x{r}#0, $$count(*)$count{r}#2, $$count(*)$seen{r}#3],true] + \_AggregateExec[[x{r}#0],[COUNT(*[KEYWORD],true[BOOLEAN],PT0S[TIME_DURATION]) AS count(*)#1, x{r}#0],INITIAL,[x{r}#0, $$count(*)$count{r}#4, $$count(*)$seen{r}#5],16] + \_EvalExec[[$$date$round_to$datetime{f}#6 AS x#0]] + \_EsQueryExec[all_types], indexMode[standard], [_doc{f}#7, $$date$round_to$datetime{f}#6], limit[], sort[] estimatedRowSize[12] queryBuilderAndTags [[QueryBuilderAndTags[query={ "bool" : { "filter" : [ { diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testDateTruncBucketTransformToQueryAndTagsWithOtherPushdownFunctions/bucket/keyword_match/local_physical_optimization.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testDateTruncBucketTransformToQueryAndTagsWithOtherPushdownFunctions/bucket/keyword_match/local_physical_optimization.expected index fa6cea028e09c..1783e8bca9fb9 100644 --- a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testDateTruncBucketTransformToQueryAndTagsWithOtherPushdownFunctions/bucket/keyword_match/local_physical_optimization.expected +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testDateTruncBucketTransformToQueryAndTagsWithOtherPushdownFunctions/bucket/keyword_match/local_physical_optimization.expected @@ -1,9 +1,9 @@ LimitExec[1000[INTEGER],null] -\_AggregateExec[[x{r}],[COUNT(*[KEYWORD],true[BOOLEAN],PT0S[TIME_DURATION]) AS count(*), x{r}],FINAL,[x{r}, $$count(*)$count{r}, $$count(*)$seen{r}],null] - \_ExchangeExec[[x{r}, $$count(*)$count{r}, $$count(*)$seen{r}],true] - \_AggregateExec[[x{r}],[COUNT(*[KEYWORD],true[BOOLEAN],PT0S[TIME_DURATION]) AS count(*), x{r}],INITIAL,[x{r}, $$count(*)$count{r}, $$count(*)$seen{r}],16] - \_EvalExec[[$$date$round_to$datetime{f} AS x]] - \_EsQueryExec[all_types], indexMode[standard], [_doc{f}, $$date$round_to$datetime{f}], limit[], sort[] estimatedRowSize[12] queryBuilderAndTags [[QueryBuilderAndTags[query={ +\_AggregateExec[[x{r}#0],[COUNT(*[KEYWORD],true[BOOLEAN],PT0S[TIME_DURATION]) AS count(*)#1, x{r}#0],FINAL,[x{r}#0, $$count(*)$count{r}#2, $$count(*)$seen{r}#3],null] + \_ExchangeExec[[x{r}#0, $$count(*)$count{r}#2, $$count(*)$seen{r}#3],true] + \_AggregateExec[[x{r}#0],[COUNT(*[KEYWORD],true[BOOLEAN],PT0S[TIME_DURATION]) AS count(*)#1, x{r}#0],INITIAL,[x{r}#0, $$count(*)$count{r}#4, $$count(*)$seen{r}#5],16] + \_EvalExec[[$$date$round_to$datetime{f}#6 AS x#0]] + \_EsQueryExec[all_types], indexMode[standard], [_doc{f}#7, $$date$round_to$datetime{f}#6], limit[], sort[] estimatedRowSize[12] queryBuilderAndTags [[QueryBuilderAndTags[query={ "bool" : { "filter" : [ { diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testDateTruncBucketTransformToQueryAndTagsWithOtherPushdownFunctions/date_trunc/date_range/local_physical_optimization.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testDateTruncBucketTransformToQueryAndTagsWithOtherPushdownFunctions/date_trunc/date_range/local_physical_optimization.expected index dc56c28f87e93..6af84798b0c5b 100644 --- a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testDateTruncBucketTransformToQueryAndTagsWithOtherPushdownFunctions/date_trunc/date_range/local_physical_optimization.expected +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testDateTruncBucketTransformToQueryAndTagsWithOtherPushdownFunctions/date_trunc/date_range/local_physical_optimization.expected @@ -1,7 +1,7 @@ LimitExec[1000[INTEGER],null] -\_AggregateExec[[x{r}],[COUNT(*[KEYWORD],true[BOOLEAN],PT0S[TIME_DURATION]) AS count(*), x{r}],FINAL,[x{r}, $$count(*)$count{r}, $$count(*)$seen{r}],null] - \_ExchangeExec[[x{r}, $$count(*)$count{r}, $$count(*)$seen{r}],true] - \_FilterExec[$$count(*)$count{r} > 0[LONG]] +\_AggregateExec[[x{r}#0],[COUNT(*[KEYWORD],true[BOOLEAN],PT0S[TIME_DURATION]) AS count(*)#1, x{r}#0],FINAL,[x{r}#0, $$count(*)$count{r}#2, $$count(*)$seen{r}#3],null] + \_ExchangeExec[[x{r}#0, $$count(*)$count{r}#2, $$count(*)$seen{r}#3],true] + \_FilterExec[$$count(*)$count{r}#4 > 0[LONG]] \_EsStatsQueryExec[all_types], statsByStat{queryBuilderAndTags=[QueryBuilderAndTags[query={ "range" : { "date" : { @@ -42,4 +42,4 @@ LimitExec[1000[INTEGER],null] "boost" : 0.0 } } -}, tags=[1698019200000]]]}], query[][x{r}, $$count(*)$count{r}, $$count(*)$seen{r}], limit[], \ No newline at end of file +}, tags=[1698019200000]]]}], query[][x{r}#0, $$count(*)$count{r}#4, $$count(*)$seen{r}#5], limit[], \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testDateTruncBucketTransformToQueryAndTagsWithOtherPushdownFunctions/date_trunc/keyword_equality/local_physical_optimization.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testDateTruncBucketTransformToQueryAndTagsWithOtherPushdownFunctions/date_trunc/keyword_equality/local_physical_optimization.expected index b2f7f6047fbc3..741c5cc853d00 100644 --- a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testDateTruncBucketTransformToQueryAndTagsWithOtherPushdownFunctions/date_trunc/keyword_equality/local_physical_optimization.expected +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testDateTruncBucketTransformToQueryAndTagsWithOtherPushdownFunctions/date_trunc/keyword_equality/local_physical_optimization.expected @@ -1,9 +1,9 @@ LimitExec[1000[INTEGER],null] -\_AggregateExec[[x{r}],[COUNT(*[KEYWORD],true[BOOLEAN],PT0S[TIME_DURATION]) AS count(*), x{r}],FINAL,[x{r}, $$count(*)$count{r}, $$count(*)$seen{r}],null] - \_ExchangeExec[[x{r}, $$count(*)$count{r}, $$count(*)$seen{r}],true] - \_AggregateExec[[x{r}],[COUNT(*[KEYWORD],true[BOOLEAN],PT0S[TIME_DURATION]) AS count(*), x{r}],INITIAL,[x{r}, $$count(*)$count{r}, $$count(*)$seen{r}],16] - \_EvalExec[[$$date$round_to$datetime{f} AS x]] - \_EsQueryExec[all_types], indexMode[standard], [_doc{f}, $$date$round_to$datetime{f}], limit[], sort[] estimatedRowSize[12] queryBuilderAndTags [[QueryBuilderAndTags[query={ +\_AggregateExec[[x{r}#0],[COUNT(*[KEYWORD],true[BOOLEAN],PT0S[TIME_DURATION]) AS count(*)#1, x{r}#0],FINAL,[x{r}#0, $$count(*)$count{r}#2, $$count(*)$seen{r}#3],null] + \_ExchangeExec[[x{r}#0, $$count(*)$count{r}#2, $$count(*)$seen{r}#3],true] + \_AggregateExec[[x{r}#0],[COUNT(*[KEYWORD],true[BOOLEAN],PT0S[TIME_DURATION]) AS count(*)#1, x{r}#0],INITIAL,[x{r}#0, $$count(*)$count{r}#4, $$count(*)$seen{r}#5],16] + \_EvalExec[[$$date$round_to$datetime{f}#6 AS x#0]] + \_EsQueryExec[all_types], indexMode[standard], [_doc{f}#7, $$date$round_to$datetime{f}#6], limit[], sort[] estimatedRowSize[12] queryBuilderAndTags [[QueryBuilderAndTags[query={ "bool" : { "filter" : [ { diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testDateTruncBucketTransformToQueryAndTagsWithOtherPushdownFunctions/date_trunc/keyword_match/local_physical_optimization.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testDateTruncBucketTransformToQueryAndTagsWithOtherPushdownFunctions/date_trunc/keyword_match/local_physical_optimization.expected index 479e0224b6622..ba745f8603cf2 100644 --- a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testDateTruncBucketTransformToQueryAndTagsWithOtherPushdownFunctions/date_trunc/keyword_match/local_physical_optimization.expected +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testDateTruncBucketTransformToQueryAndTagsWithOtherPushdownFunctions/date_trunc/keyword_match/local_physical_optimization.expected @@ -1,9 +1,9 @@ LimitExec[1000[INTEGER],null] -\_AggregateExec[[x{r}],[COUNT(*[KEYWORD],true[BOOLEAN],PT0S[TIME_DURATION]) AS count(*), x{r}],FINAL,[x{r}, $$count(*)$count{r}, $$count(*)$seen{r}],null] - \_ExchangeExec[[x{r}, $$count(*)$count{r}, $$count(*)$seen{r}],true] - \_AggregateExec[[x{r}],[COUNT(*[KEYWORD],true[BOOLEAN],PT0S[TIME_DURATION]) AS count(*), x{r}],INITIAL,[x{r}, $$count(*)$count{r}, $$count(*)$seen{r}],16] - \_EvalExec[[$$date$round_to$datetime{f} AS x]] - \_EsQueryExec[all_types], indexMode[standard], [_doc{f}, $$date$round_to$datetime{f}], limit[], sort[] estimatedRowSize[12] queryBuilderAndTags [[QueryBuilderAndTags[query={ +\_AggregateExec[[x{r}#0],[COUNT(*[KEYWORD],true[BOOLEAN],PT0S[TIME_DURATION]) AS count(*)#1, x{r}#0],FINAL,[x{r}#0, $$count(*)$count{r}#2, $$count(*)$seen{r}#3],null] + \_ExchangeExec[[x{r}#0, $$count(*)$count{r}#2, $$count(*)$seen{r}#3],true] + \_AggregateExec[[x{r}#0],[COUNT(*[KEYWORD],true[BOOLEAN],PT0S[TIME_DURATION]) AS count(*)#1, x{r}#0],INITIAL,[x{r}#0, $$count(*)$count{r}#4, $$count(*)$seen{r}#5],16] + \_EvalExec[[$$date$round_to$datetime{f}#6 AS x#0]] + \_EsQueryExec[all_types], indexMode[standard], [_doc{f}#7, $$date$round_to$datetime{f}#6], limit[], sort[] estimatedRowSize[12] queryBuilderAndTags [[QueryBuilderAndTags[query={ "bool" : { "filter" : [ { diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testDateTruncBucketTransformToQueryAndTagsWithOtherPushdownFunctions/round_to/date_range/local_physical_optimization.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testDateTruncBucketTransformToQueryAndTagsWithOtherPushdownFunctions/round_to/date_range/local_physical_optimization.expected index dc56c28f87e93..6af84798b0c5b 100644 --- a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testDateTruncBucketTransformToQueryAndTagsWithOtherPushdownFunctions/round_to/date_range/local_physical_optimization.expected +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testDateTruncBucketTransformToQueryAndTagsWithOtherPushdownFunctions/round_to/date_range/local_physical_optimization.expected @@ -1,7 +1,7 @@ LimitExec[1000[INTEGER],null] -\_AggregateExec[[x{r}],[COUNT(*[KEYWORD],true[BOOLEAN],PT0S[TIME_DURATION]) AS count(*), x{r}],FINAL,[x{r}, $$count(*)$count{r}, $$count(*)$seen{r}],null] - \_ExchangeExec[[x{r}, $$count(*)$count{r}, $$count(*)$seen{r}],true] - \_FilterExec[$$count(*)$count{r} > 0[LONG]] +\_AggregateExec[[x{r}#0],[COUNT(*[KEYWORD],true[BOOLEAN],PT0S[TIME_DURATION]) AS count(*)#1, x{r}#0],FINAL,[x{r}#0, $$count(*)$count{r}#2, $$count(*)$seen{r}#3],null] + \_ExchangeExec[[x{r}#0, $$count(*)$count{r}#2, $$count(*)$seen{r}#3],true] + \_FilterExec[$$count(*)$count{r}#4 > 0[LONG]] \_EsStatsQueryExec[all_types], statsByStat{queryBuilderAndTags=[QueryBuilderAndTags[query={ "range" : { "date" : { @@ -42,4 +42,4 @@ LimitExec[1000[INTEGER],null] "boost" : 0.0 } } -}, tags=[1698019200000]]]}], query[][x{r}, $$count(*)$count{r}, $$count(*)$seen{r}], limit[], \ No newline at end of file +}, tags=[1698019200000]]]}], query[][x{r}#0, $$count(*)$count{r}#4, $$count(*)$seen{r}#5], limit[], \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testDateTruncBucketTransformToQueryAndTagsWithOtherPushdownFunctions/round_to/keyword_equality/local_physical_optimization.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testDateTruncBucketTransformToQueryAndTagsWithOtherPushdownFunctions/round_to/keyword_equality/local_physical_optimization.expected index 23b908e99a46f..3bb91af178169 100644 --- a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testDateTruncBucketTransformToQueryAndTagsWithOtherPushdownFunctions/round_to/keyword_equality/local_physical_optimization.expected +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testDateTruncBucketTransformToQueryAndTagsWithOtherPushdownFunctions/round_to/keyword_equality/local_physical_optimization.expected @@ -1,9 +1,9 @@ LimitExec[1000[INTEGER],null] -\_AggregateExec[[x{r}],[COUNT(*[KEYWORD],true[BOOLEAN],PT0S[TIME_DURATION]) AS count(*), x{r}],FINAL,[x{r}, $$count(*)$count{r}, $$count(*)$seen{r}],null] - \_ExchangeExec[[x{r}, $$count(*)$count{r}, $$count(*)$seen{r}],true] - \_AggregateExec[[x{r}],[COUNT(*[KEYWORD],true[BOOLEAN],PT0S[TIME_DURATION]) AS count(*), x{r}],INITIAL,[x{r}, $$count(*)$count{r}, $$count(*)$seen{r}],16] - \_EvalExec[[$$date$round_to$datetime{f} AS x]] - \_EsQueryExec[all_types], indexMode[standard], [_doc{f}, $$date$round_to$datetime{f}], limit[], sort[] estimatedRowSize[12] queryBuilderAndTags [[QueryBuilderAndTags[query={ +\_AggregateExec[[x{r}#0],[COUNT(*[KEYWORD],true[BOOLEAN],PT0S[TIME_DURATION]) AS count(*)#1, x{r}#0],FINAL,[x{r}#0, $$count(*)$count{r}#2, $$count(*)$seen{r}#3],null] + \_ExchangeExec[[x{r}#0, $$count(*)$count{r}#2, $$count(*)$seen{r}#3],true] + \_AggregateExec[[x{r}#0],[COUNT(*[KEYWORD],true[BOOLEAN],PT0S[TIME_DURATION]) AS count(*)#1, x{r}#0],INITIAL,[x{r}#0, $$count(*)$count{r}#4, $$count(*)$seen{r}#5],16] + \_EvalExec[[$$date$round_to$datetime{f}#6 AS x#0]] + \_EsQueryExec[all_types], indexMode[standard], [_doc{f}#7, $$date$round_to$datetime{f}#6], limit[], sort[] estimatedRowSize[12] queryBuilderAndTags [[QueryBuilderAndTags[query={ "bool" : { "filter" : [ { diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testDateTruncBucketTransformToQueryAndTagsWithOtherPushdownFunctions/round_to/keyword_match/local_physical_optimization.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testDateTruncBucketTransformToQueryAndTagsWithOtherPushdownFunctions/round_to/keyword_match/local_physical_optimization.expected index 186576dc41e63..0adf9b4716949 100644 --- a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testDateTruncBucketTransformToQueryAndTagsWithOtherPushdownFunctions/round_to/keyword_match/local_physical_optimization.expected +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testDateTruncBucketTransformToQueryAndTagsWithOtherPushdownFunctions/round_to/keyword_match/local_physical_optimization.expected @@ -1,9 +1,9 @@ LimitExec[1000[INTEGER],null] -\_AggregateExec[[x{r}],[COUNT(*[KEYWORD],true[BOOLEAN],PT0S[TIME_DURATION]) AS count(*), x{r}],FINAL,[x{r}, $$count(*)$count{r}, $$count(*)$seen{r}],null] - \_ExchangeExec[[x{r}, $$count(*)$count{r}, $$count(*)$seen{r}],true] - \_AggregateExec[[x{r}],[COUNT(*[KEYWORD],true[BOOLEAN],PT0S[TIME_DURATION]) AS count(*), x{r}],INITIAL,[x{r}, $$count(*)$count{r}, $$count(*)$seen{r}],16] - \_EvalExec[[$$date$round_to$datetime{f} AS x]] - \_EsQueryExec[all_types], indexMode[standard], [_doc{f}, $$date$round_to$datetime{f}], limit[], sort[] estimatedRowSize[12] queryBuilderAndTags [[QueryBuilderAndTags[query={ +\_AggregateExec[[x{r}#0],[COUNT(*[KEYWORD],true[BOOLEAN],PT0S[TIME_DURATION]) AS count(*)#1, x{r}#0],FINAL,[x{r}#0, $$count(*)$count{r}#2, $$count(*)$seen{r}#3],null] + \_ExchangeExec[[x{r}#0, $$count(*)$count{r}#2, $$count(*)$seen{r}#3],true] + \_AggregateExec[[x{r}#0],[COUNT(*[KEYWORD],true[BOOLEAN],PT0S[TIME_DURATION]) AS count(*)#1, x{r}#0],INITIAL,[x{r}#0, $$count(*)$count{r}#4, $$count(*)$seen{r}#5],16] + \_EvalExec[[$$date$round_to$datetime{f}#6 AS x#0]] + \_EsQueryExec[all_types], indexMode[standard], [_doc{f}#7, $$date$round_to$datetime{f}#6], limit[], sort[] estimatedRowSize[12] queryBuilderAndTags [[QueryBuilderAndTags[query={ "bool" : { "filter" : [ { diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testDateTruncBucketTransformToQueryAndTagsWithWhereInsideAggregation/bucket/local_physical_optimization.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testDateTruncBucketTransformToQueryAndTagsWithWhereInsideAggregation/bucket/local_physical_optimization.expected index ccee8d2c5df22..54ec4005471fb 100644 --- a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testDateTruncBucketTransformToQueryAndTagsWithWhereInsideAggregation/bucket/local_physical_optimization.expected +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testDateTruncBucketTransformToQueryAndTagsWithWhereInsideAggregation/bucket/local_physical_optimization.expected @@ -1,10 +1,10 @@ LimitExec[1000[INTEGER],null] -\_AggregateExec[[x{r}],[COUNT(*[KEYWORD],long{f} > 10[INTEGER],PT0S[TIME_DURATION]) AS count(*) where long > 10, x{r}],FINAL,[x{r}, $$count(*) where long > 10$count{r}, $$count(*) where long > 10$seen{r}],null] - \_ExchangeExec[[x{r}, $$count(*) where long > 10$count{r}, $$count(*) where long > 10$seen{r}],true] - \_AggregateExec[[x{r}],[COUNT(*[KEYWORD],long{f} > 10[INTEGER],PT0S[TIME_DURATION]) AS count(*) where long > 10, x{r}],INITIAL,[x{r}, $$count(*) where long > 10$count{r}, $$count(*) where long > 10$seen{r}],16] - \_FieldExtractExec[long{f}]<[],[]> - \_EvalExec[[$$date$round_to$datetime{f} AS x]] - \_EsQueryExec[all_types], indexMode[standard], [_doc{f}, $$date$round_to$datetime{f}], limit[], sort[] estimatedRowSize[20] queryBuilderAndTags [[QueryBuilderAndTags[query={ +\_AggregateExec[[x{r}#0],[COUNT(*[KEYWORD],long{f}#1 > 10[INTEGER],PT0S[TIME_DURATION]) AS count(*) where long > 10#2, x{r}#0],FINAL,[x{r}#0, $$count(*) where long > 10$count{r}#3, $$count(*) where long > 10$seen{r}#4],null] + \_ExchangeExec[[x{r}#0, $$count(*) where long > 10$count{r}#3, $$count(*) where long > 10$seen{r}#4],true] + \_AggregateExec[[x{r}#0],[COUNT(*[KEYWORD],long{f}#1 > 10[INTEGER],PT0S[TIME_DURATION]) AS count(*) where long > 10#2, x{r}#0],INITIAL,[x{r}#0, $$count(*) where long > 10$count{r}#5, $$count(*) where long > 10$seen{r}#6],16] + \_FieldExtractExec[long{f}#1]<[],[]> + \_EvalExec[[$$date$round_to$datetime{f}#7 AS x#0]] + \_EsQueryExec[all_types], indexMode[standard], [_doc{f}#8, $$date$round_to$datetime{f}#7], limit[], sort[] estimatedRowSize[20] queryBuilderAndTags [[QueryBuilderAndTags[query={ "esql_single_value" : { "field" : "date", "next" : { diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testDateTruncBucketTransformToQueryAndTagsWithWhereInsideAggregation/date_trunc/local_physical_optimization.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testDateTruncBucketTransformToQueryAndTagsWithWhereInsideAggregation/date_trunc/local_physical_optimization.expected index 8fcf95e865e7b..8665d69bc4af1 100644 --- a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testDateTruncBucketTransformToQueryAndTagsWithWhereInsideAggregation/date_trunc/local_physical_optimization.expected +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testDateTruncBucketTransformToQueryAndTagsWithWhereInsideAggregation/date_trunc/local_physical_optimization.expected @@ -1,10 +1,10 @@ LimitExec[1000[INTEGER],null] -\_AggregateExec[[x{r}],[COUNT(*[KEYWORD],long{f} > 10[INTEGER],PT0S[TIME_DURATION]) AS count(*) where long > 10, x{r}],FINAL,[x{r}, $$count(*) where long > 10$count{r}, $$count(*) where long > 10$seen{r}],null] - \_ExchangeExec[[x{r}, $$count(*) where long > 10$count{r}, $$count(*) where long > 10$seen{r}],true] - \_AggregateExec[[x{r}],[COUNT(*[KEYWORD],long{f} > 10[INTEGER],PT0S[TIME_DURATION]) AS count(*) where long > 10, x{r}],INITIAL,[x{r}, $$count(*) where long > 10$count{r}, $$count(*) where long > 10$seen{r}],16] - \_FieldExtractExec[long{f}]<[],[]> - \_EvalExec[[$$date$round_to$datetime{f} AS x]] - \_EsQueryExec[all_types], indexMode[standard], [_doc{f}, $$date$round_to$datetime{f}], limit[], sort[] estimatedRowSize[20] queryBuilderAndTags [[QueryBuilderAndTags[query={ +\_AggregateExec[[x{r}#0],[COUNT(*[KEYWORD],long{f}#1 > 10[INTEGER],PT0S[TIME_DURATION]) AS count(*) where long > 10#2, x{r}#0],FINAL,[x{r}#0, $$count(*) where long > 10$count{r}#3, $$count(*) where long > 10$seen{r}#4],null] + \_ExchangeExec[[x{r}#0, $$count(*) where long > 10$count{r}#3, $$count(*) where long > 10$seen{r}#4],true] + \_AggregateExec[[x{r}#0],[COUNT(*[KEYWORD],long{f}#1 > 10[INTEGER],PT0S[TIME_DURATION]) AS count(*) where long > 10#2, x{r}#0],INITIAL,[x{r}#0, $$count(*) where long > 10$count{r}#5, $$count(*) where long > 10$seen{r}#6],16] + \_FieldExtractExec[long{f}#1]<[],[]> + \_EvalExec[[$$date$round_to$datetime{f}#7 AS x#0]] + \_EsQueryExec[all_types], indexMode[standard], [_doc{f}#8, $$date$round_to$datetime{f}#7], limit[], sort[] estimatedRowSize[20] queryBuilderAndTags [[QueryBuilderAndTags[query={ "esql_single_value" : { "field" : "date", "next" : { diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testDateTruncBucketTransformToQueryAndTagsWithWhereInsideAggregation/round_to/local_physical_optimization.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testDateTruncBucketTransformToQueryAndTagsWithWhereInsideAggregation/round_to/local_physical_optimization.expected index 01cb9eab075bb..d59fd1a30f5dc 100644 --- a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testDateTruncBucketTransformToQueryAndTagsWithWhereInsideAggregation/round_to/local_physical_optimization.expected +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testDateTruncBucketTransformToQueryAndTagsWithWhereInsideAggregation/round_to/local_physical_optimization.expected @@ -1,10 +1,10 @@ LimitExec[1000[INTEGER],null] -\_AggregateExec[[x{r}],[COUNT(*[KEYWORD],long{f} > 10[INTEGER],PT0S[TIME_DURATION]) AS count(*) where long > 10, x{r}],FINAL,[x{r}, $$count(*) where long > 10$count{r}, $$count(*) where long > 10$seen{r}],null] - \_ExchangeExec[[x{r}, $$count(*) where long > 10$count{r}, $$count(*) where long > 10$seen{r}],true] - \_AggregateExec[[x{r}],[COUNT(*[KEYWORD],long{f} > 10[INTEGER],PT0S[TIME_DURATION]) AS count(*) where long > 10, x{r}],INITIAL,[x{r}, $$count(*) where long > 10$count{r}, $$count(*) where long > 10$seen{r}],16] - \_FieldExtractExec[long{f}]<[],[]> - \_EvalExec[[$$date$round_to$datetime{f} AS x]] - \_EsQueryExec[all_types], indexMode[standard], [_doc{f}, $$date$round_to$datetime{f}], limit[], sort[] estimatedRowSize[20] queryBuilderAndTags [[QueryBuilderAndTags[query={ +\_AggregateExec[[x{r}#0],[COUNT(*[KEYWORD],long{f}#1 > 10[INTEGER],PT0S[TIME_DURATION]) AS count(*) where long > 10#2, x{r}#0],FINAL,[x{r}#0, $$count(*) where long > 10$count{r}#3, $$count(*) where long > 10$seen{r}#4],null] + \_ExchangeExec[[x{r}#0, $$count(*) where long > 10$count{r}#3, $$count(*) where long > 10$seen{r}#4],true] + \_AggregateExec[[x{r}#0],[COUNT(*[KEYWORD],long{f}#1 > 10[INTEGER],PT0S[TIME_DURATION]) AS count(*) where long > 10#2, x{r}#0],INITIAL,[x{r}#0, $$count(*) where long > 10$count{r}#5, $$count(*) where long > 10$seen{r}#6],16] + \_FieldExtractExec[long{f}#1]<[],[]> + \_EvalExec[[$$date$round_to$datetime{f}#7 AS x#0]] + \_EsQueryExec[all_types], indexMode[standard], [_doc{f}#8, $$date$round_to$datetime{f}#7], limit[], sort[] estimatedRowSize[20] queryBuilderAndTags [[QueryBuilderAndTags[query={ "esql_single_value" : { "field" : "date", "next" : { diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testDateTruncNotTransformToQueryAndTags/date_trunc/local_physical_optimization.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testDateTruncNotTransformToQueryAndTags/date_trunc/local_physical_optimization.expected index 046b0b2603e13..f4aec5a235e42 100644 --- a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testDateTruncNotTransformToQueryAndTags/date_trunc/local_physical_optimization.expected +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testDateTruncNotTransformToQueryAndTags/date_trunc/local_physical_optimization.expected @@ -1,8 +1,8 @@ -ProjectExec[[!alias_integer, date{f}, x{r}]] -\_TopNExec[[Order[date{f},ASC,LAST]],5[INTEGER],null] - \_ExchangeExec[[!alias_integer, date{f}, x{r}],false] - \_ProjectExec[[!alias_integer, date{f}, x{r}]] +ProjectExec[[!alias_integer, date{f}#0, x{r}#1]] +\_TopNExec[[Order[date{f}#0,ASC,LAST]],5[INTEGER],null] + \_ExchangeExec[[!alias_integer, date{f}#0, x{r}#1],false] + \_ProjectExec[[!alias_integer, date{f}#0, x{r}#1]] \_FieldExtractExec[!alias_integer]<[],[]> - \_EvalExec[[ROUNDTO(date{f},1697760000000[DATETIME],1697846400000[DATETIME],1697932800000[DATETIME],1698019200000[DATETIME]) AS x]] - \_FieldExtractExec[date{f}]<[],[]> - \_EsQueryExec[all_types], indexMode[standard], [_doc{f}], limit[5], sort[[FieldSort[field=date{f}, direction=ASC, nulls=LAST]]] estimatedRowSize[1056] queryBuilderAndTags [[QueryBuilderAndTags[query=null, tags=[]]]] \ No newline at end of file + \_EvalExec[[ROUNDTO(date{f}#0,1697760000000[DATETIME],1697846400000[DATETIME],1697932800000[DATETIME],1698019200000[DATETIME]) AS x#1]] + \_FieldExtractExec[date{f}#0]<[],[]> + \_EsQueryExec[all_types], indexMode[standard], [_doc{f}#2], limit[5], sort[[FieldSort[field=date{f}#0, direction=ASC, nulls=LAST]]] estimatedRowSize[1056] queryBuilderAndTags [[QueryBuilderAndTags[query=null, tags=[]]]] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testDateTruncNotTransformToQueryAndTags/round_to/local_physical_optimization.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testDateTruncNotTransformToQueryAndTags/round_to/local_physical_optimization.expected index 046b0b2603e13..f4aec5a235e42 100644 --- a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testDateTruncNotTransformToQueryAndTags/round_to/local_physical_optimization.expected +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testDateTruncNotTransformToQueryAndTags/round_to/local_physical_optimization.expected @@ -1,8 +1,8 @@ -ProjectExec[[!alias_integer, date{f}, x{r}]] -\_TopNExec[[Order[date{f},ASC,LAST]],5[INTEGER],null] - \_ExchangeExec[[!alias_integer, date{f}, x{r}],false] - \_ProjectExec[[!alias_integer, date{f}, x{r}]] +ProjectExec[[!alias_integer, date{f}#0, x{r}#1]] +\_TopNExec[[Order[date{f}#0,ASC,LAST]],5[INTEGER],null] + \_ExchangeExec[[!alias_integer, date{f}#0, x{r}#1],false] + \_ProjectExec[[!alias_integer, date{f}#0, x{r}#1]] \_FieldExtractExec[!alias_integer]<[],[]> - \_EvalExec[[ROUNDTO(date{f},1697760000000[DATETIME],1697846400000[DATETIME],1697932800000[DATETIME],1698019200000[DATETIME]) AS x]] - \_FieldExtractExec[date{f}]<[],[]> - \_EsQueryExec[all_types], indexMode[standard], [_doc{f}], limit[5], sort[[FieldSort[field=date{f}, direction=ASC, nulls=LAST]]] estimatedRowSize[1056] queryBuilderAndTags [[QueryBuilderAndTags[query=null, tags=[]]]] \ No newline at end of file + \_EvalExec[[ROUNDTO(date{f}#0,1697760000000[DATETIME],1697846400000[DATETIME],1697932800000[DATETIME],1698019200000[DATETIME]) AS x#1]] + \_FieldExtractExec[date{f}#0]<[],[]> + \_EsQueryExec[all_types], indexMode[standard], [_doc{f}#2], limit[5], sort[[FieldSort[field=date{f}#0, direction=ASC, nulls=LAST]]] estimatedRowSize[1056] queryBuilderAndTags [[QueryBuilderAndTags[query=null, tags=[]]]] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testForkWithStatsCountStarDateTrunc/local_physical_optimization.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testForkWithStatsCountStarDateTrunc/local_physical_optimization.expected index 689d91b4b0781..d6af15a5d5b6f 100644 --- a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testForkWithStatsCountStarDateTrunc/local_physical_optimization.expected +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testForkWithStatsCountStarDateTrunc/local_physical_optimization.expected @@ -1,14 +1,14 @@ LimitExec[1000[INTEGER],null] -\_MergeExec[[x{r}, y{r}, hd{r}, _fork{r}]] - |_ProjectExec[[x{r}, y{r}, hd{r}, _fork{r}]] - | \_EvalExec[[fork1[KEYWORD] AS _fork]] +\_MergeExec[[x{r}#0, y{r}#1, hd{r}#2, _fork{r}#3]] + |_ProjectExec[[x{r}#4, y{r}#5, hd{r}#6, _fork{r}#7]] + | \_EvalExec[[fork1[KEYWORD] AS _fork#7]] | \_LimitExec[1000[INTEGER],null] - | \_AggregateExec[[hd{r}],[COUNT(*[KEYWORD],true[BOOLEAN],PT0S[TIME_DURATION]) AS x, MAX(long{f},true[BOOLEAN],PT0S[TIME_DURATION]) AS y, hd{r}],FINAL,[hd{r}, $$x$count{r}, $$x$seen{r}, $$y$max{r}, $$y$seen{r}],null] - | \_ExchangeExec[[hd{r}, $$x$count{r}, $$x$seen{r}, $$y$max{r}, $$y$seen{r}],true] - | \_AggregateExec[[hd{r}],[COUNT(*[KEYWORD],true[BOOLEAN],PT0S[TIME_DURATION]) AS x, MAX(long{f},true[BOOLEAN],PT0S[TIME_DURATION]) AS y, hd{r}],INITIAL,[hd{r}, $$x$count{r}, $$x$seen{r}, $$y$max{r}, $$y$seen{r}],24] - | \_FieldExtractExec[long{f}]<[],[]> - | \_EvalExec[[$$date$round_to$datetime{f} AS hd]] - | \_EsQueryExec[all_types], indexMode[standard], [_doc{f}, $$date$round_to$datetime{f}], limit[], sort[] estimatedRowSize[20] queryBuilderAndTags [[QueryBuilderAndTags[query={ + | \_AggregateExec[[hd{r}#6],[COUNT(*[KEYWORD],true[BOOLEAN],PT0S[TIME_DURATION]) AS x#4, MAX(long{f}#8,true[BOOLEAN],PT0S[TIME_DURATION]) AS y#5, hd{r}#6],FINAL,[hd{r}#6, $$x$count{r}#9, $$x$seen{r}#10, $$y$max{r}#11, $$y$seen{r}#12],null] + | \_ExchangeExec[[hd{r}#6, $$x$count{r}#9, $$x$seen{r}#10, $$y$max{r}#11, $$y$seen{r}#12],true] + | \_AggregateExec[[hd{r}#6],[COUNT(*[KEYWORD],true[BOOLEAN],PT0S[TIME_DURATION]) AS x#4, MAX(long{f}#8,true[BOOLEAN],PT0S[TIME_DURATION]) AS y#5, hd{r}#6],INITIAL,[hd{r}#6, $$x$count{r}#13, $$x$seen{r}#14, $$y$max{r}#15, $$y$seen{r}#16],24] + | \_FieldExtractExec[long{f}#8]<[],[]> + | \_EvalExec[[$$date$round_to$datetime{f}#17 AS hd#6]] + | \_EsQueryExec[all_types], indexMode[standard], [_doc{f}#18, $$date$round_to$datetime{f}#17], limit[], sort[] estimatedRowSize[20] queryBuilderAndTags [[QueryBuilderAndTags[query={ "esql_single_value" : { "field" : "date", "next" : { @@ -83,13 +83,13 @@ LimitExec[1000[INTEGER],null] "boost" : 1.0 } }, tags=[null]]]] - \_ProjectExec[[x{r}, y{r}, hd{r}, _fork{r}]] - \_EvalExec[[fork2[KEYWORD] AS _fork]] + \_ProjectExec[[x{r}#19, y{r}#20, hd{r}#21, _fork{r}#7]] + \_EvalExec[[fork2[KEYWORD] AS _fork#7]] \_LimitExec[1000[INTEGER],null] - \_AggregateExec[[hd{r}],[COUNT(*[KEYWORD],true[BOOLEAN],PT0S[TIME_DURATION]) AS x, MIN(long{f},true[BOOLEAN],PT0S[TIME_DURATION]) AS y, hd{r}],FINAL,[hd{r}, $$x$count{r}, $$x$seen{r}, $$y$min{r}, $$y$seen{r}],null] - \_ExchangeExec[[hd{r}, $$x$count{r}, $$x$seen{r}, $$y$min{r}, $$y$seen{r}],true] - \_AggregateExec[[hd{r}],[COUNT(*[KEYWORD],true[BOOLEAN],PT0S[TIME_DURATION]) AS x, MIN(long{f},true[BOOLEAN],PT0S[TIME_DURATION]) AS y, hd{r}],INITIAL,[hd{r}, $$x$count{r}, $$x$seen{r}, $$y$min{r}, $$y$seen{r}],24] - \_FieldExtractExec[long{f}]<[],[]> - \_EvalExec[[DATETRUNC(P2D[DATE_PERIOD],date{f}) AS hd]] - \_FieldExtractExec[date{f}]<[],[]> - \_EsQueryExec[all_types], indexMode[standard], [_doc{f}], limit[], sort[] estimatedRowSize[28] queryBuilderAndTags [[QueryBuilderAndTags[query=null, tags=[]]]] \ No newline at end of file + \_AggregateExec[[hd{r}#21],[COUNT(*[KEYWORD],true[BOOLEAN],PT0S[TIME_DURATION]) AS x#19, MIN(long{f}#22,true[BOOLEAN],PT0S[TIME_DURATION]) AS y#20, hd{r}#21],FINAL,[hd{r}#21, $$x$count{r}#23, $$x$seen{r}#24, $$y$min{r}#25, $$y$seen{r}#26],null] + \_ExchangeExec[[hd{r}#21, $$x$count{r}#23, $$x$seen{r}#24, $$y$min{r}#25, $$y$seen{r}#26],true] + \_AggregateExec[[hd{r}#21],[COUNT(*[KEYWORD],true[BOOLEAN],PT0S[TIME_DURATION]) AS x#19, MIN(long{f}#22,true[BOOLEAN],PT0S[TIME_DURATION]) AS y#20, hd{r}#21],INITIAL,[hd{r}#21, $$x$count{r}#27, $$x$seen{r}#28, $$y$min{r}#29, $$y$seen{r}#30],24] + \_FieldExtractExec[long{f}#22]<[],[]> + \_EvalExec[[DATETRUNC(P2D[DATE_PERIOD],date{f}#31) AS hd#21]] + \_FieldExtractExec[date{f}#31]<[],[]> + \_EsQueryExec[all_types], indexMode[standard], [_doc{f}#32], limit[], sort[] estimatedRowSize[28] queryBuilderAndTags [[QueryBuilderAndTags[query=null, tags=[]]]] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testRoundToTransformToQueryAndTags/byte/local_physical_optimization.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testRoundToTransformToQueryAndTags/byte/local_physical_optimization.expected index 23bb5e9c22897..5315aaeb6b782 100644 --- a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testRoundToTransformToQueryAndTags/byte/local_physical_optimization.expected +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testRoundToTransformToQueryAndTags/byte/local_physical_optimization.expected @@ -1,7 +1,7 @@ LimitExec[1000[INTEGER],null] -\_AggregateExec[[x{r}],[COUNT(*[KEYWORD],true[BOOLEAN],PT0S[TIME_DURATION]) AS count(*), x{r}],FINAL,[x{r}, $$count(*)$count{r}, $$count(*)$seen{r}],null] - \_ExchangeExec[[x{r}, $$count(*)$count{r}, $$count(*)$seen{r}],true] - \_FilterExec[$$count(*)$count{r} > 0[LONG]] +\_AggregateExec[[x{r}#0],[COUNT(*[KEYWORD],true[BOOLEAN],PT0S[TIME_DURATION]) AS count(*)#1, x{r}#0],FINAL,[x{r}#0, $$count(*)$count{r}#2, $$count(*)$seen{r}#3],null] + \_ExchangeExec[[x{r}#0, $$count(*)$count{r}#2, $$count(*)$seen{r}#3],true] + \_FilterExec[$$count(*)$count{r}#4 > 0[LONG]] \_EsStatsQueryExec[all_types], statsByStat{queryBuilderAndTags=[QueryBuilderAndTags[query={ "esql_single_value" : { "field" : "byte", @@ -68,4 +68,4 @@ LimitExec[1000[INTEGER],null] ], "boost" : 1.0 } -}, tags=[null]]]}], query[][x{r}, $$count(*)$count{r}, $$count(*)$seen{r}], limit[], \ No newline at end of file +}, tags=[null]]]}], query[][x{r}#0, $$count(*)$count{r}#4, $$count(*)$seen{r}#5], limit[], \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testRoundToTransformToQueryAndTags/date/local_physical_optimization.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testRoundToTransformToQueryAndTags/date/local_physical_optimization.expected index 50845a7e8de0e..a917d136623a5 100644 --- a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testRoundToTransformToQueryAndTags/date/local_physical_optimization.expected +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testRoundToTransformToQueryAndTags/date/local_physical_optimization.expected @@ -1,7 +1,7 @@ LimitExec[1000[INTEGER],null] -\_AggregateExec[[x{r}],[COUNT(*[KEYWORD],true[BOOLEAN],PT0S[TIME_DURATION]) AS count(*), x{r}],FINAL,[x{r}, $$count(*)$count{r}, $$count(*)$seen{r}],null] - \_ExchangeExec[[x{r}, $$count(*)$count{r}, $$count(*)$seen{r}],true] - \_FilterExec[$$count(*)$count{r} > 0[LONG]] +\_AggregateExec[[x{r}#0],[COUNT(*[KEYWORD],true[BOOLEAN],PT0S[TIME_DURATION]) AS count(*)#1, x{r}#0],FINAL,[x{r}#0, $$count(*)$count{r}#2, $$count(*)$seen{r}#3],null] + \_ExchangeExec[[x{r}#0, $$count(*)$count{r}#2, $$count(*)$seen{r}#3],true] + \_FilterExec[$$count(*)$count{r}#4 > 0[LONG]] \_EsStatsQueryExec[all_types], statsByStat{queryBuilderAndTags=[QueryBuilderAndTags[query={ "esql_single_value" : { "field" : "date", @@ -76,4 +76,4 @@ LimitExec[1000[INTEGER],null] ], "boost" : 1.0 } -}, tags=[null]]]}], query[][x{r}, $$count(*)$count{r}, $$count(*)$seen{r}], limit[], \ No newline at end of file +}, tags=[null]]]}], query[][x{r}#0, $$count(*)$count{r}#4, $$count(*)$seen{r}#5], limit[], \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testRoundToTransformToQueryAndTags/date_nanos/local_physical_optimization.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testRoundToTransformToQueryAndTags/date_nanos/local_physical_optimization.expected index 082cecd12d88a..66b986835d508 100644 --- a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testRoundToTransformToQueryAndTags/date_nanos/local_physical_optimization.expected +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testRoundToTransformToQueryAndTags/date_nanos/local_physical_optimization.expected @@ -1,7 +1,7 @@ LimitExec[1000[INTEGER],null] -\_AggregateExec[[x{r}],[COUNT(*[KEYWORD],true[BOOLEAN],PT0S[TIME_DURATION]) AS count(*), x{r}],FINAL,[x{r}, $$count(*)$count{r}, $$count(*)$seen{r}],null] - \_ExchangeExec[[x{r}, $$count(*)$count{r}, $$count(*)$seen{r}],true] - \_FilterExec[$$count(*)$count{r} > 0[LONG]] +\_AggregateExec[[x{r}#0],[COUNT(*[KEYWORD],true[BOOLEAN],PT0S[TIME_DURATION]) AS count(*)#1, x{r}#0],FINAL,[x{r}#0, $$count(*)$count{r}#2, $$count(*)$seen{r}#3],null] + \_ExchangeExec[[x{r}#0, $$count(*)$count{r}#2, $$count(*)$seen{r}#3],true] + \_FilterExec[$$count(*)$count{r}#4 > 0[LONG]] \_EsStatsQueryExec[all_types], statsByStat{queryBuilderAndTags=[QueryBuilderAndTags[query={ "esql_single_value" : { "field" : "date_nanos", @@ -76,4 +76,4 @@ LimitExec[1000[INTEGER],null] ], "boost" : 1.0 } -}, tags=[null]]]}], query[][x{r}, $$count(*)$count{r}, $$count(*)$seen{r}], limit[], \ No newline at end of file +}, tags=[null]]]}], query[][x{r}#0, $$count(*)$count{r}#4, $$count(*)$seen{r}#5], limit[], \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testRoundToTransformToQueryAndTags/double/local_physical_optimization.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testRoundToTransformToQueryAndTags/double/local_physical_optimization.expected index 88f9a412070ba..d7f1b8f132836 100644 --- a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testRoundToTransformToQueryAndTags/double/local_physical_optimization.expected +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testRoundToTransformToQueryAndTags/double/local_physical_optimization.expected @@ -1,7 +1,7 @@ LimitExec[1000[INTEGER],null] -\_AggregateExec[[x{r}],[COUNT(*[KEYWORD],true[BOOLEAN],PT0S[TIME_DURATION]) AS count(*), x{r}],FINAL,[x{r}, $$count(*)$count{r}, $$count(*)$seen{r}],null] - \_ExchangeExec[[x{r}, $$count(*)$count{r}, $$count(*)$seen{r}],true] - \_FilterExec[$$count(*)$count{r} > 0[LONG]] +\_AggregateExec[[x{r}#0],[COUNT(*[KEYWORD],true[BOOLEAN],PT0S[TIME_DURATION]) AS count(*)#1, x{r}#0],FINAL,[x{r}#0, $$count(*)$count{r}#2, $$count(*)$seen{r}#3],null] + \_ExchangeExec[[x{r}#0, $$count(*)$count{r}#2, $$count(*)$seen{r}#3],true] + \_FilterExec[$$count(*)$count{r}#4 > 0[LONG]] \_EsStatsQueryExec[all_types], statsByStat{queryBuilderAndTags=[QueryBuilderAndTags[query={ "esql_single_value" : { "field" : "double", @@ -68,4 +68,4 @@ LimitExec[1000[INTEGER],null] ], "boost" : 1.0 } -}, tags=[null]]]}], query[][x{r}, $$count(*)$count{r}, $$count(*)$seen{r}], limit[], \ No newline at end of file +}, tags=[null]]]}], query[][x{r}#0, $$count(*)$count{r}#4, $$count(*)$seen{r}#5], limit[], \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testRoundToTransformToQueryAndTags/float/local_physical_optimization.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testRoundToTransformToQueryAndTags/float/local_physical_optimization.expected index 66daa7da9316f..299660977cb4e 100644 --- a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testRoundToTransformToQueryAndTags/float/local_physical_optimization.expected +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testRoundToTransformToQueryAndTags/float/local_physical_optimization.expected @@ -1,7 +1,7 @@ LimitExec[1000[INTEGER],null] -\_AggregateExec[[x{r}],[COUNT(*[KEYWORD],true[BOOLEAN],PT0S[TIME_DURATION]) AS count(*), x{r}],FINAL,[x{r}, $$count(*)$count{r}, $$count(*)$seen{r}],null] - \_ExchangeExec[[x{r}, $$count(*)$count{r}, $$count(*)$seen{r}],true] - \_FilterExec[$$count(*)$count{r} > 0[LONG]] +\_AggregateExec[[x{r}#0],[COUNT(*[KEYWORD],true[BOOLEAN],PT0S[TIME_DURATION]) AS count(*)#1, x{r}#0],FINAL,[x{r}#0, $$count(*)$count{r}#2, $$count(*)$seen{r}#3],null] + \_ExchangeExec[[x{r}#0, $$count(*)$count{r}#2, $$count(*)$seen{r}#3],true] + \_FilterExec[$$count(*)$count{r}#4 > 0[LONG]] \_EsStatsQueryExec[all_types], statsByStat{queryBuilderAndTags=[QueryBuilderAndTags[query={ "esql_single_value" : { "field" : "float", @@ -68,4 +68,4 @@ LimitExec[1000[INTEGER],null] ], "boost" : 1.0 } -}, tags=[null]]]}], query[][x{r}, $$count(*)$count{r}, $$count(*)$seen{r}], limit[], \ No newline at end of file +}, tags=[null]]]}], query[][x{r}#0, $$count(*)$count{r}#4, $$count(*)$seen{r}#5], limit[], \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testRoundToTransformToQueryAndTags/half_float/local_physical_optimization.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testRoundToTransformToQueryAndTags/half_float/local_physical_optimization.expected index f4b5190ff7395..7f6523fa91e37 100644 --- a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testRoundToTransformToQueryAndTags/half_float/local_physical_optimization.expected +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testRoundToTransformToQueryAndTags/half_float/local_physical_optimization.expected @@ -1,7 +1,7 @@ LimitExec[1000[INTEGER],null] -\_AggregateExec[[x{r}],[COUNT(*[KEYWORD],true[BOOLEAN],PT0S[TIME_DURATION]) AS count(*), x{r}],FINAL,[x{r}, $$count(*)$count{r}, $$count(*)$seen{r}],null] - \_ExchangeExec[[x{r}, $$count(*)$count{r}, $$count(*)$seen{r}],true] - \_FilterExec[$$count(*)$count{r} > 0[LONG]] +\_AggregateExec[[x{r}#0],[COUNT(*[KEYWORD],true[BOOLEAN],PT0S[TIME_DURATION]) AS count(*)#1, x{r}#0],FINAL,[x{r}#0, $$count(*)$count{r}#2, $$count(*)$seen{r}#3],null] + \_ExchangeExec[[x{r}#0, $$count(*)$count{r}#2, $$count(*)$seen{r}#3],true] + \_FilterExec[$$count(*)$count{r}#4 > 0[LONG]] \_EsStatsQueryExec[all_types], statsByStat{queryBuilderAndTags=[QueryBuilderAndTags[query={ "esql_single_value" : { "field" : "half_float", @@ -68,4 +68,4 @@ LimitExec[1000[INTEGER],null] ], "boost" : 1.0 } -}, tags=[null]]]}], query[][x{r}, $$count(*)$count{r}, $$count(*)$seen{r}], limit[], \ No newline at end of file +}, tags=[null]]]}], query[][x{r}#0, $$count(*)$count{r}#4, $$count(*)$seen{r}#5], limit[], \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testRoundToTransformToQueryAndTags/integer/local_physical_optimization.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testRoundToTransformToQueryAndTags/integer/local_physical_optimization.expected index fba0ce864cf57..bd20ccd161980 100644 --- a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testRoundToTransformToQueryAndTags/integer/local_physical_optimization.expected +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testRoundToTransformToQueryAndTags/integer/local_physical_optimization.expected @@ -1,7 +1,7 @@ LimitExec[1000[INTEGER],null] -\_AggregateExec[[x{r}],[COUNT(*[KEYWORD],true[BOOLEAN],PT0S[TIME_DURATION]) AS count(*), x{r}],FINAL,[x{r}, $$count(*)$count{r}, $$count(*)$seen{r}],null] - \_ExchangeExec[[x{r}, $$count(*)$count{r}, $$count(*)$seen{r}],true] - \_FilterExec[$$count(*)$count{r} > 0[LONG]] +\_AggregateExec[[x{r}#0],[COUNT(*[KEYWORD],true[BOOLEAN],PT0S[TIME_DURATION]) AS count(*)#1, x{r}#0],FINAL,[x{r}#0, $$count(*)$count{r}#2, $$count(*)$seen{r}#3],null] + \_ExchangeExec[[x{r}#0, $$count(*)$count{r}#2, $$count(*)$seen{r}#3],true] + \_FilterExec[$$count(*)$count{r}#4 > 0[LONG]] \_EsStatsQueryExec[all_types], statsByStat{queryBuilderAndTags=[QueryBuilderAndTags[query={ "esql_single_value" : { "field" : "integer", @@ -68,4 +68,4 @@ LimitExec[1000[INTEGER],null] ], "boost" : 1.0 } -}, tags=[null]]]}], query[][x{r}, $$count(*)$count{r}, $$count(*)$seen{r}], limit[], \ No newline at end of file +}, tags=[null]]]}], query[][x{r}#0, $$count(*)$count{r}#4, $$count(*)$seen{r}#5], limit[], \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testRoundToTransformToQueryAndTags/long/local_physical_optimization.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testRoundToTransformToQueryAndTags/long/local_physical_optimization.expected index 45671a3481eff..cf3a620024a4e 100644 --- a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testRoundToTransformToQueryAndTags/long/local_physical_optimization.expected +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testRoundToTransformToQueryAndTags/long/local_physical_optimization.expected @@ -1,7 +1,7 @@ LimitExec[1000[INTEGER],null] -\_AggregateExec[[x{r}],[COUNT(*[KEYWORD],true[BOOLEAN],PT0S[TIME_DURATION]) AS count(*), x{r}],FINAL,[x{r}, $$count(*)$count{r}, $$count(*)$seen{r}],null] - \_ExchangeExec[[x{r}, $$count(*)$count{r}, $$count(*)$seen{r}],true] - \_FilterExec[$$count(*)$count{r} > 0[LONG]] +\_AggregateExec[[x{r}#0],[COUNT(*[KEYWORD],true[BOOLEAN],PT0S[TIME_DURATION]) AS count(*)#1, x{r}#0],FINAL,[x{r}#0, $$count(*)$count{r}#2, $$count(*)$seen{r}#3],null] + \_ExchangeExec[[x{r}#0, $$count(*)$count{r}#2, $$count(*)$seen{r}#3],true] + \_FilterExec[$$count(*)$count{r}#4 > 0[LONG]] \_EsStatsQueryExec[all_types], statsByStat{queryBuilderAndTags=[QueryBuilderAndTags[query={ "esql_single_value" : { "field" : "long", @@ -68,4 +68,4 @@ LimitExec[1000[INTEGER],null] ], "boost" : 1.0 } -}, tags=[null]]]}], query[][x{r}, $$count(*)$count{r}, $$count(*)$seen{r}], limit[], \ No newline at end of file +}, tags=[null]]]}], query[][x{r}#0, $$count(*)$count{r}#4, $$count(*)$seen{r}#5], limit[], \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testRoundToTransformToQueryAndTags/scaled_float/local_physical_optimization.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testRoundToTransformToQueryAndTags/scaled_float/local_physical_optimization.expected index d2a0558821e41..c980fac8998ca 100644 --- a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testRoundToTransformToQueryAndTags/scaled_float/local_physical_optimization.expected +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testRoundToTransformToQueryAndTags/scaled_float/local_physical_optimization.expected @@ -1,7 +1,7 @@ LimitExec[1000[INTEGER],null] -\_AggregateExec[[x{r}],[COUNT(*[KEYWORD],true[BOOLEAN],PT0S[TIME_DURATION]) AS count(*), x{r}],FINAL,[x{r}, $$count(*)$count{r}, $$count(*)$seen{r}],null] - \_ExchangeExec[[x{r}, $$count(*)$count{r}, $$count(*)$seen{r}],true] - \_FilterExec[$$count(*)$count{r} > 0[LONG]] +\_AggregateExec[[x{r}#0],[COUNT(*[KEYWORD],true[BOOLEAN],PT0S[TIME_DURATION]) AS count(*)#1, x{r}#0],FINAL,[x{r}#0, $$count(*)$count{r}#2, $$count(*)$seen{r}#3],null] + \_ExchangeExec[[x{r}#0, $$count(*)$count{r}#2, $$count(*)$seen{r}#3],true] + \_FilterExec[$$count(*)$count{r}#4 > 0[LONG]] \_EsStatsQueryExec[all_types], statsByStat{queryBuilderAndTags=[QueryBuilderAndTags[query={ "esql_single_value" : { "field" : "scaled_float", @@ -68,4 +68,4 @@ LimitExec[1000[INTEGER],null] ], "boost" : 1.0 } -}, tags=[null]]]}], query[][x{r}, $$count(*)$count{r}, $$count(*)$seen{r}], limit[], \ No newline at end of file +}, tags=[null]]]}], query[][x{r}#0, $$count(*)$count{r}#4, $$count(*)$seen{r}#5], limit[], \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testRoundToTransformToQueryAndTags/short/local_physical_optimization.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testRoundToTransformToQueryAndTags/short/local_physical_optimization.expected index dda69d55339db..ad219641bde8c 100644 --- a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testRoundToTransformToQueryAndTags/short/local_physical_optimization.expected +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testRoundToTransformToQueryAndTags/short/local_physical_optimization.expected @@ -1,7 +1,7 @@ LimitExec[1000[INTEGER],null] -\_AggregateExec[[x{r}],[COUNT(*[KEYWORD],true[BOOLEAN],PT0S[TIME_DURATION]) AS count(*), x{r}],FINAL,[x{r}, $$count(*)$count{r}, $$count(*)$seen{r}],null] - \_ExchangeExec[[x{r}, $$count(*)$count{r}, $$count(*)$seen{r}],true] - \_FilterExec[$$count(*)$count{r} > 0[LONG]] +\_AggregateExec[[x{r}#0],[COUNT(*[KEYWORD],true[BOOLEAN],PT0S[TIME_DURATION]) AS count(*)#1, x{r}#0],FINAL,[x{r}#0, $$count(*)$count{r}#2, $$count(*)$seen{r}#3],null] + \_ExchangeExec[[x{r}#0, $$count(*)$count{r}#2, $$count(*)$seen{r}#3],true] + \_FilterExec[$$count(*)$count{r}#4 > 0[LONG]] \_EsStatsQueryExec[all_types], statsByStat{queryBuilderAndTags=[QueryBuilderAndTags[query={ "esql_single_value" : { "field" : "short", @@ -68,4 +68,4 @@ LimitExec[1000[INTEGER],null] ], "boost" : 1.0 } -}, tags=[null]]]}], query[][x{r}, $$count(*)$count{r}, $$count(*)$seen{r}], limit[], \ No newline at end of file +}, tags=[null]]]}], query[][x{r}#0, $$count(*)$count{r}#4, $$count(*)$seen{r}#5], limit[], \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testSubqueryWithCountStarAndDateTrunc/local_physical_optimization.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testSubqueryWithCountStarAndDateTrunc/local_physical_optimization.expected index 7dc015da213c7..9f3fe63e4a21f 100644 --- a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testSubqueryWithCountStarAndDateTrunc/local_physical_optimization.expected +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testSubqueryWithCountStarAndDateTrunc/local_physical_optimization.expected @@ -1,16 +1,16 @@ -ProjectExec[[x{r}, cnt{r}, date{r}]] +ProjectExec[[x{r}#0, cnt{r}#1, date{r}#2]] \_LimitExec[1000[INTEGER],null] - \_MergeExec[[alias_integer{r}, boolean{r}, byte{r}, constant_keyword-foo{r}, date{r}, date_nanos{r}, dense_vector{r}, double{r}, float{r}, half_float{r}, integer{r}, ip{r}, keyword{r}, long{r}, scaled_float{r}, semantic_text{r}, short{r}, text{r}, unsigned_long{r}, version{r}, wildcard{r}, cnt{r}, x{r}]] - |_ExchangeExec[[alias_integer{r}, boolean{f}, byte{f}, constant_keyword-foo{f}, date{f}, date_nanos{f}, dense_vector{f}, double{f}, float{f}, half_float{f}, integer{f}, ip{f}, keyword{f}, long{f}, scaled_float{f}, semantic_text{f}, short{f}, text{f}, unsigned_long{f}, version{f}, wildcard{f}, cnt{r}, x{r}],false] - | \_ProjectExec[[alias_integer{r}, boolean{f}, byte{f}, constant_keyword-foo{f}, date{f}, date_nanos{f}, dense_vector{f}, double{f}, float{f}, half_float{f}, integer{f}, ip{f}, keyword{f}, long{f}, scaled_float{f}, semantic_text{f}, short{f}, text{f}, unsigned_long{f}, version{f}, wildcard{f}, cnt{r}, x{r}]] - | \_FieldExtractExec[boolean{f}, byte{f}, constant_keyword-foo{f}, date{f}, date_nanos{f}, dense_vector{f}, double{f}, float{f}, half_float{f}, integer{f}, ip{f}, keyword{f}, long{f}, scaled_float{f}, semantic_text{f}, short{f}, text{f}, unsigned_long{f}, version{f}, wildcard{f}]<[],[]> - | \_EvalExec[[null[LONG] AS cnt, null[DATETIME] AS x, null[KEYWORD] AS alias_integer]] - | \_EsQueryExec[all_types], indexMode[standard], [_doc{f}], limit[], sort[] estimatedRowSize[6472] queryBuilderAndTags [[QueryBuilderAndTags[query=null, tags=[]]]] - \_ProjectExec[[alias_integer{r}, boolean{r}, byte{r}, constant_keyword-foo{r}, date{r}, date_nanos{r}, dense_vector{r}, double{r}, float{r}, half_float{r}, integer{r}, ip{r}, keyword{r}, long{r}, scaled_float{r}, semantic_text{r}, short{r}, text{r}, unsigned_long{r}, version{r}, wildcard{r}, cnt{r}, x{r}]] - \_EvalExec[[null[KEYWORD] AS alias_integer, null[BOOLEAN] AS boolean, null[INTEGER] AS byte, null[KEYWORD] AS constant_keyword-foo, null[DATETIME] AS date, null[DATE_NANOS] AS date_nanos, null[DENSE_VECTOR] AS dense_vector, null[DOUBLE] AS double, null[DOUBLE] AS float, null[DOUBLE] AS half_float, null[INTEGER] AS integer, null[IP] AS ip, null[KEYWORD] AS keyword, null[LONG] AS long, null[DOUBLE] AS scaled_float, null[TEXT] AS semantic_text, null[INTEGER] AS short, null[TEXT] AS text, null[UNSIGNED_LONG] AS unsigned_long, null[VERSION] AS version, null[KEYWORD] AS wildcard, null[KEYWORD] AS alias_integer]] - \_AggregateExec[[x{r}],[COUNT(*[KEYWORD],true[BOOLEAN],PT0S[TIME_DURATION]) AS cnt, x{r}],FINAL,[x{r}, $$cnt$count{r}, $$cnt$seen{r}],null] - \_ExchangeExec[[x{r}, $$cnt$count{r}, $$cnt$seen{r}],true] - \_FilterExec[$$cnt$count{r} > 0[LONG]] + \_MergeExec[[alias_integer{r}#3, boolean{r}#4, byte{r}#5, constant_keyword-foo{r}#6, date{r}#2, date_nanos{r}#7, dense_vector{r}#8, double{r}#9, float{r}#10, half_float{r}#11, integer{r}#12, ip{r}#13, keyword{r}#14, long{r}#15, scaled_float{r}#16, semantic_text{r}#17, short{r}#18, text{r}#19, unsigned_long{r}#20, version{r}#21, wildcard{r}#22, cnt{r}#1, x{r}#0]] + |_ExchangeExec[[alias_integer{r}#23, boolean{f}#24, byte{f}#25, constant_keyword-foo{f}#26, date{f}#27, date_nanos{f}#28, dense_vector{f}#29, double{f}#30, float{f}#31, half_float{f}#32, integer{f}#33, ip{f}#34, keyword{f}#35, long{f}#36, scaled_float{f}#37, semantic_text{f}#38, short{f}#39, text{f}#40, unsigned_long{f}#41, version{f}#42, wildcard{f}#43, cnt{r}#44, x{r}#45],false] + | \_ProjectExec[[alias_integer{r}#23, boolean{f}#24, byte{f}#25, constant_keyword-foo{f}#26, date{f}#27, date_nanos{f}#28, dense_vector{f}#29, double{f}#30, float{f}#31, half_float{f}#32, integer{f}#33, ip{f}#34, keyword{f}#35, long{f}#36, scaled_float{f}#37, semantic_text{f}#38, short{f}#39, text{f}#40, unsigned_long{f}#41, version{f}#42, wildcard{f}#43, cnt{r}#44, x{r}#45]] + | \_FieldExtractExec[boolean{f}#24, byte{f}#25, constant_keyword-foo{f}#26, date{f}#27, date_nanos{f}#28, dense_vector{f}#29, double{f}#30, float{f}#31, half_float{f}#32, integer{f}#33, ip{f}#34, keyword{f}#35, long{f}#36, scaled_float{f}#37, semantic_text{f}#38, short{f}#39, text{f}#40, unsigned_long{f}#41, version{f}#42, wildcard{f}#43]<[],[]> + | \_EvalExec[[null[LONG] AS cnt#44, null[DATETIME] AS x#45, null[KEYWORD] AS alias_integer#23]] + | \_EsQueryExec[all_types], indexMode[standard], [_doc{f}#46], limit[], sort[] estimatedRowSize[6472] queryBuilderAndTags [[QueryBuilderAndTags[query=null, tags=[]]]] + \_ProjectExec[[alias_integer{r}#47, boolean{r}#48, byte{r}#49, constant_keyword-foo{r}#50, date{r}#51, date_nanos{r}#52, dense_vector{r}#53, double{r}#54, float{r}#55, half_float{r}#56, integer{r}#57, ip{r}#58, keyword{r}#59, long{r}#60, scaled_float{r}#61, semantic_text{r}#62, short{r}#63, text{r}#64, unsigned_long{r}#65, version{r}#66, wildcard{r}#67, cnt{r}#68, x{r}#69]] + \_EvalExec[[null[KEYWORD] AS alias_integer#70, null[BOOLEAN] AS boolean#48, null[INTEGER] AS byte#49, null[KEYWORD] AS constant_keyword-foo#50, null[DATETIME] AS date#51, null[DATE_NANOS] AS date_nanos#52, null[DENSE_VECTOR] AS dense_vector#53, null[DOUBLE] AS double#54, null[DOUBLE] AS float#55, null[DOUBLE] AS half_float#56, null[INTEGER] AS integer#57, null[IP] AS ip#58, null[KEYWORD] AS keyword#59, null[LONG] AS long#60, null[DOUBLE] AS scaled_float#61, null[TEXT] AS semantic_text#62, null[INTEGER] AS short#63, null[TEXT] AS text#64, null[UNSIGNED_LONG] AS unsigned_long#65, null[VERSION] AS version#66, null[KEYWORD] AS wildcard#67, null[KEYWORD] AS alias_integer#47]] + \_AggregateExec[[x{r}#69],[COUNT(*[KEYWORD],true[BOOLEAN],PT0S[TIME_DURATION]) AS cnt#68, x{r}#69],FINAL,[x{r}#69, $$cnt$count{r}#71, $$cnt$seen{r}#72],null] + \_ExchangeExec[[x{r}#69, $$cnt$count{r}#71, $$cnt$seen{r}#72],true] + \_FilterExec[$$cnt$count{r}#73 > 0[LONG]] \_EsStatsQueryExec[all_types], statsByStat{queryBuilderAndTags=[QueryBuilderAndTags[query={ "esql_single_value" : { "field" : "date", @@ -85,4 +85,4 @@ ProjectExec[[x{r}, cnt{r}, date{r}]] ], "boost" : 1.0 } -}, tags=[null]]]}], query[][x{r}, $$cnt$count{r}, $$cnt$seen{r}], limit[], \ No newline at end of file +}, tags=[null]]]}], query[][x{r}#69, $$cnt$count{r}#73, $$cnt$seen{r}#74], limit[], \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testBasicTopNLateMaterialization/local_reduce_physical_optimization_data_driver.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testBasicTopNLateMaterialization/local_reduce_physical_optimization_data_driver.expected index 79d08e098a4ac..71c01677f83a5 100644 --- a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testBasicTopNLateMaterialization/local_reduce_physical_optimization_data_driver.expected +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testBasicTopNLateMaterialization/local_reduce_physical_optimization_data_driver.expected @@ -1,4 +1,4 @@ -ExchangeSinkExec[[emp_no{f}, hire_date{f}, salary{f}],false] -\_ProjectExec[[_doc{f}, hire_date{f}]] - \_FieldExtractExec[hire_date{f}]<[],[]> - \_EsQueryExec[employees], indexMode[standard], [_doc{f}], limit[20], sort[[FieldSort[field=hire_date{f}, direction=ASC, nulls=LAST]]] estimatedRowSize[24] queryBuilderAndTags [[QueryBuilderAndTags[query=null, tags=[]]]] \ No newline at end of file +ExchangeSinkExec[[emp_no{f}#0, hire_date{f}#1, salary{f}#2],false] +\_ProjectExec[[_doc{f}#3, hire_date{f}#1]] + \_FieldExtractExec[hire_date{f}#1]<[],[]> + \_EsQueryExec[employees], indexMode[standard], [_doc{f}#3], limit[20], sort[[FieldSort[field=hire_date{f}#1, direction=ASC, nulls=LAST]]] estimatedRowSize[24] queryBuilderAndTags [[QueryBuilderAndTags[query=null, tags=[]]]] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testBasicTopNLateMaterialization/local_reduce_planned_data_driver.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testBasicTopNLateMaterialization/local_reduce_planned_data_driver.expected index 42c2f1deccb35..fc4d011c9a8fb 100644 --- a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testBasicTopNLateMaterialization/local_reduce_planned_data_driver.expected +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testBasicTopNLateMaterialization/local_reduce_planned_data_driver.expected @@ -1,5 +1,5 @@ -ExchangeSinkExec[[emp_no{f}, hire_date{f}, salary{f}],false] +ExchangeSinkExec[[emp_no{f}#0, hire_date{f}#1, salary{f}#2],false] \_FragmentExec[filter=null, estimatedRowSize=0, reducer=[], fragment=[<> -Project[[_doc{f}, hire_date{f}]] -\_TopN[[Order[hire_date{f},ASC,LAST]],20[INTEGER],false] - \_EsRelation[employees][_doc{f}, avg_worked_seconds{f}, birth_date{f}, emp_no{f}, first_name{f}, gender{f}, height{f}, height.float{f}, height.half_float{f}, height.scaled_float{f}, hire_date{f}, is_rehired{f}, job_positions{f}, languages{f}, languages.byte{f}, languages.long{f}, languages.short{f}, last_name{f}, salary{f}, salary_change{f}, salary_change.int{f}, salary_change.keyword{f}, salary_change.long{f}, still_hired{f}]<>]] \ No newline at end of file +Project[[_doc{f}#3, hire_date{f}#1]] +\_TopN[[Order[hire_date{f}#1,ASC,LAST]],20[INTEGER],false] + \_EsRelation[employees][_doc{f}#3, avg_worked_seconds{f}#4, birth_date{f}#5, emp_no{f}#0, first_name{f}#6, gender{f}#7, height{f}#8, height.float{f}#9, height.half_float{f}#10, height.scaled_float{f}#11, hire_date{f}#1, is_rehired{f}#12, job_positions{f}#13, languages{f}#14, languages.byte{f}#15, languages.long{f}#16, languages.short{f}#17, last_name{f}#18, salary{f}#2, salary_change{f}#19, salary_change.int{f}#20, salary_change.keyword{f}#21, salary_change.long{f}#22, still_hired{f}#23]<>]] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testBasicTopNLateMaterialization/local_reduce_planned_reduce_driver.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testBasicTopNLateMaterialization/local_reduce_planned_reduce_driver.expected index 378271a5e3f37..4b4fc0c891ac1 100644 --- a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testBasicTopNLateMaterialization/local_reduce_planned_reduce_driver.expected +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testBasicTopNLateMaterialization/local_reduce_planned_reduce_driver.expected @@ -1,5 +1,5 @@ -ExchangeSinkExec[[emp_no{f}, hire_date{f}, salary{f}],false] -\_ProjectExec[[emp_no{f}, hire_date{f}, salary{f}]] - \_FieldExtractExec[emp_no{f}, salary{f}]<[],[]> - \_TopNExec[[Order[hire_date{f},ASC,LAST]],20[INTEGER],36] - \_ExchangeSourceExec[[_doc{f}, hire_date{f}],false] \ No newline at end of file +ExchangeSinkExec[[emp_no{f}#0, hire_date{f}#1, salary{f}#2],false] +\_ProjectExec[[emp_no{f}#0, hire_date{f}#1, salary{f}#2]] + \_FieldExtractExec[emp_no{f}#0, salary{f}#2]<[],[]> + \_TopNExec[[Order[hire_date{f}#1,ASC,LAST]],20[INTEGER],36] + \_ExchangeSourceExec[[_doc{f}#3, hire_date{f}#1],false] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testBasicTopNLateMaterialization/physical_optimization.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testBasicTopNLateMaterialization/physical_optimization.expected index cd76be3897e14..84b502cae4e25 100644 --- a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testBasicTopNLateMaterialization/physical_optimization.expected +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testBasicTopNLateMaterialization/physical_optimization.expected @@ -1,7 +1,7 @@ -ProjectExec[[hire_date{f}, salary{f}, emp_no{f}]] -\_TopNExec[[Order[hire_date{f},ASC,LAST]],20[INTEGER],null] - \_ExchangeExec[[emp_no{f}, hire_date{f}, salary{f}],false] +ProjectExec[[hire_date{f}#0, salary{f}#1, emp_no{f}#2]] +\_TopNExec[[Order[hire_date{f}#0,ASC,LAST]],20[INTEGER],null] + \_ExchangeExec[[emp_no{f}#2, hire_date{f}#0, salary{f}#1],false] \_FragmentExec[filter=null, estimatedRowSize=0, reducer=[], fragment=[<> -Project[[emp_no{f}, hire_date{f}, salary{f}]] -\_TopN[[Order[hire_date{f},ASC,LAST]],20[INTEGER],false] - \_EsRelation[employees][avg_worked_seconds{f}, birth_date{f}, emp_no{f}, first_name{f}, gender{f}, height{f}, height.float{f}, height.half_float{f}, height.scaled_float{f}, hire_date{f}, is_rehired{f}, job_positions{f}, languages{f}, languages.byte{f}, languages.long{f}, languages.short{f}, last_name{f}, salary{f}, salary_change{f}, salary_change.int{f}, salary_change.keyword{f}, salary_change.long{f}, still_hired{f}]<>]] \ No newline at end of file +Project[[emp_no{f}#2, hire_date{f}#0, salary{f}#1]] +\_TopN[[Order[hire_date{f}#0,ASC,LAST]],20[INTEGER],false] + \_EsRelation[employees][avg_worked_seconds{f}#3, birth_date{f}#4, emp_no{f}#2, first_name{f}#5, gender{f}#6, height{f}#7, height.float{f}#8, height.half_float{f}#9, height.scaled_float{f}#10, hire_date{f}#0, is_rehired{f}#11, job_positions{f}#12, languages{f}#13, languages.byte{f}#14, languages.long{f}#15, languages.short{f}#16, last_name{f}#17, salary{f}#1, salary_change{f}#18, salary_change.int{f}#19, salary_change.keyword{f}#20, salary_change.long{f}#21, still_hired{f}#22]<>]] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testExpressionSortTopNKeepAfterSort/local_reduce_physical_optimization_data_driver.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testExpressionSortTopNKeepAfterSort/local_reduce_physical_optimization_data_driver.expected index 6c0cb294fc861..b70e2da30d8d9 100644 --- a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testExpressionSortTopNKeepAfterSort/local_reduce_physical_optimization_data_driver.expected +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testExpressionSortTopNKeepAfterSort/local_reduce_physical_optimization_data_driver.expected @@ -1,6 +1,6 @@ -ExchangeSinkExec[[hire_date{f}, $$order_by{r}],false] -\_ProjectExec[[_doc{f}, $$order_by{r}]] - \_TopNExec[[Order[$$order_by{r},ASC,LAST]],20[INTEGER],36] - \_EvalExec[[SIN(height{f}) * 2[INTEGER] AS $$order_by]] - \_FieldExtractExec[height{f}]<[],[]> - \_EsQueryExec[employees], indexMode[standard], [_doc{f}], limit[], sort[] estimatedRowSize[20] queryBuilderAndTags [[QueryBuilderAndTags[query=null, tags=[]]]] \ No newline at end of file +ExchangeSinkExec[[hire_date{f}#0, $$order_by$0$1{r}#1],false] +\_ProjectExec[[_doc{f}#2, $$order_by$0$1{r}#1]] + \_TopNExec[[Order[$$order_by$0$1{r}#1,ASC,LAST]],20[INTEGER],36] + \_EvalExec[[SIN(height{f}#3) * 2[INTEGER] AS $$order_by$0$1#1]] + \_FieldExtractExec[height{f}#3]<[],[]> + \_EsQueryExec[employees], indexMode[standard], [_doc{f}#2], limit[], sort[] estimatedRowSize[20] queryBuilderAndTags [[QueryBuilderAndTags[query=null, tags=[]]]] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testExpressionSortTopNKeepAfterSort/local_reduce_planned_data_driver.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testExpressionSortTopNKeepAfterSort/local_reduce_planned_data_driver.expected index 2c2c810fdcd5f..6e7579d93480f 100644 --- a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testExpressionSortTopNKeepAfterSort/local_reduce_planned_data_driver.expected +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testExpressionSortTopNKeepAfterSort/local_reduce_planned_data_driver.expected @@ -1,6 +1,6 @@ -ExchangeSinkExec[[hire_date{f}, $$order_by{r}],false] +ExchangeSinkExec[[hire_date{f}#0, $$order_by$0$1{r}#1],false] \_FragmentExec[filter=null, estimatedRowSize=0, reducer=[], fragment=[<> -Project[[_doc{f}, $$order_by{r}]] -\_TopN[[Order[$$order_by{r},ASC,LAST]],20[INTEGER],false] - \_Eval[[SIN(height{f}) * 2[INTEGER] AS $$order_by]] - \_EsRelation[employees][_doc{f}, avg_worked_seconds{f}, birth_date{f}, emp_no{f}, first_name{f}, gender{f}, height{f}, height.float{f}, height.half_float{f}, height.scaled_float{f}, hire_date{f}, is_rehired{f}, job_positions{f}, languages{f}, languages.byte{f}, languages.long{f}, languages.short{f}, last_name{f}, salary{f}, salary_change{f}, salary_change.int{f}, salary_change.keyword{f}, salary_change.long{f}, still_hired{f}]<>]] \ No newline at end of file +Project[[_doc{f}#2, $$order_by$0$1{r}#1]] +\_TopN[[Order[$$order_by$0$1{r}#1,ASC,LAST]],20[INTEGER],false] + \_Eval[[SIN(height{f}#3) * 2[INTEGER] AS $$order_by$0$1#1]] + \_EsRelation[employees][_doc{f}#2, avg_worked_seconds{f}#4, birth_date{f}#5, emp_no{f}#6, first_name{f}#7, gender{f}#8, height{f}#3, height.float{f}#9, height.half_float{f}#10, height.scaled_float{f}#11, hire_date{f}#0, is_rehired{f}#12, job_positions{f}#13, languages{f}#14, languages.byte{f}#15, languages.long{f}#16, languages.short{f}#17, last_name{f}#18, salary{f}#19, salary_change{f}#20, salary_change.int{f}#21, salary_change.keyword{f}#22, salary_change.long{f}#23, still_hired{f}#24]<>]] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testExpressionSortTopNKeepAfterSort/local_reduce_planned_reduce_driver.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testExpressionSortTopNKeepAfterSort/local_reduce_planned_reduce_driver.expected index 6122b8f73ddfa..b69f8a120e20a 100644 --- a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testExpressionSortTopNKeepAfterSort/local_reduce_planned_reduce_driver.expected +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testExpressionSortTopNKeepAfterSort/local_reduce_planned_reduce_driver.expected @@ -1,5 +1,5 @@ -ExchangeSinkExec[[hire_date{f}, $$order_by{r}],false] -\_ProjectExec[[hire_date{f}, $$order_by{r}]] - \_FieldExtractExec[hire_date{f}]<[],[]> - \_TopNExec[[Order[$$order_by{r},ASC,LAST]],20[INTEGER],36] - \_ExchangeSourceExec[[_doc{f}, $$order_by{r}],false] \ No newline at end of file +ExchangeSinkExec[[hire_date{f}#0, $$order_by$0$1{r}#1],false] +\_ProjectExec[[hire_date{f}#0, $$order_by$0$1{r}#1]] + \_FieldExtractExec[hire_date{f}#0]<[],[]> + \_TopNExec[[Order[$$order_by$0$1{r}#1,ASC,LAST]],20[INTEGER],36] + \_ExchangeSourceExec[[_doc{f}#2, $$order_by$0$1{r}#1],false] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testExpressionSortTopNKeepAfterSort/physical_optimization.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testExpressionSortTopNKeepAfterSort/physical_optimization.expected index 379de6ff82e29..40e41a83c3210 100644 --- a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testExpressionSortTopNKeepAfterSort/physical_optimization.expected +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testExpressionSortTopNKeepAfterSort/physical_optimization.expected @@ -1,8 +1,8 @@ -ProjectExec[[hire_date{f}]] -\_TopNExec[[Order[$$order_by{r},ASC,LAST]],20[INTEGER],null] - \_ExchangeExec[[hire_date{f}, $$order_by{r}],false] +ProjectExec[[hire_date{f}#0]] +\_TopNExec[[Order[$$order_by$0$1{r}#1,ASC,LAST]],20[INTEGER],null] + \_ExchangeExec[[hire_date{f}#0, $$order_by$0$1{r}#1],false] \_FragmentExec[filter=null, estimatedRowSize=0, reducer=[], fragment=[<> -Project[[hire_date{f}, $$order_by{r}]] -\_TopN[[Order[$$order_by{r},ASC,LAST]],20[INTEGER],false] - \_Eval[[SIN(height{f}) * 2[INTEGER] AS $$order_by]] - \_EsRelation[employees][avg_worked_seconds{f}, birth_date{f}, emp_no{f}, first_name{f}, gender{f}, height{f}, height.float{f}, height.half_float{f}, height.scaled_float{f}, hire_date{f}, is_rehired{f}, job_positions{f}, languages{f}, languages.byte{f}, languages.long{f}, languages.short{f}, last_name{f}, salary{f}, salary_change{f}, salary_change.int{f}, salary_change.keyword{f}, salary_change.long{f}, still_hired{f}]<>]] \ No newline at end of file +Project[[hire_date{f}#0, $$order_by$0$1{r}#1]] +\_TopN[[Order[$$order_by$0$1{r}#1,ASC,LAST]],20[INTEGER],false] + \_Eval[[SIN(height{f}#2) * 2[INTEGER] AS $$order_by$0$1#1]] + \_EsRelation[employees][avg_worked_seconds{f}#3, birth_date{f}#4, emp_no{f}#5, first_name{f}#6, gender{f}#7, height{f}#2, height.float{f}#8, height.half_float{f}#9, height.scaled_float{f}#10, hire_date{f}#0, is_rehired{f}#11, job_positions{f}#12, languages{f}#13, languages.byte{f}#14, languages.long{f}#15, languages.short{f}#16, last_name{f}#17, salary{f}#18, salary_change{f}#19, salary_change.int{f}#20, salary_change.keyword{f}#21, salary_change.long{f}#22, still_hired{f}#23]<>]] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testExpressionSortTopNKeepBeforeSort/local_reduce_physical_optimization_data_driver.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testExpressionSortTopNKeepBeforeSort/local_reduce_physical_optimization_data_driver.expected index abec74e514128..d7b0d2e276b29 100644 --- a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testExpressionSortTopNKeepBeforeSort/local_reduce_physical_optimization_data_driver.expected +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testExpressionSortTopNKeepBeforeSort/local_reduce_physical_optimization_data_driver.expected @@ -1,6 +1,6 @@ -ExchangeSinkExec[[height{f}, hire_date{f}, $$order_by{r}],false] -\_ProjectExec[[_doc{f}, height{f}, $$order_by{r}]] - \_TopNExec[[Order[$$order_by{r},ASC,LAST]],20[INTEGER],36] - \_EvalExec[[SIN(height{f}) * 2[INTEGER] AS $$order_by]] - \_FieldExtractExec[height{f}]<[],[]> - \_EsQueryExec[employees], indexMode[standard], [_doc{f}], limit[], sort[] estimatedRowSize[20] queryBuilderAndTags [[QueryBuilderAndTags[query=null, tags=[]]]] \ No newline at end of file +ExchangeSinkExec[[height{f}#0, hire_date{f}#1, $$order_by$0$0{r}#2],false] +\_ProjectExec[[_doc{f}#3, height{f}#0, $$order_by$0$0{r}#2]] + \_TopNExec[[Order[$$order_by$0$0{r}#2,ASC,LAST]],20[INTEGER],36] + \_EvalExec[[SIN(height{f}#0) * 2[INTEGER] AS $$order_by$0$0#2]] + \_FieldExtractExec[height{f}#0]<[],[]> + \_EsQueryExec[employees], indexMode[standard], [_doc{f}#3], limit[], sort[] estimatedRowSize[20] queryBuilderAndTags [[QueryBuilderAndTags[query=null, tags=[]]]] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testExpressionSortTopNKeepBeforeSort/local_reduce_planned_data_driver.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testExpressionSortTopNKeepBeforeSort/local_reduce_planned_data_driver.expected index d6d06ec07d272..44d16e2751dd8 100644 --- a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testExpressionSortTopNKeepBeforeSort/local_reduce_planned_data_driver.expected +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testExpressionSortTopNKeepBeforeSort/local_reduce_planned_data_driver.expected @@ -1,6 +1,6 @@ -ExchangeSinkExec[[height{f}, hire_date{f}, $$order_by{r}],false] +ExchangeSinkExec[[height{f}#0, hire_date{f}#1, $$order_by$0$0{r}#2],false] \_FragmentExec[filter=null, estimatedRowSize=0, reducer=[], fragment=[<> -Project[[_doc{f}, height{f}, $$order_by{r}]] -\_TopN[[Order[$$order_by{r},ASC,LAST]],20[INTEGER],false] - \_Eval[[SIN(height{f}) * 2[INTEGER] AS $$order_by]] - \_EsRelation[employees][_doc{f}, avg_worked_seconds{f}, birth_date{f}, emp_no{f}, first_name{f}, gender{f}, height{f}, height.float{f}, height.half_float{f}, height.scaled_float{f}, hire_date{f}, is_rehired{f}, job_positions{f}, languages{f}, languages.byte{f}, languages.long{f}, languages.short{f}, last_name{f}, salary{f}, salary_change{f}, salary_change.int{f}, salary_change.keyword{f}, salary_change.long{f}, still_hired{f}]<>]] \ No newline at end of file +Project[[_doc{f}#3, height{f}#0, $$order_by$0$0{r}#2]] +\_TopN[[Order[$$order_by$0$0{r}#2,ASC,LAST]],20[INTEGER],false] + \_Eval[[SIN(height{f}#0) * 2[INTEGER] AS $$order_by$0$0#2]] + \_EsRelation[employees][_doc{f}#3, avg_worked_seconds{f}#4, birth_date{f}#5, emp_no{f}#6, first_name{f}#7, gender{f}#8, height{f}#0, height.float{f}#9, height.half_float{f}#10, height.scaled_float{f}#11, hire_date{f}#1, is_rehired{f}#12, job_positions{f}#13, languages{f}#14, languages.byte{f}#15, languages.long{f}#16, languages.short{f}#17, last_name{f}#18, salary{f}#19, salary_change{f}#20, salary_change.int{f}#21, salary_change.keyword{f}#22, salary_change.long{f}#23, still_hired{f}#24]<>]] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testExpressionSortTopNKeepBeforeSort/local_reduce_planned_reduce_driver.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testExpressionSortTopNKeepBeforeSort/local_reduce_planned_reduce_driver.expected index e19d24b8b2b9f..45f5637b6faac 100644 --- a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testExpressionSortTopNKeepBeforeSort/local_reduce_planned_reduce_driver.expected +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testExpressionSortTopNKeepBeforeSort/local_reduce_planned_reduce_driver.expected @@ -1,5 +1,5 @@ -ExchangeSinkExec[[height{f}, hire_date{f}, $$order_by{r}],false] -\_ProjectExec[[height{f}, hire_date{f}, $$order_by{r}]] - \_FieldExtractExec[hire_date{f}]<[],[]> - \_TopNExec[[Order[$$order_by{r},ASC,LAST]],20[INTEGER],44] - \_ExchangeSourceExec[[_doc{f}, height{f}, $$order_by{r}],false] \ No newline at end of file +ExchangeSinkExec[[height{f}#0, hire_date{f}#1, $$order_by$0$0{r}#2],false] +\_ProjectExec[[height{f}#0, hire_date{f}#1, $$order_by$0$0{r}#2]] + \_FieldExtractExec[hire_date{f}#1]<[],[]> + \_TopNExec[[Order[$$order_by$0$0{r}#2,ASC,LAST]],20[INTEGER],44] + \_ExchangeSourceExec[[_doc{f}#3, height{f}#0, $$order_by$0$0{r}#2],false] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testExpressionSortTopNKeepBeforeSort/physical_optimization.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testExpressionSortTopNKeepBeforeSort/physical_optimization.expected index dd1f613d8bedf..083b9f2af3acf 100644 --- a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testExpressionSortTopNKeepBeforeSort/physical_optimization.expected +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testExpressionSortTopNKeepBeforeSort/physical_optimization.expected @@ -1,8 +1,8 @@ -ProjectExec[[hire_date{f}, height{f}]] -\_TopNExec[[Order[$$order_by{r},ASC,LAST]],20[INTEGER],null] - \_ExchangeExec[[height{f}, hire_date{f}, $$order_by{r}],false] +ProjectExec[[hire_date{f}#0, height{f}#1]] +\_TopNExec[[Order[$$order_by$0$0{r}#2,ASC,LAST]],20[INTEGER],null] + \_ExchangeExec[[height{f}#1, hire_date{f}#0, $$order_by$0$0{r}#2],false] \_FragmentExec[filter=null, estimatedRowSize=0, reducer=[], fragment=[<> -Project[[height{f}, hire_date{f}, $$order_by{r}]] -\_TopN[[Order[$$order_by{r},ASC,LAST]],20[INTEGER],false] - \_Eval[[SIN(height{f}) * 2[INTEGER] AS $$order_by]] - \_EsRelation[employees][avg_worked_seconds{f}, birth_date{f}, emp_no{f}, first_name{f}, gender{f}, height{f}, height.float{f}, height.half_float{f}, height.scaled_float{f}, hire_date{f}, is_rehired{f}, job_positions{f}, languages{f}, languages.byte{f}, languages.long{f}, languages.short{f}, last_name{f}, salary{f}, salary_change{f}, salary_change.int{f}, salary_change.keyword{f}, salary_change.long{f}, still_hired{f}]<>]] \ No newline at end of file +Project[[height{f}#1, hire_date{f}#0, $$order_by$0$0{r}#2]] +\_TopN[[Order[$$order_by$0$0{r}#2,ASC,LAST]],20[INTEGER],false] + \_Eval[[SIN(height{f}#1) * 2[INTEGER] AS $$order_by$0$0#2]] + \_EsRelation[employees][avg_worked_seconds{f}#3, birth_date{f}#4, emp_no{f}#5, first_name{f}#6, gender{f}#7, height{f}#1, height.float{f}#8, height.half_float{f}#9, height.scaled_float{f}#10, hire_date{f}#0, is_rehired{f}#11, job_positions{f}#12, languages{f}#13, languages.byte{f}#14, languages.long{f}#15, languages.short{f}#16, last_name{f}#17, salary{f}#18, salary_change{f}#19, salary_change.int{f}#20, salary_change.keyword{f}#21, salary_change.long{f}#22, still_hired{f}#23]<>]] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testLookupJoinOnDataNode/local_reduce_physical_optimization_data_driver.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testLookupJoinOnDataNode/local_reduce_physical_optimization_data_driver.expected index afa8bc120313d..ebbbae1cfcc6d 100644 --- a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testLookupJoinOnDataNode/local_reduce_physical_optimization_data_driver.expected +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testLookupJoinOnDataNode/local_reduce_physical_optimization_data_driver.expected @@ -1,11 +1,11 @@ -ExchangeSinkExec[[avg_worked_seconds{f}, birth_date{f}, emp_no{f}, first_name{f}, gender{f}, height{f}, height.float{f}, height.half_float{f}, height.scaled_float{f}, hire_date{f}, is_rehired{f}, job_positions{f}, languages{f}, languages.byte{f}, languages.long{f}, languages.short{f}, last_name{f}, salary{f}, salary_change{f}, salary_change.int{f}, salary_change.keyword{f}, salary_change.long{f}, still_hired{f}, language_code{r}, language_name{f}],false] -\_ProjectExec[[_doc{f}, emp_no{f}, languages{f}, language_code{r}, language_name{f}]] - \_TopNExec[[Order[emp_no{f},ASC,LAST]],20[INTEGER],82] - \_FieldExtractExec[emp_no{f}]<[],[]> - \_LookupJoinExec[[language_code{r}],[language_code{f}],[language_name{f}],null] - |_EvalExec[[languages{f} AS language_code]] - | \_FieldExtractExec[languages{f}]<[],[]> - | \_EsQueryExec[employees], indexMode[standard], [_doc{f}], limit[], sort[] estimatedRowSize[66] queryBuilderAndTags [[QueryBuilderAndTags[query={ +ExchangeSinkExec[[avg_worked_seconds{f}#0, birth_date{f}#1, emp_no{f}#2, first_name{f}#3, gender{f}#4, height{f}#5, height.float{f}#6, height.half_float{f}#7, height.scaled_float{f}#8, hire_date{f}#9, is_rehired{f}#10, job_positions{f}#11, languages{f}#12, languages.byte{f}#13, languages.long{f}#14, languages.short{f}#15, last_name{f}#16, salary{f}#17, salary_change{f}#18, salary_change.int{f}#19, salary_change.keyword{f}#20, salary_change.long{f}#21, still_hired{f}#22, language_code{r}#23, language_name{f}#24],false] +\_ProjectExec[[_doc{f}#25, emp_no{f}#2, languages{f}#12, language_code{r}#23, language_name{f}#24]] + \_TopNExec[[Order[emp_no{f}#2,ASC,LAST]],20[INTEGER],82] + \_FieldExtractExec[emp_no{f}#2]<[],[]> + \_LookupJoinExec[[language_code{r}#23],[language_code{f}#26],[language_name{f}#24],null] + |_EvalExec[[languages{f}#12 AS language_code#23]] + | \_FieldExtractExec[languages{f}#12]<[],[]> + | \_EsQueryExec[employees], indexMode[standard], [_doc{f}#25], limit[], sort[] estimatedRowSize[66] queryBuilderAndTags [[QueryBuilderAndTags[query={ "esql_single_value" : { "field" : "emp_no", "next" : { @@ -22,4 +22,4 @@ ExchangeSinkExec[[avg_worked_seconds{f}, birth_date{f}, emp_no{f}, first_name{f} } }, tags=[]]]] \_FragmentExec[filter=null, estimatedRowSize=0, reducer=[], fragment=[<> -EsRelation[languages_lookup][LOOKUP][language_code{f}, language_name{f}]<>]] \ No newline at end of file +EsRelation[languages_lookup][LOOKUP][language_code{f}#26, language_name{f}#24]<>]] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testLookupJoinOnDataNode/local_reduce_planned_data_driver.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testLookupJoinOnDataNode/local_reduce_planned_data_driver.expected index ef61e922e587d..7ff68ac134d83 100644 --- a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testLookupJoinOnDataNode/local_reduce_planned_data_driver.expected +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testLookupJoinOnDataNode/local_reduce_planned_data_driver.expected @@ -1,9 +1,9 @@ -ExchangeSinkExec[[avg_worked_seconds{f}, birth_date{f}, emp_no{f}, first_name{f}, gender{f}, height{f}, height.float{f}, height.half_float{f}, height.scaled_float{f}, hire_date{f}, is_rehired{f}, job_positions{f}, languages{f}, languages.byte{f}, languages.long{f}, languages.short{f}, last_name{f}, salary{f}, salary_change{f}, salary_change.int{f}, salary_change.keyword{f}, salary_change.long{f}, still_hired{f}, language_code{r}, language_name{f}],false] +ExchangeSinkExec[[avg_worked_seconds{f}#0, birth_date{f}#1, emp_no{f}#2, first_name{f}#3, gender{f}#4, height{f}#5, height.float{f}#6, height.half_float{f}#7, height.scaled_float{f}#8, hire_date{f}#9, is_rehired{f}#10, job_positions{f}#11, languages{f}#12, languages.byte{f}#13, languages.long{f}#14, languages.short{f}#15, last_name{f}#16, salary{f}#17, salary_change{f}#18, salary_change.int{f}#19, salary_change.keyword{f}#20, salary_change.long{f}#21, still_hired{f}#22, language_code{r}#23, language_name{f}#24],false] \_FragmentExec[filter=null, estimatedRowSize=0, reducer=[], fragment=[<> -Project[[_doc{f}, emp_no{f}, languages{f}, language_code{r}, language_name{f}]] -\_TopN[[Order[emp_no{f},ASC,LAST]],20[INTEGER],false] - \_Join[LEFT,[language_code{r}],[language_code{f}],null] - |_Eval[[languages{f} AS language_code]] - | \_Filter[emp_no{f} >= 10091[INTEGER] AND emp_no{f} < 10094[INTEGER]] - | \_EsRelation[employees][_doc{f}, avg_worked_seconds{f}, birth_date{f}, emp_no{f}, first_name{f}, gender{f}, height{f}, height.float{f}, height.half_float{f}, height.scaled_float{f}, hire_date{f}, is_rehired{f}, job_positions{f}, languages{f}, languages.byte{f}, languages.long{f}, languages.short{f}, last_name{f}, salary{f}, salary_change{f}, salary_change.int{f}, salary_change.keyword{f}, salary_change.long{f}, still_hired{f}] - \_EsRelation[languages_lookup][LOOKUP][language_code{f}, language_name{f}]<>]] \ No newline at end of file +Project[[_doc{f}#25, emp_no{f}#2, languages{f}#12, language_code{r}#23, language_name{f}#24]] +\_TopN[[Order[emp_no{f}#2,ASC,LAST]],20[INTEGER],false] + \_Join[LEFT,[language_code{r}#23],[language_code{f}#26],null] + |_Eval[[languages{f}#12 AS language_code#23]] + | \_Filter[emp_no{f}#2 >= 10091[INTEGER] AND emp_no{f}#2 < 10094[INTEGER]] + | \_EsRelation[employees][_doc{f}#25, avg_worked_seconds{f}#0, birth_date{f}#1, emp_no{f}#2, first_name{f}#3, gender{f}#4, height{f}#5, height.float{f}#6, height.half_float{f}#7, height.scaled_float{f}#8, hire_date{f}#9, is_rehired{f}#10, job_positions{f}#11, languages{f}#12, languages.byte{f}#13, languages.long{f}#14, languages.short{f}#15, last_name{f}#16, salary{f}#17, salary_change{f}#18, salary_change.int{f}#19, salary_change.keyword{f}#20, salary_change.long{f}#21, still_hired{f}#22] + \_EsRelation[languages_lookup][LOOKUP][language_code{f}#26, language_name{f}#24]<>]] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testLookupJoinOnDataNode/local_reduce_planned_reduce_driver.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testLookupJoinOnDataNode/local_reduce_planned_reduce_driver.expected index 1c739d108e561..19c98b1780f37 100644 --- a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testLookupJoinOnDataNode/local_reduce_planned_reduce_driver.expected +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testLookupJoinOnDataNode/local_reduce_planned_reduce_driver.expected @@ -1,5 +1,5 @@ -ExchangeSinkExec[[avg_worked_seconds{f}, birth_date{f}, emp_no{f}, first_name{f}, gender{f}, height{f}, height.float{f}, height.half_float{f}, height.scaled_float{f}, hire_date{f}, is_rehired{f}, job_positions{f}, languages{f}, languages.byte{f}, languages.long{f}, languages.short{f}, last_name{f}, salary{f}, salary_change{f}, salary_change.int{f}, salary_change.keyword{f}, salary_change.long{f}, still_hired{f}, language_code{r}, language_name{f}],false] -\_ProjectExec[[avg_worked_seconds{f}, birth_date{f}, emp_no{f}, first_name{f}, gender{f}, height{f}, height.float{f}, height.half_float{f}, height.scaled_float{f}, hire_date{f}, is_rehired{f}, job_positions{f}, languages{f}, languages.byte{f}, languages.long{f}, languages.short{f}, last_name{f}, salary{f}, salary_change{f}, salary_change.int{f}, salary_change.keyword{f}, salary_change.long{f}, still_hired{f}, language_code{r}, language_name{f}]] - \_FieldExtractExec[avg_worked_seconds{f}, birth_date{f}, first_name{f}, gender{f}, height{f}, height.float{f}, height.half_float{f}, height.scaled_float{f}, hire_date{f}, is_rehired{f}, job_positions{f}, languages.byte{f}, languages.long{f}, languages.short{f}, last_name{f}, salary{f}, salary_change{f}, salary_change.int{f}, salary_change.keyword{f}, salary_change.long{f}, still_hired{f}]<[],[]> - \_TopNExec[[Order[emp_no{f},ASC,LAST]],20[INTEGER],430] - \_ExchangeSourceExec[[_doc{f}, emp_no{f}, languages{f}, language_code{r}, language_name{f}],false] \ No newline at end of file +ExchangeSinkExec[[avg_worked_seconds{f}#0, birth_date{f}#1, emp_no{f}#2, first_name{f}#3, gender{f}#4, height{f}#5, height.float{f}#6, height.half_float{f}#7, height.scaled_float{f}#8, hire_date{f}#9, is_rehired{f}#10, job_positions{f}#11, languages{f}#12, languages.byte{f}#13, languages.long{f}#14, languages.short{f}#15, last_name{f}#16, salary{f}#17, salary_change{f}#18, salary_change.int{f}#19, salary_change.keyword{f}#20, salary_change.long{f}#21, still_hired{f}#22, language_code{r}#23, language_name{f}#24],false] +\_ProjectExec[[avg_worked_seconds{f}#0, birth_date{f}#1, emp_no{f}#2, first_name{f}#3, gender{f}#4, height{f}#5, height.float{f}#6, height.half_float{f}#7, height.scaled_float{f}#8, hire_date{f}#9, is_rehired{f}#10, job_positions{f}#11, languages{f}#12, languages.byte{f}#13, languages.long{f}#14, languages.short{f}#15, last_name{f}#16, salary{f}#17, salary_change{f}#18, salary_change.int{f}#19, salary_change.keyword{f}#20, salary_change.long{f}#21, still_hired{f}#22, language_code{r}#23, language_name{f}#24]] + \_FieldExtractExec[avg_worked_seconds{f}#0, birth_date{f}#1, first_name{f}#3, gender{f}#4, height{f}#5, height.float{f}#6, height.half_float{f}#7, height.scaled_float{f}#8, hire_date{f}#9, is_rehired{f}#10, job_positions{f}#11, languages.byte{f}#13, languages.long{f}#14, languages.short{f}#15, last_name{f}#16, salary{f}#17, salary_change{f}#18, salary_change.int{f}#19, salary_change.keyword{f}#20, salary_change.long{f}#21, still_hired{f}#22]<[],[]> + \_TopNExec[[Order[emp_no{f}#2,ASC,LAST]],20[INTEGER],430] + \_ExchangeSourceExec[[_doc{f}#25, emp_no{f}#2, languages{f}#12, language_code{r}#23, language_name{f}#24],false] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testLookupJoinOnDataNode/physical_optimization.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testLookupJoinOnDataNode/physical_optimization.expected index 6de9cdeb68a29..438c1c6d34382 100644 --- a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testLookupJoinOnDataNode/physical_optimization.expected +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testLookupJoinOnDataNode/physical_optimization.expected @@ -1,10 +1,10 @@ -TopNExec[[Order[emp_no{f},ASC,LAST]],20[INTEGER],null] -\_ExchangeExec[[avg_worked_seconds{f}, birth_date{f}, emp_no{f}, first_name{f}, gender{f}, height{f}, height.float{f}, height.half_float{f}, height.scaled_float{f}, hire_date{f}, is_rehired{f}, job_positions{f}, languages{f}, languages.byte{f}, languages.long{f}, languages.short{f}, last_name{f}, salary{f}, salary_change{f}, salary_change.int{f}, salary_change.keyword{f}, salary_change.long{f}, still_hired{f}, language_code{r}, language_name{f}],false] +TopNExec[[Order[emp_no{f}#0,ASC,LAST]],20[INTEGER],null] +\_ExchangeExec[[avg_worked_seconds{f}#1, birth_date{f}#2, emp_no{f}#0, first_name{f}#3, gender{f}#4, height{f}#5, height.float{f}#6, height.half_float{f}#7, height.scaled_float{f}#8, hire_date{f}#9, is_rehired{f}#10, job_positions{f}#11, languages{f}#12, languages.byte{f}#13, languages.long{f}#14, languages.short{f}#15, last_name{f}#16, salary{f}#17, salary_change{f}#18, salary_change.int{f}#19, salary_change.keyword{f}#20, salary_change.long{f}#21, still_hired{f}#22, language_code{r}#23, language_name{f}#24],false] \_FragmentExec[filter=null, estimatedRowSize=0, reducer=[], fragment=[<> -Project[[avg_worked_seconds{f}, birth_date{f}, emp_no{f}, first_name{f}, gender{f}, height{f}, height.float{f}, height.half_float{f}, height.scaled_float{f}, hire_date{f}, is_rehired{f}, job_positions{f}, languages{f}, languages.byte{f}, languages.long{f}, languages.short{f}, last_name{f}, salary{f}, salary_change{f}, salary_change.int{f}, salary_change.keyword{f}, salary_change.long{f}, still_hired{f}, language_code{r}, language_name{f}]] -\_TopN[[Order[emp_no{f},ASC,LAST]],20[INTEGER],false] - \_Join[LEFT,[language_code{r}],[language_code{f}],null] - |_Eval[[languages{f} AS language_code]] - | \_Filter[emp_no{f} >= 10091[INTEGER] AND emp_no{f} < 10094[INTEGER]] - | \_EsRelation[employees][avg_worked_seconds{f}, birth_date{f}, emp_no{f}, first_name{f}, gender{f}, height{f}, height.float{f}, height.half_float{f}, height.scaled_float{f}, hire_date{f}, is_rehired{f}, job_positions{f}, languages{f}, languages.byte{f}, languages.long{f}, languages.short{f}, last_name{f}, salary{f}, salary_change{f}, salary_change.int{f}, salary_change.keyword{f}, salary_change.long{f}, still_hired{f}] - \_EsRelation[languages_lookup][LOOKUP][language_code{f}, language_name{f}]<>]] \ No newline at end of file +Project[[avg_worked_seconds{f}#1, birth_date{f}#2, emp_no{f}#0, first_name{f}#3, gender{f}#4, height{f}#5, height.float{f}#6, height.half_float{f}#7, height.scaled_float{f}#8, hire_date{f}#9, is_rehired{f}#10, job_positions{f}#11, languages{f}#12, languages.byte{f}#13, languages.long{f}#14, languages.short{f}#15, last_name{f}#16, salary{f}#17, salary_change{f}#18, salary_change.int{f}#19, salary_change.keyword{f}#20, salary_change.long{f}#21, still_hired{f}#22, language_code{r}#23, language_name{f}#24]] +\_TopN[[Order[emp_no{f}#0,ASC,LAST]],20[INTEGER],false] + \_Join[LEFT,[language_code{r}#23],[language_code{f}#25],null] + |_Eval[[languages{f}#12 AS language_code#23]] + | \_Filter[emp_no{f}#0 >= 10091[INTEGER] AND emp_no{f}#0 < 10094[INTEGER]] + | \_EsRelation[employees][avg_worked_seconds{f}#1, birth_date{f}#2, emp_no{f}#0, first_name{f}#3, gender{f}#4, height{f}#5, height.float{f}#6, height.half_float{f}#7, height.scaled_float{f}#8, hire_date{f}#9, is_rehired{f}#10, job_positions{f}#11, languages{f}#12, languages.byte{f}#13, languages.long{f}#14, languages.short{f}#15, last_name{f}#16, salary{f}#17, salary_change{f}#18, salary_change.int{f}#19, salary_change.keyword{f}#20, salary_change.long{f}#21, still_hired{f}#22] + \_EsRelation[languages_lookup][LOOKUP][language_code{f}#25, language_name{f}#24]<>]] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testMultipleFieldSortTopN/local_reduce_physical_optimization_data_driver.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testMultipleFieldSortTopN/local_reduce_physical_optimization_data_driver.expected index 4ba472a701132..e5de0b72a7705 100644 --- a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testMultipleFieldSortTopN/local_reduce_physical_optimization_data_driver.expected +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testMultipleFieldSortTopN/local_reduce_physical_optimization_data_driver.expected @@ -1,4 +1,4 @@ -ExchangeSinkExec[[emp_no{f}, height{f}, hire_date{f}],false] -\_ProjectExec[[_doc{f}, hire_date{f}, height{f}]] - \_FieldExtractExec[hire_date{f}, height{f}]<[],[]> - \_EsQueryExec[employees], indexMode[standard], [_doc{f}], limit[20], sort[[FieldSort[field=hire_date{f}, direction=ASC, nulls=LAST], FieldSort[field=height{f}, direction=ASC, nulls=LAST]]] estimatedRowSize[32] queryBuilderAndTags [[QueryBuilderAndTags[query=null, tags=[]]]] \ No newline at end of file +ExchangeSinkExec[[emp_no{f}#0, height{f}#1, hire_date{f}#2],false] +\_ProjectExec[[_doc{f}#3, hire_date{f}#2, height{f}#1]] + \_FieldExtractExec[hire_date{f}#2, height{f}#1]<[],[]> + \_EsQueryExec[employees], indexMode[standard], [_doc{f}#3], limit[20], sort[[FieldSort[field=hire_date{f}#2, direction=ASC, nulls=LAST], FieldSort[field=height{f}#1, direction=ASC, nulls=LAST]]] estimatedRowSize[32] queryBuilderAndTags [[QueryBuilderAndTags[query=null, tags=[]]]] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testMultipleFieldSortTopN/local_reduce_planned_data_driver.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testMultipleFieldSortTopN/local_reduce_planned_data_driver.expected index 8ab7e96ac70e1..4866ac15c30c3 100644 --- a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testMultipleFieldSortTopN/local_reduce_planned_data_driver.expected +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testMultipleFieldSortTopN/local_reduce_planned_data_driver.expected @@ -1,5 +1,5 @@ -ExchangeSinkExec[[emp_no{f}, height{f}, hire_date{f}],false] +ExchangeSinkExec[[emp_no{f}#0, height{f}#1, hire_date{f}#2],false] \_FragmentExec[filter=null, estimatedRowSize=0, reducer=[], fragment=[<> -Project[[_doc{f}, hire_date{f}, height{f}]] -\_TopN[[Order[hire_date{f},ASC,LAST], Order[height{f},ASC,LAST]],20[INTEGER],false] - \_EsRelation[employees][_doc{f}, avg_worked_seconds{f}, birth_date{f}, emp_no{f}, first_name{f}, gender{f}, height{f}, height.float{f}, height.half_float{f}, height.scaled_float{f}, hire_date{f}, is_rehired{f}, job_positions{f}, languages{f}, languages.byte{f}, languages.long{f}, languages.short{f}, last_name{f}, salary{f}, salary_change{f}, salary_change.int{f}, salary_change.keyword{f}, salary_change.long{f}, still_hired{f}]<>]] \ No newline at end of file +Project[[_doc{f}#3, hire_date{f}#2, height{f}#1]] +\_TopN[[Order[hire_date{f}#2,ASC,LAST], Order[height{f}#1,ASC,LAST]],20[INTEGER],false] + \_EsRelation[employees][_doc{f}#3, avg_worked_seconds{f}#4, birth_date{f}#5, emp_no{f}#0, first_name{f}#6, gender{f}#7, height{f}#1, height.float{f}#8, height.half_float{f}#9, height.scaled_float{f}#10, hire_date{f}#2, is_rehired{f}#11, job_positions{f}#12, languages{f}#13, languages.byte{f}#14, languages.long{f}#15, languages.short{f}#16, last_name{f}#17, salary{f}#18, salary_change{f}#19, salary_change.int{f}#20, salary_change.keyword{f}#21, salary_change.long{f}#22, still_hired{f}#23]<>]] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testMultipleFieldSortTopN/local_reduce_planned_reduce_driver.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testMultipleFieldSortTopN/local_reduce_planned_reduce_driver.expected index b4903131e7355..ab96def3b448c 100644 --- a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testMultipleFieldSortTopN/local_reduce_planned_reduce_driver.expected +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testMultipleFieldSortTopN/local_reduce_planned_reduce_driver.expected @@ -1,5 +1,5 @@ -ExchangeSinkExec[[emp_no{f}, height{f}, hire_date{f}],false] -\_ProjectExec[[emp_no{f}, height{f}, hire_date{f}]] - \_FieldExtractExec[emp_no{f}]<[],[]> - \_TopNExec[[Order[hire_date{f},ASC,LAST], Order[height{f},ASC,LAST]],20[INTEGER],40] - \_ExchangeSourceExec[[_doc{f}, hire_date{f}, height{f}],false] \ No newline at end of file +ExchangeSinkExec[[emp_no{f}#0, height{f}#1, hire_date{f}#2],false] +\_ProjectExec[[emp_no{f}#0, height{f}#1, hire_date{f}#2]] + \_FieldExtractExec[emp_no{f}#0]<[],[]> + \_TopNExec[[Order[hire_date{f}#2,ASC,LAST], Order[height{f}#1,ASC,LAST]],20[INTEGER],40] + \_ExchangeSourceExec[[_doc{f}#3, hire_date{f}#2, height{f}#1],false] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testMultipleFieldSortTopN/physical_optimization.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testMultipleFieldSortTopN/physical_optimization.expected index 01e434d142dbc..64df823ba0bbf 100644 --- a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testMultipleFieldSortTopN/physical_optimization.expected +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testMultipleFieldSortTopN/physical_optimization.expected @@ -1,7 +1,7 @@ -ProjectExec[[hire_date{f}, emp_no{f}, height{f}]] -\_TopNExec[[Order[hire_date{f},ASC,LAST], Order[height{f},ASC,LAST]],20[INTEGER],null] - \_ExchangeExec[[emp_no{f}, height{f}, hire_date{f}],false] +ProjectExec[[hire_date{f}#0, emp_no{f}#1, height{f}#2]] +\_TopNExec[[Order[hire_date{f}#0,ASC,LAST], Order[height{f}#2,ASC,LAST]],20[INTEGER],null] + \_ExchangeExec[[emp_no{f}#1, height{f}#2, hire_date{f}#0],false] \_FragmentExec[filter=null, estimatedRowSize=0, reducer=[], fragment=[<> -Project[[emp_no{f}, height{f}, hire_date{f}]] -\_TopN[[Order[hire_date{f},ASC,LAST], Order[height{f},ASC,LAST]],20[INTEGER],false] - \_EsRelation[employees][avg_worked_seconds{f}, birth_date{f}, emp_no{f}, first_name{f}, gender{f}, height{f}, height.float{f}, height.half_float{f}, height.scaled_float{f}, hire_date{f}, is_rehired{f}, job_positions{f}, languages{f}, languages.byte{f}, languages.long{f}, languages.short{f}, last_name{f}, salary{f}, salary_change{f}, salary_change.int{f}, salary_change.keyword{f}, salary_change.long{f}, still_hired{f}]<>]] \ No newline at end of file +Project[[emp_no{f}#1, height{f}#2, hire_date{f}#0]] +\_TopN[[Order[hire_date{f}#0,ASC,LAST], Order[height{f}#2,ASC,LAST]],20[INTEGER],false] + \_EsRelation[employees][avg_worked_seconds{f}#3, birth_date{f}#4, emp_no{f}#1, first_name{f}#5, gender{f}#6, height{f}#2, height.float{f}#7, height.half_float{f}#8, height.scaled_float{f}#9, hire_date{f}#0, is_rehired{f}#10, job_positions{f}#11, languages{f}#12, languages.byte{f}#13, languages.long{f}#14, languages.short{f}#15, last_name{f}#16, salary{f}#17, salary_change{f}#18, salary_change.int{f}#19, salary_change.keyword{f}#20, salary_change.long{f}#21, still_hired{f}#22]<>]] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testMultipleTopN/local_reduce_physical_optimization_data_driver.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testMultipleTopN/local_reduce_physical_optimization_data_driver.expected index 79d08e098a4ac..71c01677f83a5 100644 --- a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testMultipleTopN/local_reduce_physical_optimization_data_driver.expected +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testMultipleTopN/local_reduce_physical_optimization_data_driver.expected @@ -1,4 +1,4 @@ -ExchangeSinkExec[[emp_no{f}, hire_date{f}, salary{f}],false] -\_ProjectExec[[_doc{f}, hire_date{f}]] - \_FieldExtractExec[hire_date{f}]<[],[]> - \_EsQueryExec[employees], indexMode[standard], [_doc{f}], limit[20], sort[[FieldSort[field=hire_date{f}, direction=ASC, nulls=LAST]]] estimatedRowSize[24] queryBuilderAndTags [[QueryBuilderAndTags[query=null, tags=[]]]] \ No newline at end of file +ExchangeSinkExec[[emp_no{f}#0, hire_date{f}#1, salary{f}#2],false] +\_ProjectExec[[_doc{f}#3, hire_date{f}#1]] + \_FieldExtractExec[hire_date{f}#1]<[],[]> + \_EsQueryExec[employees], indexMode[standard], [_doc{f}#3], limit[20], sort[[FieldSort[field=hire_date{f}#1, direction=ASC, nulls=LAST]]] estimatedRowSize[24] queryBuilderAndTags [[QueryBuilderAndTags[query=null, tags=[]]]] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testMultipleTopN/local_reduce_planned_data_driver.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testMultipleTopN/local_reduce_planned_data_driver.expected index 42c2f1deccb35..fc4d011c9a8fb 100644 --- a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testMultipleTopN/local_reduce_planned_data_driver.expected +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testMultipleTopN/local_reduce_planned_data_driver.expected @@ -1,5 +1,5 @@ -ExchangeSinkExec[[emp_no{f}, hire_date{f}, salary{f}],false] +ExchangeSinkExec[[emp_no{f}#0, hire_date{f}#1, salary{f}#2],false] \_FragmentExec[filter=null, estimatedRowSize=0, reducer=[], fragment=[<> -Project[[_doc{f}, hire_date{f}]] -\_TopN[[Order[hire_date{f},ASC,LAST]],20[INTEGER],false] - \_EsRelation[employees][_doc{f}, avg_worked_seconds{f}, birth_date{f}, emp_no{f}, first_name{f}, gender{f}, height{f}, height.float{f}, height.half_float{f}, height.scaled_float{f}, hire_date{f}, is_rehired{f}, job_positions{f}, languages{f}, languages.byte{f}, languages.long{f}, languages.short{f}, last_name{f}, salary{f}, salary_change{f}, salary_change.int{f}, salary_change.keyword{f}, salary_change.long{f}, still_hired{f}]<>]] \ No newline at end of file +Project[[_doc{f}#3, hire_date{f}#1]] +\_TopN[[Order[hire_date{f}#1,ASC,LAST]],20[INTEGER],false] + \_EsRelation[employees][_doc{f}#3, avg_worked_seconds{f}#4, birth_date{f}#5, emp_no{f}#0, first_name{f}#6, gender{f}#7, height{f}#8, height.float{f}#9, height.half_float{f}#10, height.scaled_float{f}#11, hire_date{f}#1, is_rehired{f}#12, job_positions{f}#13, languages{f}#14, languages.byte{f}#15, languages.long{f}#16, languages.short{f}#17, last_name{f}#18, salary{f}#2, salary_change{f}#19, salary_change.int{f}#20, salary_change.keyword{f}#21, salary_change.long{f}#22, still_hired{f}#23]<>]] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testMultipleTopN/local_reduce_planned_reduce_driver.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testMultipleTopN/local_reduce_planned_reduce_driver.expected index 378271a5e3f37..4b4fc0c891ac1 100644 --- a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testMultipleTopN/local_reduce_planned_reduce_driver.expected +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testMultipleTopN/local_reduce_planned_reduce_driver.expected @@ -1,5 +1,5 @@ -ExchangeSinkExec[[emp_no{f}, hire_date{f}, salary{f}],false] -\_ProjectExec[[emp_no{f}, hire_date{f}, salary{f}]] - \_FieldExtractExec[emp_no{f}, salary{f}]<[],[]> - \_TopNExec[[Order[hire_date{f},ASC,LAST]],20[INTEGER],36] - \_ExchangeSourceExec[[_doc{f}, hire_date{f}],false] \ No newline at end of file +ExchangeSinkExec[[emp_no{f}#0, hire_date{f}#1, salary{f}#2],false] +\_ProjectExec[[emp_no{f}#0, hire_date{f}#1, salary{f}#2]] + \_FieldExtractExec[emp_no{f}#0, salary{f}#2]<[],[]> + \_TopNExec[[Order[hire_date{f}#1,ASC,LAST]],20[INTEGER],36] + \_ExchangeSourceExec[[_doc{f}#3, hire_date{f}#1],false] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testMultipleTopN/physical_optimization.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testMultipleTopN/physical_optimization.expected index f614767fd6b3e..92cf16635a7dc 100644 --- a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testMultipleTopN/physical_optimization.expected +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testMultipleTopN/physical_optimization.expected @@ -1,8 +1,8 @@ -ProjectExec[[hire_date{f}, salary{f}, emp_no{f}]] -\_TopNExec[[Order[salary{f},ASC,LAST]],10[INTEGER],null] - \_TopNExec[[Order[hire_date{f},ASC,LAST]],20[INTEGER],null] - \_ExchangeExec[[emp_no{f}, hire_date{f}, salary{f}],false] +ProjectExec[[hire_date{f}#0, salary{f}#1, emp_no{f}#2]] +\_TopNExec[[Order[salary{f}#1,ASC,LAST]],10[INTEGER],null] + \_TopNExec[[Order[hire_date{f}#0,ASC,LAST]],20[INTEGER],null] + \_ExchangeExec[[emp_no{f}#2, hire_date{f}#0, salary{f}#1],false] \_FragmentExec[filter=null, estimatedRowSize=0, reducer=[], fragment=[<> -Project[[emp_no{f}, hire_date{f}, salary{f}]] -\_TopN[[Order[hire_date{f},ASC,LAST]],20[INTEGER],false] - \_EsRelation[employees][avg_worked_seconds{f}, birth_date{f}, emp_no{f}, first_name{f}, gender{f}, height{f}, height.float{f}, height.half_float{f}, height.scaled_float{f}, hire_date{f}, is_rehired{f}, job_positions{f}, languages{f}, languages.byte{f}, languages.long{f}, languages.short{f}, last_name{f}, salary{f}, salary_change{f}, salary_change.int{f}, salary_change.keyword{f}, salary_change.long{f}, still_hired{f}]<>]] \ No newline at end of file +Project[[emp_no{f}#2, hire_date{f}#0, salary{f}#1]] +\_TopN[[Order[hire_date{f}#0,ASC,LAST]],20[INTEGER],false] + \_EsRelation[employees][avg_worked_seconds{f}#3, birth_date{f}#4, emp_no{f}#2, first_name{f}#5, gender{f}#6, height{f}#7, height.float{f}#8, height.half_float{f}#9, height.scaled_float{f}#10, hire_date{f}#0, is_rehired{f}#11, job_positions{f}#12, languages{f}#13, languages.byte{f}#14, languages.long{f}#15, languages.short{f}#16, last_name{f}#17, salary{f}#1, salary_change{f}#18, salary_change.int{f}#19, salary_change.keyword{f}#20, salary_change.long{f}#21, still_hired{f}#22]<>]] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testMvExpandBeforeTopN/local_reduce_physical_optimization_data_driver.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testMvExpandBeforeTopN/local_reduce_physical_optimization_data_driver.expected index 2f239d653927e..f0d827b7d0c99 100644 --- a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testMvExpandBeforeTopN/local_reduce_physical_optimization_data_driver.expected +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testMvExpandBeforeTopN/local_reduce_physical_optimization_data_driver.expected @@ -1,7 +1,7 @@ -ExchangeSinkExec[[emp_no{f}, job_positions{r}, salary{f}],false] -\_ProjectExec[[emp_no{f}, job_positions{r}, salary{f}]] - \_TopNExec[[Order[salary{f},ASC,LAST]],20[INTEGER],58] - \_MvExpandExec[job_positions{f},job_positions{r}] - \_ProjectExec[[emp_no{f}, job_positions{f}, salary{f}]] - \_FieldExtractExec[emp_no{f}, job_positions{f}, salary{f}]<[],[]> - \_EsQueryExec[employees], indexMode[standard], [_doc{f}], limit[], sort[] estimatedRowSize[62] queryBuilderAndTags [[QueryBuilderAndTags[query=null, tags=[]]]] \ No newline at end of file +ExchangeSinkExec[[emp_no{f}#0, job_positions{r}#1, salary{f}#2],false] +\_ProjectExec[[emp_no{f}#0, job_positions{r}#1, salary{f}#2]] + \_TopNExec[[Order[salary{f}#2,ASC,LAST]],20[INTEGER],58] + \_MvExpandExec[job_positions{f}#3,job_positions{r}#1] + \_ProjectExec[[emp_no{f}#0, job_positions{f}#3, salary{f}#2]] + \_FieldExtractExec[emp_no{f}#0, job_positions{f}#3, salary{f}#2]<[],[]> + \_EsQueryExec[employees], indexMode[standard], [_doc{f}#4], limit[], sort[] estimatedRowSize[62] queryBuilderAndTags [[QueryBuilderAndTags[query=null, tags=[]]]] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testMvExpandBeforeTopN/local_reduce_physical_optimization_reduce_driver.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testMvExpandBeforeTopN/local_reduce_physical_optimization_reduce_driver.expected index 0c801590c80b7..a9639e399dec8 100644 --- a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testMvExpandBeforeTopN/local_reduce_physical_optimization_reduce_driver.expected +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testMvExpandBeforeTopN/local_reduce_physical_optimization_reduce_driver.expected @@ -1,3 +1,3 @@ -ExchangeSinkExec[[emp_no{f}, job_positions{r}, salary{f}],false] -\_TopNExec[[Order[salary{f},ASC,LAST]],20[INTEGER],58] - \_ExchangeSourceExec[[emp_no{f}, job_positions{r}, salary{f}],false] \ No newline at end of file +ExchangeSinkExec[[emp_no{f}#0, job_positions{r}#1, salary{f}#2],false] +\_TopNExec[[Order[salary{f}#2,ASC,LAST]],20[INTEGER],58] + \_ExchangeSourceExec[[emp_no{f}#0, job_positions{r}#1, salary{f}#2],false] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testMvExpandBeforeTopN/local_reduce_planned_data_driver.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testMvExpandBeforeTopN/local_reduce_planned_data_driver.expected index 5a4be4cccf576..baf5e66932990 100644 --- a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testMvExpandBeforeTopN/local_reduce_planned_data_driver.expected +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testMvExpandBeforeTopN/local_reduce_planned_data_driver.expected @@ -1,7 +1,7 @@ -ExchangeSinkExec[[emp_no{f}, job_positions{r}, salary{f}],false] +ExchangeSinkExec[[emp_no{f}#0, job_positions{r}#1, salary{f}#2],false] \_FragmentExec[filter=null, estimatedRowSize=0, reducer=[], fragment=[<> -Project[[emp_no{f}, job_positions{r}, salary{f}]] -\_TopN[[Order[salary{f},ASC,LAST]],20[INTEGER],false] - \_MvExpand[job_positions{f},job_positions{r}] - \_Project[[emp_no{f}, job_positions{f}, salary{f}]] - \_EsRelation[employees][avg_worked_seconds{f}, birth_date{f}, emp_no{f}, first_name{f}, gender{f}, height{f}, height.float{f}, height.half_float{f}, height.scaled_float{f}, hire_date{f}, is_rehired{f}, job_positions{f}, languages{f}, languages.byte{f}, languages.long{f}, languages.short{f}, last_name{f}, salary{f}, salary_change{f}, salary_change.int{f}, salary_change.keyword{f}, salary_change.long{f}, still_hired{f}]<>]] \ No newline at end of file +Project[[emp_no{f}#0, job_positions{r}#1, salary{f}#2]] +\_TopN[[Order[salary{f}#2,ASC,LAST]],20[INTEGER],false] + \_MvExpand[job_positions{f}#3,job_positions{r}#1] + \_Project[[emp_no{f}#0, job_positions{f}#3, salary{f}#2]] + \_EsRelation[employees][avg_worked_seconds{f}#4, birth_date{f}#5, emp_no{f}#0, first_name{f}#6, gender{f}#7, height{f}#8, height.float{f}#9, height.half_float{f}#10, height.scaled_float{f}#11, hire_date{f}#12, is_rehired{f}#13, job_positions{f}#3, languages{f}#14, languages.byte{f}#15, languages.long{f}#16, languages.short{f}#17, last_name{f}#18, salary{f}#2, salary_change{f}#19, salary_change.int{f}#20, salary_change.keyword{f}#21, salary_change.long{f}#22, still_hired{f}#23]<>]] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testMvExpandBeforeTopN/local_reduce_planned_reduce_driver.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testMvExpandBeforeTopN/local_reduce_planned_reduce_driver.expected index 0c801590c80b7..a9639e399dec8 100644 --- a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testMvExpandBeforeTopN/local_reduce_planned_reduce_driver.expected +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testMvExpandBeforeTopN/local_reduce_planned_reduce_driver.expected @@ -1,3 +1,3 @@ -ExchangeSinkExec[[emp_no{f}, job_positions{r}, salary{f}],false] -\_TopNExec[[Order[salary{f},ASC,LAST]],20[INTEGER],58] - \_ExchangeSourceExec[[emp_no{f}, job_positions{r}, salary{f}],false] \ No newline at end of file +ExchangeSinkExec[[emp_no{f}#0, job_positions{r}#1, salary{f}#2],false] +\_TopNExec[[Order[salary{f}#2,ASC,LAST]],20[INTEGER],58] + \_ExchangeSourceExec[[emp_no{f}#0, job_positions{r}#1, salary{f}#2],false] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testMvExpandBeforeTopN/physical_optimization.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testMvExpandBeforeTopN/physical_optimization.expected index d53c3f7c10b84..7bd205fddb3bd 100644 --- a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testMvExpandBeforeTopN/physical_optimization.expected +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testMvExpandBeforeTopN/physical_optimization.expected @@ -1,8 +1,8 @@ -TopNExec[[Order[salary{f},ASC,LAST]],20[INTEGER],null] -\_ExchangeExec[[emp_no{f}, job_positions{r}, salary{f}],false] +TopNExec[[Order[salary{f}#0,ASC,LAST]],20[INTEGER],null] +\_ExchangeExec[[emp_no{f}#1, job_positions{r}#2, salary{f}#0],false] \_FragmentExec[filter=null, estimatedRowSize=0, reducer=[], fragment=[<> -Project[[emp_no{f}, job_positions{r}, salary{f}]] -\_TopN[[Order[salary{f},ASC,LAST]],20[INTEGER],false] - \_MvExpand[job_positions{f},job_positions{r}] - \_Project[[emp_no{f}, job_positions{f}, salary{f}]] - \_EsRelation[employees][avg_worked_seconds{f}, birth_date{f}, emp_no{f}, first_name{f}, gender{f}, height{f}, height.float{f}, height.half_float{f}, height.scaled_float{f}, hire_date{f}, is_rehired{f}, job_positions{f}, languages{f}, languages.byte{f}, languages.long{f}, languages.short{f}, last_name{f}, salary{f}, salary_change{f}, salary_change.int{f}, salary_change.keyword{f}, salary_change.long{f}, still_hired{f}]<>]] \ No newline at end of file +Project[[emp_no{f}#1, job_positions{r}#2, salary{f}#0]] +\_TopN[[Order[salary{f}#0,ASC,LAST]],20[INTEGER],false] + \_MvExpand[job_positions{f}#3,job_positions{r}#2] + \_Project[[emp_no{f}#1, job_positions{f}#3, salary{f}#0]] + \_EsRelation[employees][avg_worked_seconds{f}#4, birth_date{f}#5, emp_no{f}#1, first_name{f}#6, gender{f}#7, height{f}#8, height.float{f}#9, height.half_float{f}#10, height.scaled_float{f}#11, hire_date{f}#12, is_rehired{f}#13, job_positions{f}#3, languages{f}#14, languages.byte{f}#15, languages.long{f}#16, languages.short{f}#17, last_name{f}#18, salary{f}#0, salary_change{f}#19, salary_change.int{f}#20, salary_change.keyword{f}#21, salary_change.long{f}#22, still_hired{f}#23]<>]] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testPushedDownTopN/local_reduce_physical_optimization_data_driver.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testPushedDownTopN/local_reduce_physical_optimization_data_driver.expected index b49e189701890..cebf3f704c28d 100644 --- a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testPushedDownTopN/local_reduce_physical_optimization_data_driver.expected +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testPushedDownTopN/local_reduce_physical_optimization_data_driver.expected @@ -1,4 +1,4 @@ -ExchangeSinkExec[[emp_no{f}, height{f}],false] -\_ProjectExec[[_doc{f}, height{f}]] - \_FieldExtractExec[height{f}]<[],[]> - \_EsQueryExec[employees], indexMode[standard], [_doc{f}], limit[20], sort[[FieldSort[field=height{f}, direction=ASC, nulls=LAST]]] estimatedRowSize[24] queryBuilderAndTags [[QueryBuilderAndTags[query=null, tags=[]]]] \ No newline at end of file +ExchangeSinkExec[[emp_no{f}#0, height{f}#1],false] +\_ProjectExec[[_doc{f}#2, height{f}#1]] + \_FieldExtractExec[height{f}#1]<[],[]> + \_EsQueryExec[employees], indexMode[standard], [_doc{f}#2], limit[20], sort[[FieldSort[field=height{f}#1, direction=ASC, nulls=LAST]]] estimatedRowSize[24] queryBuilderAndTags [[QueryBuilderAndTags[query=null, tags=[]]]] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testPushedDownTopN/local_reduce_planned_data_driver.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testPushedDownTopN/local_reduce_planned_data_driver.expected index bf2fa9c12991a..b2913dbdf505b 100644 --- a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testPushedDownTopN/local_reduce_planned_data_driver.expected +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testPushedDownTopN/local_reduce_planned_data_driver.expected @@ -1,5 +1,5 @@ -ExchangeSinkExec[[emp_no{f}, height{f}],false] +ExchangeSinkExec[[emp_no{f}#0, height{f}#1],false] \_FragmentExec[filter=null, estimatedRowSize=0, reducer=[], fragment=[<> -Project[[_doc{f}, height{f}]] -\_TopN[[Order[height{f},ASC,LAST]],20[INTEGER],false] - \_EsRelation[employees][_doc{f}, avg_worked_seconds{f}, birth_date{f}, emp_no{f}, first_name{f}, gender{f}, height{f}, height.float{f}, height.half_float{f}, height.scaled_float{f}, hire_date{f}, is_rehired{f}, job_positions{f}, languages{f}, languages.byte{f}, languages.long{f}, languages.short{f}, last_name{f}, salary{f}, salary_change{f}, salary_change.int{f}, salary_change.keyword{f}, salary_change.long{f}, still_hired{f}]<>]] \ No newline at end of file +Project[[_doc{f}#2, height{f}#1]] +\_TopN[[Order[height{f}#1,ASC,LAST]],20[INTEGER],false] + \_EsRelation[employees][_doc{f}#2, avg_worked_seconds{f}#3, birth_date{f}#4, emp_no{f}#0, first_name{f}#5, gender{f}#6, height{f}#1, height.float{f}#7, height.half_float{f}#8, height.scaled_float{f}#9, hire_date{f}#10, is_rehired{f}#11, job_positions{f}#12, languages{f}#13, languages.byte{f}#14, languages.long{f}#15, languages.short{f}#16, last_name{f}#17, salary{f}#18, salary_change{f}#19, salary_change.int{f}#20, salary_change.keyword{f}#21, salary_change.long{f}#22, still_hired{f}#23]<>]] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testPushedDownTopN/local_reduce_planned_reduce_driver.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testPushedDownTopN/local_reduce_planned_reduce_driver.expected index 787b72a5c8f72..3425364e715c1 100644 --- a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testPushedDownTopN/local_reduce_planned_reduce_driver.expected +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testPushedDownTopN/local_reduce_planned_reduce_driver.expected @@ -1,5 +1,5 @@ -ExchangeSinkExec[[emp_no{f}, height{f}],false] -\_ProjectExec[[emp_no{f}, height{f}]] - \_FieldExtractExec[emp_no{f}]<[],[]> - \_TopNExec[[Order[height{f},ASC,LAST]],20[INTEGER],32] - \_ExchangeSourceExec[[_doc{f}, height{f}],false] \ No newline at end of file +ExchangeSinkExec[[emp_no{f}#0, height{f}#1],false] +\_ProjectExec[[emp_no{f}#0, height{f}#1]] + \_FieldExtractExec[emp_no{f}#0]<[],[]> + \_TopNExec[[Order[height{f}#1,ASC,LAST]],20[INTEGER],32] + \_ExchangeSourceExec[[_doc{f}#2, height{f}#1],false] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testPushedDownTopN/physical_optimization.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testPushedDownTopN/physical_optimization.expected index 896efe01a59ec..e659e9ce08d64 100644 --- a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testPushedDownTopN/physical_optimization.expected +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testPushedDownTopN/physical_optimization.expected @@ -1,7 +1,7 @@ -ProjectExec[[emp_no{f}, height{f}]] -\_TopNExec[[Order[height{f},ASC,LAST]],20[INTEGER],null] - \_ExchangeExec[[emp_no{f}, height{f}],false] +ProjectExec[[emp_no{f}#0, height{f}#1]] +\_TopNExec[[Order[height{f}#1,ASC,LAST]],20[INTEGER],null] + \_ExchangeExec[[emp_no{f}#0, height{f}#1],false] \_FragmentExec[filter=null, estimatedRowSize=0, reducer=[], fragment=[<> -Project[[emp_no{f}, height{f}]] -\_TopN[[Order[height{f},ASC,LAST]],20[INTEGER],false] - \_EsRelation[employees][avg_worked_seconds{f}, birth_date{f}, emp_no{f}, first_name{f}, gender{f}, height{f}, height.float{f}, height.half_float{f}, height.scaled_float{f}, hire_date{f}, is_rehired{f}, job_positions{f}, languages{f}, languages.byte{f}, languages.long{f}, languages.short{f}, last_name{f}, salary{f}, salary_change{f}, salary_change.int{f}, salary_change.keyword{f}, salary_change.long{f}, still_hired{f}]<>]] \ No newline at end of file +Project[[emp_no{f}#0, height{f}#1]] +\_TopN[[Order[height{f}#1,ASC,LAST]],20[INTEGER],false] + \_EsRelation[employees][avg_worked_seconds{f}#2, birth_date{f}#3, emp_no{f}#0, first_name{f}#4, gender{f}#5, height{f}#1, height.float{f}#6, height.half_float{f}#7, height.scaled_float{f}#8, hire_date{f}#9, is_rehired{f}#10, job_positions{f}#11, languages{f}#12, languages.byte{f}#13, languages.long{f}#14, languages.short{f}#15, last_name{f}#16, salary{f}#17, salary_change{f}#18, salary_change.int{f}#19, salary_change.keyword{f}#20, salary_change.long{f}#21, still_hired{f}#22]<>]] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testSomeFieldsNeededBeforeLateMaterialization/local_reduce_physical_optimization_data_driver.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testSomeFieldsNeededBeforeLateMaterialization/local_reduce_physical_optimization_data_driver.expected index 7a2b16378c969..91fa3beaa5567 100644 --- a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testSomeFieldsNeededBeforeLateMaterialization/local_reduce_physical_optimization_data_driver.expected +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testSomeFieldsNeededBeforeLateMaterialization/local_reduce_physical_optimization_data_driver.expected @@ -1,7 +1,7 @@ -ExchangeSinkExec[[emp_no{f}, hire_date{f}, salary{f}],false] -\_ProjectExec[[_doc{f}, salary{f}, hire_date{f}]] - \_FieldExtractExec[salary{f}, hire_date{f}]<[],[]> - \_EsQueryExec[employees], indexMode[standard], [_doc{f}], limit[20], sort[[FieldSort[field=hire_date{f}, direction=ASC, nulls=LAST]]] estimatedRowSize[28] queryBuilderAndTags [[QueryBuilderAndTags[query={ +ExchangeSinkExec[[emp_no{f}#0, hire_date{f}#1, salary{f}#2],false] +\_ProjectExec[[_doc{f}#3, salary{f}#2, hire_date{f}#1]] + \_FieldExtractExec[salary{f}#2, hire_date{f}#1]<[],[]> + \_EsQueryExec[employees], indexMode[standard], [_doc{f}#3], limit[20], sort[[FieldSort[field=hire_date{f}#1, direction=ASC, nulls=LAST]]] estimatedRowSize[28] queryBuilderAndTags [[QueryBuilderAndTags[query={ "esql_single_value" : { "field" : "salary", "next" : { diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testSomeFieldsNeededBeforeLateMaterialization/local_reduce_planned_data_driver.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testSomeFieldsNeededBeforeLateMaterialization/local_reduce_planned_data_driver.expected index 041b22266a09e..1e90a18573c7c 100644 --- a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testSomeFieldsNeededBeforeLateMaterialization/local_reduce_planned_data_driver.expected +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testSomeFieldsNeededBeforeLateMaterialization/local_reduce_planned_data_driver.expected @@ -1,6 +1,6 @@ -ExchangeSinkExec[[emp_no{f}, hire_date{f}, salary{f}],false] +ExchangeSinkExec[[emp_no{f}#0, hire_date{f}#1, salary{f}#2],false] \_FragmentExec[filter=null, estimatedRowSize=0, reducer=[], fragment=[<> -Project[[_doc{f}, salary{f}, hire_date{f}]] -\_TopN[[Order[hire_date{f},ASC,LAST]],20[INTEGER],false] - \_Filter[salary{f} > 10000[INTEGER]] - \_EsRelation[employees][_doc{f}, avg_worked_seconds{f}, birth_date{f}, emp_no{f}, first_name{f}, gender{f}, height{f}, height.float{f}, height.half_float{f}, height.scaled_float{f}, hire_date{f}, is_rehired{f}, job_positions{f}, languages{f}, languages.byte{f}, languages.long{f}, languages.short{f}, last_name{f}, salary{f}, salary_change{f}, salary_change.int{f}, salary_change.keyword{f}, salary_change.long{f}, still_hired{f}]<>]] \ No newline at end of file +Project[[_doc{f}#3, salary{f}#2, hire_date{f}#1]] +\_TopN[[Order[hire_date{f}#1,ASC,LAST]],20[INTEGER],false] + \_Filter[salary{f}#2 > 10000[INTEGER]] + \_EsRelation[employees][_doc{f}#3, avg_worked_seconds{f}#4, birth_date{f}#5, emp_no{f}#0, first_name{f}#6, gender{f}#7, height{f}#8, height.float{f}#9, height.half_float{f}#10, height.scaled_float{f}#11, hire_date{f}#1, is_rehired{f}#12, job_positions{f}#13, languages{f}#14, languages.byte{f}#15, languages.long{f}#16, languages.short{f}#17, last_name{f}#18, salary{f}#2, salary_change{f}#19, salary_change.int{f}#20, salary_change.keyword{f}#21, salary_change.long{f}#22, still_hired{f}#23]<>]] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testSomeFieldsNeededBeforeLateMaterialization/local_reduce_planned_reduce_driver.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testSomeFieldsNeededBeforeLateMaterialization/local_reduce_planned_reduce_driver.expected index 23b988ef09a77..178d31ccc5dc1 100644 --- a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testSomeFieldsNeededBeforeLateMaterialization/local_reduce_planned_reduce_driver.expected +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testSomeFieldsNeededBeforeLateMaterialization/local_reduce_planned_reduce_driver.expected @@ -1,5 +1,5 @@ -ExchangeSinkExec[[emp_no{f}, hire_date{f}, salary{f}],false] -\_ProjectExec[[emp_no{f}, hire_date{f}, salary{f}]] - \_FieldExtractExec[emp_no{f}]<[],[]> - \_TopNExec[[Order[hire_date{f},ASC,LAST]],20[INTEGER],36] - \_ExchangeSourceExec[[_doc{f}, salary{f}, hire_date{f}],false] \ No newline at end of file +ExchangeSinkExec[[emp_no{f}#0, hire_date{f}#1, salary{f}#2],false] +\_ProjectExec[[emp_no{f}#0, hire_date{f}#1, salary{f}#2]] + \_FieldExtractExec[emp_no{f}#0]<[],[]> + \_TopNExec[[Order[hire_date{f}#1,ASC,LAST]],20[INTEGER],36] + \_ExchangeSourceExec[[_doc{f}#3, salary{f}#2, hire_date{f}#1],false] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testSomeFieldsNeededBeforeLateMaterialization/physical_optimization.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testSomeFieldsNeededBeforeLateMaterialization/physical_optimization.expected index f356ac8daa272..6fc12a53e3980 100644 --- a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testSomeFieldsNeededBeforeLateMaterialization/physical_optimization.expected +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testSomeFieldsNeededBeforeLateMaterialization/physical_optimization.expected @@ -1,8 +1,8 @@ -ProjectExec[[hire_date{f}, salary{f}, emp_no{f}]] -\_TopNExec[[Order[hire_date{f},ASC,LAST]],20[INTEGER],null] - \_ExchangeExec[[emp_no{f}, hire_date{f}, salary{f}],false] +ProjectExec[[hire_date{f}#0, salary{f}#1, emp_no{f}#2]] +\_TopNExec[[Order[hire_date{f}#0,ASC,LAST]],20[INTEGER],null] + \_ExchangeExec[[emp_no{f}#2, hire_date{f}#0, salary{f}#1],false] \_FragmentExec[filter=null, estimatedRowSize=0, reducer=[], fragment=[<> -Project[[emp_no{f}, hire_date{f}, salary{f}]] -\_TopN[[Order[hire_date{f},ASC,LAST]],20[INTEGER],false] - \_Filter[salary{f} > 10000[INTEGER]] - \_EsRelation[employees][avg_worked_seconds{f}, birth_date{f}, emp_no{f}, first_name{f}, gender{f}, height{f}, height.float{f}, height.half_float{f}, height.scaled_float{f}, hire_date{f}, is_rehired{f}, job_positions{f}, languages{f}, languages.byte{f}, languages.long{f}, languages.short{f}, last_name{f}, salary{f}, salary_change{f}, salary_change.int{f}, salary_change.keyword{f}, salary_change.long{f}, still_hired{f}]<>]] \ No newline at end of file +Project[[emp_no{f}#2, hire_date{f}#0, salary{f}#1]] +\_TopN[[Order[hire_date{f}#0,ASC,LAST]],20[INTEGER],false] + \_Filter[salary{f}#1 > 10000[INTEGER]] + \_EsRelation[employees][avg_worked_seconds{f}#3, birth_date{f}#4, emp_no{f}#2, first_name{f}#5, gender{f}#6, height{f}#7, height.float{f}#8, height.half_float{f}#9, height.scaled_float{f}#10, hire_date{f}#0, is_rehired{f}#11, job_positions{f}#12, languages{f}#13, languages.byte{f}#14, languages.long{f}#15, languages.short{f}#16, last_name{f}#17, salary{f}#1, salary_change{f}#18, salary_change.int{f}#19, salary_change.keyword{f}#20, salary_change.long{f}#21, still_hired{f}#22]<>]] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testTopNThenStats/local_reduce_physical_optimization_data_driver.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testTopNThenStats/local_reduce_physical_optimization_data_driver.expected index 6d737b8a8eb59..8dc76dd8b28df 100644 --- a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testTopNThenStats/local_reduce_physical_optimization_data_driver.expected +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testTopNThenStats/local_reduce_physical_optimization_data_driver.expected @@ -1,4 +1,4 @@ -ExchangeSinkExec[[hire_date{f}, salary{f}],false] -\_ProjectExec[[_doc{f}, hire_date{f}]] - \_FieldExtractExec[hire_date{f}]<[],[]> - \_EsQueryExec[employees], indexMode[standard], [_doc{f}], limit[20], sort[[FieldSort[field=hire_date{f}, direction=ASC, nulls=LAST]]] estimatedRowSize[24] queryBuilderAndTags [[QueryBuilderAndTags[query=null, tags=[]]]] \ No newline at end of file +ExchangeSinkExec[[hire_date{f}#0, salary{f}#1],false] +\_ProjectExec[[_doc{f}#2, hire_date{f}#0]] + \_FieldExtractExec[hire_date{f}#0]<[],[]> + \_EsQueryExec[employees], indexMode[standard], [_doc{f}#2], limit[20], sort[[FieldSort[field=hire_date{f}#0, direction=ASC, nulls=LAST]]] estimatedRowSize[24] queryBuilderAndTags [[QueryBuilderAndTags[query=null, tags=[]]]] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testTopNThenStats/local_reduce_planned_data_driver.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testTopNThenStats/local_reduce_planned_data_driver.expected index 5cc08a59070fd..070d12cb17d93 100644 --- a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testTopNThenStats/local_reduce_planned_data_driver.expected +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testTopNThenStats/local_reduce_planned_data_driver.expected @@ -1,5 +1,5 @@ -ExchangeSinkExec[[hire_date{f}, salary{f}],false] +ExchangeSinkExec[[hire_date{f}#0, salary{f}#1],false] \_FragmentExec[filter=null, estimatedRowSize=0, reducer=[], fragment=[<> -Project[[_doc{f}, hire_date{f}]] -\_TopN[[Order[hire_date{f},ASC,LAST]],20[INTEGER],false] - \_EsRelation[employees][_doc{f}, avg_worked_seconds{f}, birth_date{f}, emp_no{f}, first_name{f}, gender{f}, height{f}, height.float{f}, height.half_float{f}, height.scaled_float{f}, hire_date{f}, is_rehired{f}, job_positions{f}, languages{f}, languages.byte{f}, languages.long{f}, languages.short{f}, last_name{f}, salary{f}, salary_change{f}, salary_change.int{f}, salary_change.keyword{f}, salary_change.long{f}, still_hired{f}]<>]] \ No newline at end of file +Project[[_doc{f}#2, hire_date{f}#0]] +\_TopN[[Order[hire_date{f}#0,ASC,LAST]],20[INTEGER],false] + \_EsRelation[employees][_doc{f}#2, avg_worked_seconds{f}#3, birth_date{f}#4, emp_no{f}#5, first_name{f}#6, gender{f}#7, height{f}#8, height.float{f}#9, height.half_float{f}#10, height.scaled_float{f}#11, hire_date{f}#0, is_rehired{f}#12, job_positions{f}#13, languages{f}#14, languages.byte{f}#15, languages.long{f}#16, languages.short{f}#17, last_name{f}#18, salary{f}#1, salary_change{f}#19, salary_change.int{f}#20, salary_change.keyword{f}#21, salary_change.long{f}#22, still_hired{f}#23]<>]] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testTopNThenStats/local_reduce_planned_reduce_driver.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testTopNThenStats/local_reduce_planned_reduce_driver.expected index 89b94a06e2096..3c81025a6c14e 100644 --- a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testTopNThenStats/local_reduce_planned_reduce_driver.expected +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testTopNThenStats/local_reduce_planned_reduce_driver.expected @@ -1,5 +1,5 @@ -ExchangeSinkExec[[hire_date{f}, salary{f}],false] -\_ProjectExec[[hire_date{f}, salary{f}]] - \_FieldExtractExec[salary{f}]<[],[]> - \_TopNExec[[Order[hire_date{f},ASC,LAST]],20[INTEGER],32] - \_ExchangeSourceExec[[_doc{f}, hire_date{f}],false] \ No newline at end of file +ExchangeSinkExec[[hire_date{f}#0, salary{f}#1],false] +\_ProjectExec[[hire_date{f}#0, salary{f}#1]] + \_FieldExtractExec[salary{f}#1]<[],[]> + \_TopNExec[[Order[hire_date{f}#0,ASC,LAST]],20[INTEGER],32] + \_ExchangeSourceExec[[_doc{f}#2, hire_date{f}#0],false] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testTopNThenStats/physical_optimization.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testTopNThenStats/physical_optimization.expected index 861afa9e16c8f..d520dec0664bd 100644 --- a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testTopNThenStats/physical_optimization.expected +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testTopNThenStats/physical_optimization.expected @@ -1,10 +1,10 @@ -ProjectExec[[avg_salary{r}, count{r}]] -\_EvalExec[[$$SUM$avg_salary$0{r$} / $$COUNT$avg_salary$1{r$} AS avg_salary]] +ProjectExec[[avg_salary{r}#0, count{r}#1]] +\_EvalExec[[$$SUM$avg_salary$0{r$}#2 / $$COUNT$avg_salary$1{r$}#3 AS avg_salary#0]] \_LimitExec[10000[INTEGER],null] - \_AggregateExec[[],[SUM(salary{f},true[BOOLEAN],PT0S[TIME_DURATION],compensated[KEYWORD]) AS $$SUM$avg_salary$0, COUNT(salary{f},true[BOOLEAN],PT0S[TIME_DURATION]) AS $$COUNT$avg_salary$1, COUNT(*[KEYWORD],true[BOOLEAN],PT0S[TIME_DURATION]) AS count],SINGLE,[$$SUM$avg_salary$0$sum{r}, $$SUM$avg_salary$0$seen{r}, $$COUNT$avg_salary$1$count{r}, $$COUNT$avg_salary$1$seen{r}, $$count$count{r}, $$count$seen{r}],null] - \_TopNExec[[Order[hire_date{f},ASC,LAST]],20[INTEGER],null] - \_ExchangeExec[[hire_date{f}, salary{f}],false] + \_AggregateExec[[],[SUM(salary{f}#4,true[BOOLEAN],PT0S[TIME_DURATION],compensated[KEYWORD]) AS $$SUM$avg_salary$0#2, COUNT(salary{f}#4,true[BOOLEAN],PT0S[TIME_DURATION]) AS $$COUNT$avg_salary$1#3, COUNT(*[KEYWORD],true[BOOLEAN],PT0S[TIME_DURATION]) AS count#1],SINGLE,[$$SUM$avg_salary$0$sum{r}#5, $$SUM$avg_salary$0$seen{r}#6, $$COUNT$avg_salary$1$count{r}#7, $$COUNT$avg_salary$1$seen{r}#8, $$count$count{r}#9, $$count$seen{r}#10],null] + \_TopNExec[[Order[hire_date{f}#11,ASC,LAST]],20[INTEGER],null] + \_ExchangeExec[[hire_date{f}#11, salary{f}#4],false] \_FragmentExec[filter=null, estimatedRowSize=0, reducer=[], fragment=[<> -Project[[hire_date{f}, salary{f}]] -\_TopN[[Order[hire_date{f},ASC,LAST]],20[INTEGER],false] - \_EsRelation[employees][avg_worked_seconds{f}, birth_date{f}, emp_no{f}, first_name{f}, gender{f}, height{f}, height.float{f}, height.half_float{f}, height.scaled_float{f}, hire_date{f}, is_rehired{f}, job_positions{f}, languages{f}, languages.byte{f}, languages.long{f}, languages.short{f}, last_name{f}, salary{f}, salary_change{f}, salary_change.int{f}, salary_change.keyword{f}, salary_change.long{f}, still_hired{f}]<>]] \ No newline at end of file +Project[[hire_date{f}#11, salary{f}#4]] +\_TopN[[Order[hire_date{f}#11,ASC,LAST]],20[INTEGER],false] + \_EsRelation[employees][avg_worked_seconds{f}#12, birth_date{f}#13, emp_no{f}#14, first_name{f}#15, gender{f}#16, height{f}#17, height.float{f}#18, height.half_float{f}#19, height.scaled_float{f}#20, hire_date{f}#11, is_rehired{f}#21, job_positions{f}#22, languages{f}#23, languages.byte{f}#24, languages.long{f}#25, languages.short{f}#26, last_name{f}#27, salary{f}#4, salary_change{f}#28, salary_change.int{f}#29, salary_change.keyword{f}#30, salary_change.long{f}#31, still_hired{f}#32]<>]] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testTopNWithMissingSortField/local_reduce_physical_optimization_data_driver.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testTopNWithMissingSortField/local_reduce_physical_optimization_data_driver.expected index 86be6bee3c591..0280707cf7711 100644 --- a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testTopNWithMissingSortField/local_reduce_physical_optimization_data_driver.expected +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testTopNWithMissingSortField/local_reduce_physical_optimization_data_driver.expected @@ -1,4 +1,4 @@ -ExchangeSinkExec[[emp_no{f}, hire_date{f}, salary{f}],false] -\_ProjectExec[[_doc{f}, birth_date{r} AS hire_date]] - \_EvalExec[[null[DATETIME] AS birth_date]] - \_EsQueryExec[employees], indexMode[standard], [_doc{f}], limit[20], sort[] estimatedRowSize[12] queryBuilderAndTags [[QueryBuilderAndTags[query=null, tags=[]]]] \ No newline at end of file +ExchangeSinkExec[[emp_no{f}#0, hire_date{f}#1, salary{f}#2],false] +\_ProjectExec[[_doc{f}#3, birth_date{r}#4 AS hire_date#1]] + \_EvalExec[[null[DATETIME] AS birth_date#4]] + \_EsQueryExec[employees], indexMode[standard], [_doc{f}#3], limit[20], sort[] estimatedRowSize[12] queryBuilderAndTags [[QueryBuilderAndTags[query=null, tags=[]]]] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testTopNWithMissingSortField/local_reduce_planned_data_driver.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testTopNWithMissingSortField/local_reduce_planned_data_driver.expected index 42c2f1deccb35..fc4d011c9a8fb 100644 --- a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testTopNWithMissingSortField/local_reduce_planned_data_driver.expected +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testTopNWithMissingSortField/local_reduce_planned_data_driver.expected @@ -1,5 +1,5 @@ -ExchangeSinkExec[[emp_no{f}, hire_date{f}, salary{f}],false] +ExchangeSinkExec[[emp_no{f}#0, hire_date{f}#1, salary{f}#2],false] \_FragmentExec[filter=null, estimatedRowSize=0, reducer=[], fragment=[<> -Project[[_doc{f}, hire_date{f}]] -\_TopN[[Order[hire_date{f},ASC,LAST]],20[INTEGER],false] - \_EsRelation[employees][_doc{f}, avg_worked_seconds{f}, birth_date{f}, emp_no{f}, first_name{f}, gender{f}, height{f}, height.float{f}, height.half_float{f}, height.scaled_float{f}, hire_date{f}, is_rehired{f}, job_positions{f}, languages{f}, languages.byte{f}, languages.long{f}, languages.short{f}, last_name{f}, salary{f}, salary_change{f}, salary_change.int{f}, salary_change.keyword{f}, salary_change.long{f}, still_hired{f}]<>]] \ No newline at end of file +Project[[_doc{f}#3, hire_date{f}#1]] +\_TopN[[Order[hire_date{f}#1,ASC,LAST]],20[INTEGER],false] + \_EsRelation[employees][_doc{f}#3, avg_worked_seconds{f}#4, birth_date{f}#5, emp_no{f}#0, first_name{f}#6, gender{f}#7, height{f}#8, height.float{f}#9, height.half_float{f}#10, height.scaled_float{f}#11, hire_date{f}#1, is_rehired{f}#12, job_positions{f}#13, languages{f}#14, languages.byte{f}#15, languages.long{f}#16, languages.short{f}#17, last_name{f}#18, salary{f}#2, salary_change{f}#19, salary_change.int{f}#20, salary_change.keyword{f}#21, salary_change.long{f}#22, still_hired{f}#23]<>]] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testTopNWithMissingSortField/local_reduce_planned_reduce_driver.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testTopNWithMissingSortField/local_reduce_planned_reduce_driver.expected index 378271a5e3f37..4b4fc0c891ac1 100644 --- a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testTopNWithMissingSortField/local_reduce_planned_reduce_driver.expected +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testTopNWithMissingSortField/local_reduce_planned_reduce_driver.expected @@ -1,5 +1,5 @@ -ExchangeSinkExec[[emp_no{f}, hire_date{f}, salary{f}],false] -\_ProjectExec[[emp_no{f}, hire_date{f}, salary{f}]] - \_FieldExtractExec[emp_no{f}, salary{f}]<[],[]> - \_TopNExec[[Order[hire_date{f},ASC,LAST]],20[INTEGER],36] - \_ExchangeSourceExec[[_doc{f}, hire_date{f}],false] \ No newline at end of file +ExchangeSinkExec[[emp_no{f}#0, hire_date{f}#1, salary{f}#2],false] +\_ProjectExec[[emp_no{f}#0, hire_date{f}#1, salary{f}#2]] + \_FieldExtractExec[emp_no{f}#0, salary{f}#2]<[],[]> + \_TopNExec[[Order[hire_date{f}#1,ASC,LAST]],20[INTEGER],36] + \_ExchangeSourceExec[[_doc{f}#3, hire_date{f}#1],false] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testTopNWithMissingSortField/physical_optimization.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testTopNWithMissingSortField/physical_optimization.expected index cd76be3897e14..84b502cae4e25 100644 --- a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testTopNWithMissingSortField/physical_optimization.expected +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testTopNWithMissingSortField/physical_optimization.expected @@ -1,7 +1,7 @@ -ProjectExec[[hire_date{f}, salary{f}, emp_no{f}]] -\_TopNExec[[Order[hire_date{f},ASC,LAST]],20[INTEGER],null] - \_ExchangeExec[[emp_no{f}, hire_date{f}, salary{f}],false] +ProjectExec[[hire_date{f}#0, salary{f}#1, emp_no{f}#2]] +\_TopNExec[[Order[hire_date{f}#0,ASC,LAST]],20[INTEGER],null] + \_ExchangeExec[[emp_no{f}#2, hire_date{f}#0, salary{f}#1],false] \_FragmentExec[filter=null, estimatedRowSize=0, reducer=[], fragment=[<> -Project[[emp_no{f}, hire_date{f}, salary{f}]] -\_TopN[[Order[hire_date{f},ASC,LAST]],20[INTEGER],false] - \_EsRelation[employees][avg_worked_seconds{f}, birth_date{f}, emp_no{f}, first_name{f}, gender{f}, height{f}, height.float{f}, height.half_float{f}, height.scaled_float{f}, hire_date{f}, is_rehired{f}, job_positions{f}, languages{f}, languages.byte{f}, languages.long{f}, languages.short{f}, last_name{f}, salary{f}, salary_change{f}, salary_change.int{f}, salary_change.keyword{f}, salary_change.long{f}, still_hired{f}]<>]] \ No newline at end of file +Project[[emp_no{f}#2, hire_date{f}#0, salary{f}#1]] +\_TopN[[Order[hire_date{f}#0,ASC,LAST]],20[INTEGER],false] + \_EsRelation[employees][avg_worked_seconds{f}#3, birth_date{f}#4, emp_no{f}#2, first_name{f}#5, gender{f}#6, height{f}#7, height.float{f}#8, height.half_float{f}#9, height.scaled_float{f}#10, hire_date{f}#0, is_rehired{f}#11, job_positions{f}#12, languages{f}#13, languages.byte{f}#14, languages.long{f}#15, languages.short{f}#16, last_name{f}#17, salary{f}#1, salary_change{f}#18, salary_change.int{f}#19, salary_change.keyword{f}#20, salary_change.long{f}#21, still_hired{f}#22]<>]] \ No newline at end of file From a976a8833042e5964cade910e7ac273a7b959c1c Mon Sep 17 00:00:00 2001 From: Gal Lalouche Date: Tue, 3 Feb 2026 14:51:59 +0200 Subject: [PATCH 11/25] Synthetic names --- .../xpack/esql/optimizer/GoldenTestCase.java | 32 ++++++++----------- ...physical_optimization_data_driver.expected | 8 ++--- .../local_reduce_planned_data_driver.expected | 8 ++--- ...ocal_reduce_planned_reduce_driver.expected | 8 ++--- .../physical_optimization.expected | 10 +++--- ...physical_optimization_data_driver.expected | 8 ++--- .../local_reduce_planned_data_driver.expected | 8 ++--- ...ocal_reduce_planned_reduce_driver.expected | 8 ++--- .../physical_optimization.expected | 10 +++--- 9 files changed, 48 insertions(+), 52 deletions(-) diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/optimizer/GoldenTestCase.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/optimizer/GoldenTestCase.java index e6f833bad54c6..e5e9a2ff66abd 100644 --- a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/optimizer/GoldenTestCase.java +++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/optimizer/GoldenTestCase.java @@ -28,7 +28,6 @@ import org.elasticsearch.xpack.esql.analysis.UnmappedResolution; import org.elasticsearch.xpack.esql.core.expression.FoldContext; import org.elasticsearch.xpack.esql.core.tree.Node; -import org.elasticsearch.xpack.esql.core.util.Holder; import org.elasticsearch.xpack.esql.expression.function.EsqlFunctionRegistry; import org.elasticsearch.xpack.esql.inference.InferenceResolution; import org.elasticsearch.xpack.esql.parser.EsqlParser; @@ -387,21 +386,15 @@ private static Test.TestResult createNewOutput(Path output, QueryPlan plan) t private static String normalizeNameIds(Node plan) { String full = plan.toString(Node.NodeStringFormat.FULL); - // full = normalizeSyntheticNames(full); + full = normalizeSyntheticNames(full); Matcher matcher = IDENTIFIER_PATTERN.matcher(full); StringBuilder sb = new StringBuilder(); int lastEnd = 0; - Holder counterHolder = new Holder<>(0); - Map idMap = new HashMap<>(); + var idMap = new IdMap(); while (matcher.find()) { sb.append(full, lastEnd, matcher.start()); int originalId = Integer.parseInt(matcher.group().substring(1)); // Drop the initial '#' prefix - int newId = idMap.computeIfAbsent(originalId, k -> { - int current = counterHolder.get(); - counterHolder.set(current + 1); - return current; - }); - sb.append("#").append(newId); + sb.append("#").append(idMap.getId(originalId)); lastEnd = matcher.end(); } sb.append(full, lastEnd, full.length()); @@ -416,17 +409,11 @@ private static String normalizeSyntheticNames(String full) { Matcher matcher = SYNTHETIC_PATTERN.matcher(full); StringBuilder sb = new StringBuilder(); int lastEnd = 0; - Holder runningInt = new Holder<>(0); - Map idMap = new HashMap<>(); + var idMap = new IdMap(); while (matcher.find()) { sb.append(full, lastEnd, matcher.start()); String firstSegment = matcher.group(1); - int newId = idMap.computeIfAbsent(firstSegment, k -> { - int current = runningInt.get(); - runningInt.set(current + 1); - return current; - }); - sb.append("$$").append(firstSegment).append("$").append(newId); + sb.append("$$").append(firstSegment).append("$").append(idMap.getId(firstSegment)); lastEnd = matcher.end(); } sb.append(full, lastEnd, full.length()); @@ -436,6 +423,15 @@ private static String normalizeSyntheticNames(String full) { private static final Pattern SYNTHETIC_PATTERN = Pattern.compile("\\$\\$([^$\\s]+)(\\$\\d+)+(?=[{#])"); private static final Pattern IDENTIFIER_PATTERN = Pattern.compile("#\\d+"); + private static class IdMap { + private final Map map = new HashMap<>(); + private int counter = 0; + + public int getId(K key) { + return map.computeIfAbsent(key, k -> counter++); + } + } + private static Test.TestResult verifyExisting(Path output, QueryPlan plan) throws IOException { String testString = normalize(normalizeNameIds(plan)); if (testString.equals(normalize(Files.readString(output)))) { diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testExpressionSortTopNKeepAfterSort/local_reduce_physical_optimization_data_driver.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testExpressionSortTopNKeepAfterSort/local_reduce_physical_optimization_data_driver.expected index b70e2da30d8d9..8f49d89b830ce 100644 --- a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testExpressionSortTopNKeepAfterSort/local_reduce_physical_optimization_data_driver.expected +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testExpressionSortTopNKeepAfterSort/local_reduce_physical_optimization_data_driver.expected @@ -1,6 +1,6 @@ -ExchangeSinkExec[[hire_date{f}#0, $$order_by$0$1{r}#1],false] -\_ProjectExec[[_doc{f}#2, $$order_by$0$1{r}#1]] - \_TopNExec[[Order[$$order_by$0$1{r}#1,ASC,LAST]],20[INTEGER],36] - \_EvalExec[[SIN(height{f}#3) * 2[INTEGER] AS $$order_by$0$1#1]] +ExchangeSinkExec[[hire_date{f}#0, $$order_by$0{r}#1],false] +\_ProjectExec[[_doc{f}#2, $$order_by$0{r}#1]] + \_TopNExec[[Order[$$order_by$0{r}#1,ASC,LAST]],20[INTEGER],36] + \_EvalExec[[SIN(height{f}#3) * 2[INTEGER] AS $$order_by$0#1]] \_FieldExtractExec[height{f}#3]<[],[]> \_EsQueryExec[employees], indexMode[standard], [_doc{f}#2], limit[], sort[] estimatedRowSize[20] queryBuilderAndTags [[QueryBuilderAndTags[query=null, tags=[]]]] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testExpressionSortTopNKeepAfterSort/local_reduce_planned_data_driver.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testExpressionSortTopNKeepAfterSort/local_reduce_planned_data_driver.expected index 6e7579d93480f..9ce3f748778c1 100644 --- a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testExpressionSortTopNKeepAfterSort/local_reduce_planned_data_driver.expected +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testExpressionSortTopNKeepAfterSort/local_reduce_planned_data_driver.expected @@ -1,6 +1,6 @@ -ExchangeSinkExec[[hire_date{f}#0, $$order_by$0$1{r}#1],false] +ExchangeSinkExec[[hire_date{f}#0, $$order_by$0{r}#1],false] \_FragmentExec[filter=null, estimatedRowSize=0, reducer=[], fragment=[<> -Project[[_doc{f}#2, $$order_by$0$1{r}#1]] -\_TopN[[Order[$$order_by$0$1{r}#1,ASC,LAST]],20[INTEGER],false] - \_Eval[[SIN(height{f}#3) * 2[INTEGER] AS $$order_by$0$1#1]] +Project[[_doc{f}#2, $$order_by$0{r}#1]] +\_TopN[[Order[$$order_by$0{r}#1,ASC,LAST]],20[INTEGER],false] + \_Eval[[SIN(height{f}#3) * 2[INTEGER] AS $$order_by$0#1]] \_EsRelation[employees][_doc{f}#2, avg_worked_seconds{f}#4, birth_date{f}#5, emp_no{f}#6, first_name{f}#7, gender{f}#8, height{f}#3, height.float{f}#9, height.half_float{f}#10, height.scaled_float{f}#11, hire_date{f}#0, is_rehired{f}#12, job_positions{f}#13, languages{f}#14, languages.byte{f}#15, languages.long{f}#16, languages.short{f}#17, last_name{f}#18, salary{f}#19, salary_change{f}#20, salary_change.int{f}#21, salary_change.keyword{f}#22, salary_change.long{f}#23, still_hired{f}#24]<>]] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testExpressionSortTopNKeepAfterSort/local_reduce_planned_reduce_driver.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testExpressionSortTopNKeepAfterSort/local_reduce_planned_reduce_driver.expected index b69f8a120e20a..d2459818c5588 100644 --- a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testExpressionSortTopNKeepAfterSort/local_reduce_planned_reduce_driver.expected +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testExpressionSortTopNKeepAfterSort/local_reduce_planned_reduce_driver.expected @@ -1,5 +1,5 @@ -ExchangeSinkExec[[hire_date{f}#0, $$order_by$0$1{r}#1],false] -\_ProjectExec[[hire_date{f}#0, $$order_by$0$1{r}#1]] +ExchangeSinkExec[[hire_date{f}#0, $$order_by$0{r}#1],false] +\_ProjectExec[[hire_date{f}#0, $$order_by$0{r}#1]] \_FieldExtractExec[hire_date{f}#0]<[],[]> - \_TopNExec[[Order[$$order_by$0$1{r}#1,ASC,LAST]],20[INTEGER],36] - \_ExchangeSourceExec[[_doc{f}#2, $$order_by$0$1{r}#1],false] \ No newline at end of file + \_TopNExec[[Order[$$order_by$0{r}#1,ASC,LAST]],20[INTEGER],36] + \_ExchangeSourceExec[[_doc{f}#2, $$order_by$0{r}#1],false] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testExpressionSortTopNKeepAfterSort/physical_optimization.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testExpressionSortTopNKeepAfterSort/physical_optimization.expected index 40e41a83c3210..71abdab6b07fe 100644 --- a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testExpressionSortTopNKeepAfterSort/physical_optimization.expected +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testExpressionSortTopNKeepAfterSort/physical_optimization.expected @@ -1,8 +1,8 @@ ProjectExec[[hire_date{f}#0]] -\_TopNExec[[Order[$$order_by$0$1{r}#1,ASC,LAST]],20[INTEGER],null] - \_ExchangeExec[[hire_date{f}#0, $$order_by$0$1{r}#1],false] +\_TopNExec[[Order[$$order_by$0{r}#1,ASC,LAST]],20[INTEGER],null] + \_ExchangeExec[[hire_date{f}#0, $$order_by$0{r}#1],false] \_FragmentExec[filter=null, estimatedRowSize=0, reducer=[], fragment=[<> -Project[[hire_date{f}#0, $$order_by$0$1{r}#1]] -\_TopN[[Order[$$order_by$0$1{r}#1,ASC,LAST]],20[INTEGER],false] - \_Eval[[SIN(height{f}#2) * 2[INTEGER] AS $$order_by$0$1#1]] +Project[[hire_date{f}#0, $$order_by$0{r}#1]] +\_TopN[[Order[$$order_by$0{r}#1,ASC,LAST]],20[INTEGER],false] + \_Eval[[SIN(height{f}#2) * 2[INTEGER] AS $$order_by$0#1]] \_EsRelation[employees][avg_worked_seconds{f}#3, birth_date{f}#4, emp_no{f}#5, first_name{f}#6, gender{f}#7, height{f}#2, height.float{f}#8, height.half_float{f}#9, height.scaled_float{f}#10, hire_date{f}#0, is_rehired{f}#11, job_positions{f}#12, languages{f}#13, languages.byte{f}#14, languages.long{f}#15, languages.short{f}#16, last_name{f}#17, salary{f}#18, salary_change{f}#19, salary_change.int{f}#20, salary_change.keyword{f}#21, salary_change.long{f}#22, still_hired{f}#23]<>]] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testExpressionSortTopNKeepBeforeSort/local_reduce_physical_optimization_data_driver.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testExpressionSortTopNKeepBeforeSort/local_reduce_physical_optimization_data_driver.expected index d7b0d2e276b29..460cbcab3451e 100644 --- a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testExpressionSortTopNKeepBeforeSort/local_reduce_physical_optimization_data_driver.expected +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testExpressionSortTopNKeepBeforeSort/local_reduce_physical_optimization_data_driver.expected @@ -1,6 +1,6 @@ -ExchangeSinkExec[[height{f}#0, hire_date{f}#1, $$order_by$0$0{r}#2],false] -\_ProjectExec[[_doc{f}#3, height{f}#0, $$order_by$0$0{r}#2]] - \_TopNExec[[Order[$$order_by$0$0{r}#2,ASC,LAST]],20[INTEGER],36] - \_EvalExec[[SIN(height{f}#0) * 2[INTEGER] AS $$order_by$0$0#2]] +ExchangeSinkExec[[height{f}#0, hire_date{f}#1, $$order_by$0{r}#2],false] +\_ProjectExec[[_doc{f}#3, height{f}#0, $$order_by$0{r}#2]] + \_TopNExec[[Order[$$order_by$0{r}#2,ASC,LAST]],20[INTEGER],36] + \_EvalExec[[SIN(height{f}#0) * 2[INTEGER] AS $$order_by$0#2]] \_FieldExtractExec[height{f}#0]<[],[]> \_EsQueryExec[employees], indexMode[standard], [_doc{f}#3], limit[], sort[] estimatedRowSize[20] queryBuilderAndTags [[QueryBuilderAndTags[query=null, tags=[]]]] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testExpressionSortTopNKeepBeforeSort/local_reduce_planned_data_driver.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testExpressionSortTopNKeepBeforeSort/local_reduce_planned_data_driver.expected index 44d16e2751dd8..932c4834e7e80 100644 --- a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testExpressionSortTopNKeepBeforeSort/local_reduce_planned_data_driver.expected +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testExpressionSortTopNKeepBeforeSort/local_reduce_planned_data_driver.expected @@ -1,6 +1,6 @@ -ExchangeSinkExec[[height{f}#0, hire_date{f}#1, $$order_by$0$0{r}#2],false] +ExchangeSinkExec[[height{f}#0, hire_date{f}#1, $$order_by$0{r}#2],false] \_FragmentExec[filter=null, estimatedRowSize=0, reducer=[], fragment=[<> -Project[[_doc{f}#3, height{f}#0, $$order_by$0$0{r}#2]] -\_TopN[[Order[$$order_by$0$0{r}#2,ASC,LAST]],20[INTEGER],false] - \_Eval[[SIN(height{f}#0) * 2[INTEGER] AS $$order_by$0$0#2]] +Project[[_doc{f}#3, height{f}#0, $$order_by$0{r}#2]] +\_TopN[[Order[$$order_by$0{r}#2,ASC,LAST]],20[INTEGER],false] + \_Eval[[SIN(height{f}#0) * 2[INTEGER] AS $$order_by$0#2]] \_EsRelation[employees][_doc{f}#3, avg_worked_seconds{f}#4, birth_date{f}#5, emp_no{f}#6, first_name{f}#7, gender{f}#8, height{f}#0, height.float{f}#9, height.half_float{f}#10, height.scaled_float{f}#11, hire_date{f}#1, is_rehired{f}#12, job_positions{f}#13, languages{f}#14, languages.byte{f}#15, languages.long{f}#16, languages.short{f}#17, last_name{f}#18, salary{f}#19, salary_change{f}#20, salary_change.int{f}#21, salary_change.keyword{f}#22, salary_change.long{f}#23, still_hired{f}#24]<>]] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testExpressionSortTopNKeepBeforeSort/local_reduce_planned_reduce_driver.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testExpressionSortTopNKeepBeforeSort/local_reduce_planned_reduce_driver.expected index 45f5637b6faac..88c85960c5dd2 100644 --- a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testExpressionSortTopNKeepBeforeSort/local_reduce_planned_reduce_driver.expected +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testExpressionSortTopNKeepBeforeSort/local_reduce_planned_reduce_driver.expected @@ -1,5 +1,5 @@ -ExchangeSinkExec[[height{f}#0, hire_date{f}#1, $$order_by$0$0{r}#2],false] -\_ProjectExec[[height{f}#0, hire_date{f}#1, $$order_by$0$0{r}#2]] +ExchangeSinkExec[[height{f}#0, hire_date{f}#1, $$order_by$0{r}#2],false] +\_ProjectExec[[height{f}#0, hire_date{f}#1, $$order_by$0{r}#2]] \_FieldExtractExec[hire_date{f}#1]<[],[]> - \_TopNExec[[Order[$$order_by$0$0{r}#2,ASC,LAST]],20[INTEGER],44] - \_ExchangeSourceExec[[_doc{f}#3, height{f}#0, $$order_by$0$0{r}#2],false] \ No newline at end of file + \_TopNExec[[Order[$$order_by$0{r}#2,ASC,LAST]],20[INTEGER],44] + \_ExchangeSourceExec[[_doc{f}#3, height{f}#0, $$order_by$0{r}#2],false] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testExpressionSortTopNKeepBeforeSort/physical_optimization.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testExpressionSortTopNKeepBeforeSort/physical_optimization.expected index 083b9f2af3acf..b3fbad771e03e 100644 --- a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testExpressionSortTopNKeepBeforeSort/physical_optimization.expected +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testExpressionSortTopNKeepBeforeSort/physical_optimization.expected @@ -1,8 +1,8 @@ ProjectExec[[hire_date{f}#0, height{f}#1]] -\_TopNExec[[Order[$$order_by$0$0{r}#2,ASC,LAST]],20[INTEGER],null] - \_ExchangeExec[[height{f}#1, hire_date{f}#0, $$order_by$0$0{r}#2],false] +\_TopNExec[[Order[$$order_by$0{r}#2,ASC,LAST]],20[INTEGER],null] + \_ExchangeExec[[height{f}#1, hire_date{f}#0, $$order_by$0{r}#2],false] \_FragmentExec[filter=null, estimatedRowSize=0, reducer=[], fragment=[<> -Project[[height{f}#1, hire_date{f}#0, $$order_by$0$0{r}#2]] -\_TopN[[Order[$$order_by$0$0{r}#2,ASC,LAST]],20[INTEGER],false] - \_Eval[[SIN(height{f}#1) * 2[INTEGER] AS $$order_by$0$0#2]] +Project[[height{f}#1, hire_date{f}#0, $$order_by$0{r}#2]] +\_TopN[[Order[$$order_by$0{r}#2,ASC,LAST]],20[INTEGER],false] + \_Eval[[SIN(height{f}#1) * 2[INTEGER] AS $$order_by$0#2]] \_EsRelation[employees][avg_worked_seconds{f}#3, birth_date{f}#4, emp_no{f}#5, first_name{f}#6, gender{f}#7, height{f}#1, height.float{f}#8, height.half_float{f}#9, height.scaled_float{f}#10, hire_date{f}#0, is_rehired{f}#11, job_positions{f}#12, languages{f}#13, languages.byte{f}#14, languages.long{f}#15, languages.short{f}#16, last_name{f}#17, salary{f}#18, salary_change{f}#19, salary_change.int{f}#20, salary_change.keyword{f}#21, salary_change.long{f}#22, still_hired{f}#23]<>]] \ No newline at end of file From 6a98ff7b13c40bb779767ec5eb81188cdf19245d Mon Sep 17 00:00:00 2001 From: Gal Lalouche Date: Tue, 3 Feb 2026 15:19:41 +0200 Subject: [PATCH 12/25] Refactor --- .../xpack/esql/optimizer/GoldenTestCase.java | 44 +++++++++---------- 1 file changed, 21 insertions(+), 23 deletions(-) diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/optimizer/GoldenTestCase.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/optimizer/GoldenTestCase.java index e5e9a2ff66abd..8006d3a2c7cd3 100644 --- a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/optimizer/GoldenTestCase.java +++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/optimizer/GoldenTestCase.java @@ -60,6 +60,7 @@ import java.util.HashMap; import java.util.List; import java.util.Map; +import java.util.function.Function; import java.util.regex.Matcher; import java.util.regex.Pattern; import java.util.stream.Collectors; @@ -380,48 +381,45 @@ private static Test.TestResult createNewOutput(Path output, QueryPlan plan) t if (output.toString().contains("extra")) { throw new IllegalStateException("Extra output files should not be created automatically:" + output); } - Files.writeString(output, normalizeNameIds(plan), StandardCharsets.UTF_8); + Files.writeString(output, toCanonicalString(plan), StandardCharsets.UTF_8); return Test.TestResult.CREATED; } - private static String normalizeNameIds(Node plan) { + private static String toCanonicalString(Node plan) { String full = plan.toString(Node.NodeStringFormat.FULL); - full = normalizeSyntheticNames(full); - Matcher matcher = IDENTIFIER_PATTERN.matcher(full); - StringBuilder sb = new StringBuilder(); - int lastEnd = 0; + return normalizeNameIds(normalizeSyntheticNames(full)); + } + + private static String normalizeNameIds(String plan) { var idMap = new IdMap(); - while (matcher.find()) { - sb.append(full, lastEnd, matcher.start()); - int originalId = Integer.parseInt(matcher.group().substring(1)); // Drop the initial '#' prefix - sb.append("#").append(idMap.getId(originalId)); - lastEnd = matcher.end(); - } - sb.append(full, lastEnd, full.length()); - return sb.toString(); + return normalizeHelper(plan, IDENTIFIER_PATTERN, s -> "#" + idMap.getId(Integer.parseInt(s))); } /** * Normalizes synthetic attribute names of the form $$something($something)* that are followed by # (node id). * Replaces them with $$firstSegment$runningInt so golden output is stable across runs. */ - private static String normalizeSyntheticNames(String full) { - Matcher matcher = SYNTHETIC_PATTERN.matcher(full); + private static String normalizeSyntheticNames(String plan) { + var idMap = new IdMap(); + return normalizeHelper(plan, SYNTHETIC_PATTERN, s -> "$$" + s + "$" + idMap.getId(s)); + } + + private static String normalizeHelper(String s, Pattern p, Function replacer) { + Matcher matcher = p.matcher(s); StringBuilder sb = new StringBuilder(); int lastEnd = 0; - var idMap = new IdMap(); while (matcher.find()) { - sb.append(full, lastEnd, matcher.start()); - String firstSegment = matcher.group(1); - sb.append("$$").append(firstSegment).append("$").append(idMap.getId(firstSegment)); + sb.append(s, lastEnd, matcher.start()); + sb.append(replacer.apply(matcher.group(1))); lastEnd = matcher.end(); } - sb.append(full, lastEnd, full.length()); + sb.append(s, lastEnd, s.length()); return sb.toString(); + } private static final Pattern SYNTHETIC_PATTERN = Pattern.compile("\\$\\$([^$\\s]+)(\\$\\d+)+(?=[{#])"); - private static final Pattern IDENTIFIER_PATTERN = Pattern.compile("#\\d+"); + private static final Pattern IDENTIFIER_PATTERN = Pattern.compile("#(\\d+)"); private static class IdMap { private final Map map = new HashMap<>(); @@ -433,7 +431,7 @@ public int getId(K key) { } private static Test.TestResult verifyExisting(Path output, QueryPlan plan) throws IOException { - String testString = normalize(normalizeNameIds(plan)); + String testString = normalize(toCanonicalString(plan)); if (testString.equals(normalize(Files.readString(output)))) { if (System.getProperty("golden.cleanactual") != null) { Path path = actualPath(output); From dd3ef6ba821816e9ca9a2b9137328f5de4735468 Mon Sep 17 00:00:00 2001 From: Gal Lalouche Date: Tue, 3 Feb 2026 17:05:04 +0200 Subject: [PATCH 13/25] Golden test start --- .../analysis/AnalyzerUnmappedGoldenTests.java | 295 ++++++++++++++++++ .../xpack/esql/optimizer/GoldenTestCase.java | 12 +- 2 files changed, 301 insertions(+), 6 deletions(-) create mode 100644 x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/analysis/AnalyzerUnmappedGoldenTests.java diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/analysis/AnalyzerUnmappedGoldenTests.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/analysis/AnalyzerUnmappedGoldenTests.java new file mode 100644 index 0000000000000..9db97289ae7ae --- /dev/null +++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/analysis/AnalyzerUnmappedGoldenTests.java @@ -0,0 +1,295 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. + */ + +package org.elasticsearch.xpack.esql.analysis; + +import org.elasticsearch.xpack.esql.action.EsqlCapabilities; +import org.elasticsearch.xpack.esql.optimizer.GoldenTestCase; + +import java.util.EnumSet; + +import static org.elasticsearch.xpack.esql.EsqlTestUtils.withDefaultLimitWarning; + +/** + * Golden tests for analyzer behavior with unmapped fields using SET unmapped_fields="nullify". + * These tests verify that unmapped fields are properly handled by converting them to null literals. + */ +public class AnalyzerUnmappedGoldenTests extends GoldenTestCase { + private static final EnumSet STAGES = EnumSet.of(Stage.ANALYSIS); + + public void testKeep() throws Exception { + runTests(""" + FROM test + | KEEP does_not_exist_field + """); + } + + public void testKeepRepeated() throws Exception { + runTests(""" + FROM test + | KEEP does_not_exist_field, does_not_exist_field + """); + } + + public void testKeepAndMatchingStar() throws Exception { + runTests(""" + FROM test + | KEEP emp_*, does_not_exist_field + """); + } + + public void testEvalAndKeep() throws Exception { + runTests(""" + FROM test + | EVAL x = does_not_exist_field1::INTEGER + 42 + | KEEP does_not_exist_field1, does_not_exist_field2 + """); + } + + public void testEvalAfterKeepStar() throws Exception { + runTests(""" + FROM test + | KEEP * + | EVAL x = emp_no + 1 + | EVAL y = does_not_exist_field + 2 + """); + } + + public void testEvalAfterMatchingKeepWithWildcard() throws Exception { + runTests(""" + FROM test + | KEEP emp_no, * + | EVAL x = emp_no + 1 + | EVAL y = emp_does_not_exist_field + 2 + """); + } + + public void testDrop() throws Exception { + runTests(""" + FROM test + | DROP does_not_exist_field, emp_no + """); + } + + public void testDropAndMatchingStar() throws Exception { + runTests(""" + FROM test + | DROP emp_*, does_not_exist_field + """); + } + + public void testRename() throws Exception { + runTests(""" + FROM test + | RENAME does_not_exist_field AS now_it_does, emp_no AS employee_number + """); + } + + public void testRenameRepeated() throws Exception { + runTests(""" + FROM test + | RENAME does_not_exist_field AS now_it_does, neither_does_this AS now_it_does, emp_no AS employee_number + """); + } + + public void testRenameEval() throws Exception { + runTests(""" + FROM test + | RENAME emp_no AS employee_number + | EVAL x = does_not_exist + 1 + """); + } + + public void testEval() throws Exception { + runTests(""" + FROM test + | EVAL x = does_not_exist_field + 1 + """); + } + + public void testMultipleEval() throws Exception { + runTests(""" + FROM test + | EVAL a = 1 + | EVAL x = a + b + | EVAL y = b + c + """); + } + + public void testEvalCast() throws Exception { + runTests(""" + FROM test + | EVAL x = does_not_exist_field::LONG + """); + } + + public void testEvalCastInPlace() throws Exception { + runTests(""" + FROM test + | EVAL does_not_exist_field::LONG + """); + } + + public void testEvalReplace() throws Exception { + runTests(""" + FROM test + | EVAL x = does_not_exist_field + 1 + | EVAL does_not_exist_field = 42 + """); + } + + public void testKeepThenEval() throws Exception { + runTests(""" + FROM test + | KEEP does_not_exist_field + | EVAL does_not_exist_field = 42 + """); + } + + public void testStatsCount() throws Exception { + runTests(""" + FROM test + | STATS cnt = COUNT(does_not_exist_field) + """); + } + + public void testStatsBy() throws Exception { + runTests(""" + FROM test + | STATS BY does_not_exist_field + """); + } + + public void testStatsSumBy() throws Exception { + runTests(""" + FROM test + | STATS s = SUM(does_not_exist1) BY does_not_exist2 + """); + } + + public void testStatsSumByMultiple() throws Exception { + runTests(""" + FROM test + | STATS s = SUM(does_not_exist1) + d2 BY d2 = does_not_exist2, emp_no + """); + } + + public void testStatsSumByComplex() throws Exception { + runTests(""" + FROM test + | STATS sum = SUM(does_not_exist1) + s0 + s1 BY s0 = does_not_exist2 + does_not_exist3, s1 = emp_no + """); + } + + public void testStatsMultiple() throws Exception { + runTests(""" + FROM test + | STATS s = SUM(does_not_exist1), c = COUNT(*) BY does_not_exist2, emp_no + """); + } + + public void testInlineStats() throws Exception { + runTests(""" + FROM test + | INLINE STATS s = SUM(does_not_exist1), c = COUNT(*) BY does_not_exist2, emp_no + """); + } + + public void testWhere() throws Exception { + runTests(""" + FROM test + | WHERE does_not_exist::LONG > 0 + """); + } + + public void testWhereOr() throws Exception { + runTests(""" + FROM test + | WHERE does_not_exist::LONG > 0 OR emp_no > 0 + """); + } + + public void testWhereComplex() throws Exception { + runTests(""" + FROM test + | WHERE does_not_exist1::LONG > 0 OR emp_no > 0 AND does_not_exist2::LONG < 100 + """); + } + + public void testStatsCountWhere() throws Exception { + runTests(""" + FROM test + | STATS c = COUNT(*) WHERE does_not_exist1::LONG > 0 + """); + } + + public void testStatsMultipleCountWhere() throws Exception { + runTests(""" + FROM test + | STATS c1 = COUNT(*) WHERE does_not_exist1::LONG > 0 OR emp_no > 0 OR does_not_exist2::LONG < 100, + c2 = COUNT(*) WHERE does_not_exist3 IS NULL + """); + } + + public void testSort() throws Exception { + runTests(""" + FROM test + | SORT does_not_exist ASC + """); + } + + public void testSortExpression() throws Exception { + runTests(""" + FROM test + | SORT does_not_exist::LONG + 1 + """); + } + + public void testSortMultiple() throws Exception { + runTests(""" + FROM test + | SORT does_not_exist1::LONG + 1, does_not_exist2 DESC, emp_no ASC + """); + } + + public void testMvExpand() throws Exception { + runTests(""" + FROM test + | MV_EXPAND does_not_exist + """); + } + + public void testRow() throws Exception { + runTests(""" + ROW x = 1 + | EVAL y = does_not_exist_field1::INTEGER + x + | KEEP *, does_not_exist_field2 + """); + } + + @Override + protected java.util.List filteredWarnings() { + return withDefaultLimitWarning(super.filteredWarnings()); + } + + private static String setUnmappedNullify(String query) { + return "SET unmapped_fields=\"nullify\"; " + query; + } + + private static String setUnmappedLoad(String query) { + return "SET unmapped_fields=\"load\"; " + query; + } + + private void runTests(String query) { + if (EsqlCapabilities.Cap.OPTIONAL_FIELDS_NULLIFY_TECH_PREVIEW.isEnabled()) { + builder(setUnmappedNullify(query)).nestedPath("nullify").stages(STAGES).run(); + } + if (EsqlCapabilities.Cap.OPTIONAL_FIELDS.isEnabled()) { + builder(setUnmappedLoad(query)).nestedPath("load").stages(STAGES).run(); + } + } +} diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/optimizer/GoldenTestCase.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/optimizer/GoldenTestCase.java index 8006d3a2c7cd3..6c343827b3cbb 100644 --- a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/optimizer/GoldenTestCase.java +++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/optimizer/GoldenTestCase.java @@ -391,8 +391,8 @@ private static String toCanonicalString(Node plan) { } private static String normalizeNameIds(String plan) { - var idMap = new IdMap(); - return normalizeHelper(plan, IDENTIFIER_PATTERN, s -> "#" + idMap.getId(Integer.parseInt(s))); + var idMap = new IdMap(); + return normalizeHelper(plan, IDENTIFIER_PATTERN, s -> "#" + idMap.getId(s)); } /** @@ -400,7 +400,7 @@ private static String normalizeNameIds(String plan) { * Replaces them with $$firstSegment$runningInt so golden output is stable across runs. */ private static String normalizeSyntheticNames(String plan) { - var idMap = new IdMap(); + var idMap = new IdMap(); return normalizeHelper(plan, SYNTHETIC_PATTERN, s -> "$$" + s + "$" + idMap.getId(s)); } @@ -421,11 +421,11 @@ private static String normalizeHelper(String s, Pattern p, Function { - private final Map map = new HashMap<>(); + private static class IdMap { + private final Map map = new HashMap<>(); private int counter = 0; - public int getId(K key) { + public int getId(String key) { return map.computeIfAbsent(key, k -> counter++); } } From e0b20db9793abcb86034aec98dfa263273a17a5a Mon Sep 17 00:00:00 2001 From: Gal Lalouche Date: Tue, 3 Feb 2026 17:25:28 +0200 Subject: [PATCH 14/25] Fix set issue --- .../analysis/AnalyzerUnmappedGoldenTests.java | 102 ++++++++---------- .../xpack/esql/optimizer/GoldenTestCase.java | 11 +- .../testDrop/load/analysis.expected | 3 + .../testDrop/nullify/analysis.expected | 4 + .../testDrop/query.esql | 2 + .../load/analysis.expected | 3 + .../nullify/analysis.expected | 4 + .../testDropAndMatchingStar/query.esql | 2 + .../testEval/load/analysis.expected | 3 + .../testEval/nullify/analysis.expected | 4 + .../testEval/query.esql | 2 + .../load/analysis.expected | 5 + .../nullify/analysis.expected | 6 ++ .../testEvalAfterKeepStar/query.esql | 4 + .../load/analysis.expected | 5 + .../nullify/analysis.expected | 6 ++ .../query.esql | 4 + .../testEvalAndKeep/load/analysis.expected | 4 + .../testEvalAndKeep/nullify/analysis.expected | 5 + .../testEvalAndKeep/query.esql | 3 + .../testEvalCast/load/analysis.expected | 3 + .../testEvalCast/nullify/analysis.expected | 4 + .../testEvalCast/query.esql | 2 + .../load/analysis.expected | 3 + .../nullify/analysis.expected | 4 + .../testEvalCastInPlace/query.esql | 2 + .../testEvalReplace/load/analysis.expected | 4 + .../testEvalReplace/nullify/analysis.expected | 5 + .../testEvalReplace/query.esql | 3 + .../testInlineStats/load/analysis.expected | 4 + .../testInlineStats/nullify/analysis.expected | 5 + .../testInlineStats/query.esql | 2 + .../testKeep/load/analysis.expected | 3 + .../testKeep/nullify/analysis.expected | 4 + .../testKeep/query.esql | 2 + .../load/analysis.expected | 3 + .../nullify/analysis.expected | 4 + .../testKeepAndMatchingStar/query.esql | 2 + .../testKeepRepeated/load/analysis.expected | 3 + .../nullify/analysis.expected | 4 + .../testKeepRepeated/query.esql | 2 + .../testKeepThenEval/load/analysis.expected | 4 + .../nullify/analysis.expected | 5 + .../testKeepThenEval/query.esql | 3 + .../testMultipleEval/load/analysis.expected | 5 + .../nullify/analysis.expected | 5 + .../testMultipleEval/query.esql | 4 + .../testMvExpand/load/analysis.expected | 3 + .../testMvExpand/nullify/analysis.expected | 4 + .../testMvExpand/query.esql | 2 + .../testRename/load/analysis.expected | 3 + .../testRename/nullify/analysis.expected | 4 + .../testRename/query.esql | 2 + .../testRenameEval/load/analysis.expected | 4 + .../testRenameEval/nullify/analysis.expected | 5 + .../testRenameEval/query.esql | 3 + .../testRenameRepeated/load/analysis.expected | 3 + .../nullify/analysis.expected | 4 + .../testRenameRepeated/query.esql | 2 + .../testSort/load/analysis.expected | 3 + .../testSort/nullify/analysis.expected | 4 + .../testSort/query.esql | 2 + .../testSortExpression/load/analysis.expected | 3 + .../nullify/analysis.expected | 4 + .../testSortExpression/query.esql | 2 + .../testSortMultiple/load/analysis.expected | 3 + .../nullify/analysis.expected | 4 + .../testSortMultiple/query.esql | 2 + .../testStatsBy/load/analysis.expected | 3 + .../testStatsBy/nullify/analysis.expected | 4 + .../testStatsBy/query.esql | 2 + .../testStatsCount/load/analysis.expected | 3 + .../testStatsCount/nullify/analysis.expected | 4 + .../testStatsCount/query.esql | 2 + .../load/analysis.expected | 3 + .../nullify/analysis.expected | 4 + .../testStatsCountWhere/query.esql | 2 + .../testStatsMultiple/load/analysis.expected | 3 + .../nullify/analysis.expected | 4 + .../testStatsMultiple/query.esql | 2 + .../load/analysis.expected | 4 + .../nullify/analysis.expected | 5 + .../testStatsMultipleCountWhere/query.esql | 3 + .../testStatsSumBy/load/analysis.expected | 3 + .../testStatsSumBy/nullify/analysis.expected | 4 + .../testStatsSumBy/query.esql | 2 + .../load/analysis.expected | 3 + .../nullify/analysis.expected | 4 + .../testStatsSumByComplex/query.esql | 2 + .../load/analysis.expected | 3 + .../nullify/analysis.expected | 4 + .../testStatsSumByMultiple/query.esql | 2 + .../testWhere/load/analysis.expected | 3 + .../testWhere/nullify/analysis.expected | 4 + .../testWhere/query.esql | 2 + .../testWhereComplex/load/analysis.expected | 3 + .../nullify/analysis.expected | 4 + .../testWhereComplex/query.esql | 2 + .../testWhereOr/load/analysis.expected | 3 + .../testWhereOr/nullify/analysis.expected | 4 + .../testWhereOr/query.esql | 2 + 101 files changed, 385 insertions(+), 59 deletions(-) create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testDrop/load/analysis.expected create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testDrop/nullify/analysis.expected create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testDrop/query.esql create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testDropAndMatchingStar/load/analysis.expected create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testDropAndMatchingStar/nullify/analysis.expected create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testDropAndMatchingStar/query.esql create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testEval/load/analysis.expected create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testEval/nullify/analysis.expected create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testEval/query.esql create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testEvalAfterKeepStar/load/analysis.expected create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testEvalAfterKeepStar/nullify/analysis.expected create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testEvalAfterKeepStar/query.esql create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testEvalAfterMatchingKeepWithWildcard/load/analysis.expected create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testEvalAfterMatchingKeepWithWildcard/nullify/analysis.expected create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testEvalAfterMatchingKeepWithWildcard/query.esql create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testEvalAndKeep/load/analysis.expected create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testEvalAndKeep/nullify/analysis.expected create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testEvalAndKeep/query.esql create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testEvalCast/load/analysis.expected create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testEvalCast/nullify/analysis.expected create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testEvalCast/query.esql create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testEvalCastInPlace/load/analysis.expected create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testEvalCastInPlace/nullify/analysis.expected create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testEvalCastInPlace/query.esql create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testEvalReplace/load/analysis.expected create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testEvalReplace/nullify/analysis.expected create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testEvalReplace/query.esql create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testInlineStats/load/analysis.expected create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testInlineStats/nullify/analysis.expected create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testInlineStats/query.esql create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testKeep/load/analysis.expected create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testKeep/nullify/analysis.expected create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testKeep/query.esql create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testKeepAndMatchingStar/load/analysis.expected create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testKeepAndMatchingStar/nullify/analysis.expected create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testKeepAndMatchingStar/query.esql create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testKeepRepeated/load/analysis.expected create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testKeepRepeated/nullify/analysis.expected create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testKeepRepeated/query.esql create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testKeepThenEval/load/analysis.expected create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testKeepThenEval/nullify/analysis.expected create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testKeepThenEval/query.esql create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testMultipleEval/load/analysis.expected create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testMultipleEval/nullify/analysis.expected create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testMultipleEval/query.esql create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testMvExpand/load/analysis.expected create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testMvExpand/nullify/analysis.expected create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testMvExpand/query.esql create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testRename/load/analysis.expected create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testRename/nullify/analysis.expected create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testRename/query.esql create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testRenameEval/load/analysis.expected create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testRenameEval/nullify/analysis.expected create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testRenameEval/query.esql create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testRenameRepeated/load/analysis.expected create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testRenameRepeated/nullify/analysis.expected create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testRenameRepeated/query.esql create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testSort/load/analysis.expected create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testSort/nullify/analysis.expected create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testSort/query.esql create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testSortExpression/load/analysis.expected create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testSortExpression/nullify/analysis.expected create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testSortExpression/query.esql create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testSortMultiple/load/analysis.expected create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testSortMultiple/nullify/analysis.expected create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testSortMultiple/query.esql create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testStatsBy/load/analysis.expected create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testStatsBy/nullify/analysis.expected create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testStatsBy/query.esql create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testStatsCount/load/analysis.expected create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testStatsCount/nullify/analysis.expected create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testStatsCount/query.esql create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testStatsCountWhere/load/analysis.expected create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testStatsCountWhere/nullify/analysis.expected create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testStatsCountWhere/query.esql create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testStatsMultiple/load/analysis.expected create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testStatsMultiple/nullify/analysis.expected create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testStatsMultiple/query.esql create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testStatsMultipleCountWhere/load/analysis.expected create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testStatsMultipleCountWhere/nullify/analysis.expected create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testStatsMultipleCountWhere/query.esql create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testStatsSumBy/load/analysis.expected create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testStatsSumBy/nullify/analysis.expected create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testStatsSumBy/query.esql create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testStatsSumByComplex/load/analysis.expected create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testStatsSumByComplex/nullify/analysis.expected create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testStatsSumByComplex/query.esql create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testStatsSumByMultiple/load/analysis.expected create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testStatsSumByMultiple/nullify/analysis.expected create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testStatsSumByMultiple/query.esql create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testWhere/load/analysis.expected create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testWhere/nullify/analysis.expected create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testWhere/query.esql create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testWhereComplex/load/analysis.expected create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testWhereComplex/nullify/analysis.expected create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testWhereComplex/query.esql create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testWhereOr/load/analysis.expected create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testWhereOr/nullify/analysis.expected create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testWhereOr/query.esql diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/analysis/AnalyzerUnmappedGoldenTests.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/analysis/AnalyzerUnmappedGoldenTests.java index 9db97289ae7ae..e1de3ba5bf151 100644 --- a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/analysis/AnalyzerUnmappedGoldenTests.java +++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/analysis/AnalyzerUnmappedGoldenTests.java @@ -15,36 +15,36 @@ import static org.elasticsearch.xpack.esql.EsqlTestUtils.withDefaultLimitWarning; /** - * Golden tests for analyzer behavior with unmapped fields using SET unmapped_fields="nullify". - * These tests verify that unmapped fields are properly handled by converting them to null literals. + * Golden tests for analyzer behavior with unmapped fields using SET unmapped_fields="nullify" and "load". + * These tests verify that unmapped fields are properly handled. */ public class AnalyzerUnmappedGoldenTests extends GoldenTestCase { private static final EnumSet STAGES = EnumSet.of(Stage.ANALYSIS); public void testKeep() throws Exception { runTests(""" - FROM test + FROM employees | KEEP does_not_exist_field """); } public void testKeepRepeated() throws Exception { runTests(""" - FROM test + FROM employees | KEEP does_not_exist_field, does_not_exist_field """); } public void testKeepAndMatchingStar() throws Exception { runTests(""" - FROM test + FROM employees | KEEP emp_*, does_not_exist_field """); } public void testEvalAndKeep() throws Exception { runTests(""" - FROM test + FROM employees | EVAL x = does_not_exist_field1::INTEGER + 42 | KEEP does_not_exist_field1, does_not_exist_field2 """); @@ -52,99 +52,99 @@ public void testEvalAndKeep() throws Exception { public void testEvalAfterKeepStar() throws Exception { runTests(""" - FROM test + FROM employees | KEEP * | EVAL x = emp_no + 1 - | EVAL y = does_not_exist_field + 2 + | EVAL y = does_not_exist_field::DOUBLE + 2 """); } public void testEvalAfterMatchingKeepWithWildcard() throws Exception { runTests(""" - FROM test + FROM employees | KEEP emp_no, * | EVAL x = emp_no + 1 - | EVAL y = emp_does_not_exist_field + 2 + | EVAL y = emp_does_not_exist_field::DOUBLE + 2 """); } public void testDrop() throws Exception { runTests(""" - FROM test + FROM employees | DROP does_not_exist_field, emp_no """); } public void testDropAndMatchingStar() throws Exception { runTests(""" - FROM test + FROM employees | DROP emp_*, does_not_exist_field """); } public void testRename() throws Exception { runTests(""" - FROM test + FROM employees | RENAME does_not_exist_field AS now_it_does, emp_no AS employee_number """); } public void testRenameRepeated() throws Exception { runTests(""" - FROM test + FROM employees | RENAME does_not_exist_field AS now_it_does, neither_does_this AS now_it_does, emp_no AS employee_number """); } public void testRenameEval() throws Exception { runTests(""" - FROM test + FROM employees | RENAME emp_no AS employee_number - | EVAL x = does_not_exist + 1 + | EVAL x = does_not_exist::DOUBLE + 1 """); } public void testEval() throws Exception { runTests(""" - FROM test - | EVAL x = does_not_exist_field + 1 + FROM employees + | EVAL x = does_not_exist_field::DOUBLE + 1 """); } public void testMultipleEval() throws Exception { runTests(""" - FROM test + FROM employees | EVAL a = 1 - | EVAL x = a + b - | EVAL y = b + c + | EVAL x = a + b::DOUBLE + | EVAL y = b::DOUBLE + c::DOUBLE """); } public void testEvalCast() throws Exception { runTests(""" - FROM test + FROM employees | EVAL x = does_not_exist_field::LONG """); } public void testEvalCastInPlace() throws Exception { runTests(""" - FROM test + FROM employees | EVAL does_not_exist_field::LONG """); } public void testEvalReplace() throws Exception { runTests(""" - FROM test - | EVAL x = does_not_exist_field + 1 + FROM employees + | EVAL x = does_not_exist_field::DOUBLE + 1 | EVAL does_not_exist_field = 42 """); } public void testKeepThenEval() throws Exception { runTests(""" - FROM test + FROM employees | KEEP does_not_exist_field | EVAL does_not_exist_field = 42 """); @@ -152,84 +152,84 @@ public void testKeepThenEval() throws Exception { public void testStatsCount() throws Exception { runTests(""" - FROM test + FROM employees | STATS cnt = COUNT(does_not_exist_field) """); } public void testStatsBy() throws Exception { runTests(""" - FROM test + FROM employees | STATS BY does_not_exist_field """); } public void testStatsSumBy() throws Exception { runTests(""" - FROM test - | STATS s = SUM(does_not_exist1) BY does_not_exist2 + FROM employees + | STATS s = SUM(does_not_exist1::DOUBLE) BY does_not_exist2 """); } public void testStatsSumByMultiple() throws Exception { runTests(""" - FROM test - | STATS s = SUM(does_not_exist1) + d2 BY d2 = does_not_exist2, emp_no + FROM employees + | STATS s = SUM(does_not_exist1::DOUBLE) + d2 BY d2 = does_not_exist2::DOUBLE, emp_no """); } public void testStatsSumByComplex() throws Exception { runTests(""" - FROM test - | STATS sum = SUM(does_not_exist1) + s0 + s1 BY s0 = does_not_exist2 + does_not_exist3, s1 = emp_no + FROM employees + | STATS sum = SUM(does_not_exist1::DOUBLE) + s0 + s1 BY s0 = does_not_exist2::DOUBLE + does_not_exist3::DOUBLE, s1 = emp_no """); } public void testStatsMultiple() throws Exception { runTests(""" - FROM test - | STATS s = SUM(does_not_exist1), c = COUNT(*) BY does_not_exist2, emp_no + FROM employees + | STATS s = SUM(does_not_exist1::DOUBLE), c = COUNT(*) BY does_not_exist2, emp_no """); } public void testInlineStats() throws Exception { runTests(""" - FROM test - | INLINE STATS s = SUM(does_not_exist1), c = COUNT(*) BY does_not_exist2, emp_no + FROM employees + | INLINE STATS s = SUM(does_not_exist1::DOUBLE), c = COUNT(*) BY does_not_exist2, emp_no """); } public void testWhere() throws Exception { runTests(""" - FROM test + FROM employees | WHERE does_not_exist::LONG > 0 """); } public void testWhereOr() throws Exception { runTests(""" - FROM test + FROM employees | WHERE does_not_exist::LONG > 0 OR emp_no > 0 """); } public void testWhereComplex() throws Exception { runTests(""" - FROM test + FROM employees | WHERE does_not_exist1::LONG > 0 OR emp_no > 0 AND does_not_exist2::LONG < 100 """); } public void testStatsCountWhere() throws Exception { runTests(""" - FROM test + FROM employees | STATS c = COUNT(*) WHERE does_not_exist1::LONG > 0 """); } public void testStatsMultipleCountWhere() throws Exception { runTests(""" - FROM test + FROM employees | STATS c1 = COUNT(*) WHERE does_not_exist1::LONG > 0 OR emp_no > 0 OR does_not_exist2::LONG < 100, c2 = COUNT(*) WHERE does_not_exist3 IS NULL """); @@ -237,40 +237,32 @@ public void testStatsMultipleCountWhere() throws Exception { public void testSort() throws Exception { runTests(""" - FROM test + FROM employees | SORT does_not_exist ASC """); } public void testSortExpression() throws Exception { runTests(""" - FROM test + FROM employees | SORT does_not_exist::LONG + 1 """); } public void testSortMultiple() throws Exception { runTests(""" - FROM test + FROM employees | SORT does_not_exist1::LONG + 1, does_not_exist2 DESC, emp_no ASC """); } public void testMvExpand() throws Exception { runTests(""" - FROM test + FROM employees | MV_EXPAND does_not_exist """); } - public void testRow() throws Exception { - runTests(""" - ROW x = 1 - | EVAL y = does_not_exist_field1::INTEGER + x - | KEEP *, does_not_exist_field2 - """); - } - @Override protected java.util.List filteredWarnings() { return withDefaultLimitWarning(super.filteredWarnings()); diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/optimizer/GoldenTestCase.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/optimizer/GoldenTestCase.java index 6c343827b3cbb..5a3390f4d530c 100644 --- a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/optimizer/GoldenTestCase.java +++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/optimizer/GoldenTestCase.java @@ -68,6 +68,7 @@ import static org.elasticsearch.xpack.esql.EsqlTestUtils.TEST_VERIFIER; import static org.elasticsearch.xpack.esql.EsqlTestUtils.randomMinimumVersion; import static org.elasticsearch.xpack.esql.EsqlTestUtils.withDefaultLimitWarning; +import static org.elasticsearch.xpack.esql.plan.QuerySettings.UNMAPPED_FIELDS; import static org.elasticsearch.xpack.esql.analysis.AnalyzerTestUtils.defaultLookupResolution; /** See GoldenTestsReadme.md for more information about these tests. */ @@ -200,24 +201,25 @@ private void doTest() { } private List> doTests() throws IOException { - LogicalPlan parsedStatement = EsqlParser.INSTANCE.parseQuery(esqlQuery); + var statement = EsqlParser.INSTANCE.createStatement(esqlQuery); + var parsedPlan = statement.plan(); Files.createDirectories(PathUtils.get(basePath.toString(), testName)); Files.writeString(PathUtils.get(basePath.toString(), testName, "query.esql"), esqlQuery); var analyzer = new Analyzer( new AnalyzerContext( EsqlTestUtils.TEST_CFG, new EsqlFunctionRegistry(), - CsvTests.loadIndexResolution(CsvTests.testDatasets(parsedStatement)), + CsvTests.loadIndexResolution(CsvTests.testDatasets(parsedPlan)), defaultLookupResolution(), new EnrichResolution(), InferenceResolution.EMPTY, transportVersion, - UnmappedResolution.FAIL + statement.setting(UNMAPPED_FIELDS) ), TEST_VERIFIER ); List> result = new ArrayList<>(); - var analyzed = analyzer.analyze(parsedStatement); + var analyzed = analyzer.analyze(parsedPlan); if (stages.contains(Stage.ANALYSIS)) { result.add(Tuple.tuple(Stage.ANALYSIS, verifyOrWrite(analyzed, Stage.ANALYSIS))); } @@ -381,6 +383,7 @@ private static Test.TestResult createNewOutput(Path output, QueryPlan plan) t if (output.toString().contains("extra")) { throw new IllegalStateException("Extra output files should not be created automatically:" + output); } + Files.createDirectories(output.getParent()); Files.writeString(output, toCanonicalString(plan), StandardCharsets.UTF_8); return Test.TestResult.CREATED; } diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testDrop/load/analysis.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testDrop/load/analysis.expected new file mode 100644 index 0000000000000..f5ab73414c471 --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testDrop/load/analysis.expected @@ -0,0 +1,3 @@ +Limit[1000[INTEGER],false,false] +\_Project[[avg_worked_seconds{f}#0, birth_date{f}#1, first_name{f}#2, gender{f}#3, height{f}#4, height.float{f}#5, height.half_float{f}#6, height.scaled_float{f}#7, hire_date{f}#8, is_rehired{f}#9, job_positions{f}#10, languages{f}#11, languages.byte{f}#12, languages.long{f}#13, languages.short{f}#14, last_name{f}#15, salary{f}#16, salary_change{f}#17, salary_change.int{f}#18, salary_change.keyword{f}#19, salary_change.long{f}#20, still_hired{f}#21]] + \_EsRelation[employees][avg_worked_seconds{f}#0, birth_date{f}#1, emp_no{f}#22, first_name{f}#2, gender{f}#3, height{f}#4, height.float{f}#5, height.half_float{f}#6, height.scaled_float{f}#7, hire_date{f}#8, is_rehired{f}#9, job_positions{f}#10, languages{f}#11, languages.byte{f}#12, languages.long{f}#13, languages.short{f}#14, last_name{f}#15, salary{f}#16, salary_change{f}#17, salary_change.int{f}#18, salary_change.keyword{f}#19, salary_change.long{f}#20, still_hired{f}#21, does_not_exist_field{f}#23] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testDrop/nullify/analysis.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testDrop/nullify/analysis.expected new file mode 100644 index 0000000000000..09d5818b5d458 --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testDrop/nullify/analysis.expected @@ -0,0 +1,4 @@ +Limit[1000[INTEGER],false,false] +\_Project[[avg_worked_seconds{f}#0, birth_date{f}#1, first_name{f}#2, gender{f}#3, height{f}#4, height.float{f}#5, height.half_float{f}#6, height.scaled_float{f}#7, hire_date{f}#8, is_rehired{f}#9, job_positions{f}#10, languages{f}#11, languages.byte{f}#12, languages.long{f}#13, languages.short{f}#14, last_name{f}#15, salary{f}#16, salary_change{f}#17, salary_change.int{f}#18, salary_change.keyword{f}#19, salary_change.long{f}#20, still_hired{f}#21]] + \_Eval[[null[NULL] AS does_not_exist_field#22]] + \_EsRelation[employees][avg_worked_seconds{f}#0, birth_date{f}#1, emp_no{f}#23, first_name{f}#2, gender{f}#3, height{f}#4, height.float{f}#5, height.half_float{f}#6, height.scaled_float{f}#7, hire_date{f}#8, is_rehired{f}#9, job_positions{f}#10, languages{f}#11, languages.byte{f}#12, languages.long{f}#13, languages.short{f}#14, last_name{f}#15, salary{f}#16, salary_change{f}#17, salary_change.int{f}#18, salary_change.keyword{f}#19, salary_change.long{f}#20, still_hired{f}#21] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testDrop/query.esql b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testDrop/query.esql new file mode 100644 index 0000000000000..4651e798553a5 --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testDrop/query.esql @@ -0,0 +1,2 @@ +SET unmapped_fields="load"; FROM employees +| DROP does_not_exist_field, emp_no diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testDropAndMatchingStar/load/analysis.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testDropAndMatchingStar/load/analysis.expected new file mode 100644 index 0000000000000..f5ab73414c471 --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testDropAndMatchingStar/load/analysis.expected @@ -0,0 +1,3 @@ +Limit[1000[INTEGER],false,false] +\_Project[[avg_worked_seconds{f}#0, birth_date{f}#1, first_name{f}#2, gender{f}#3, height{f}#4, height.float{f}#5, height.half_float{f}#6, height.scaled_float{f}#7, hire_date{f}#8, is_rehired{f}#9, job_positions{f}#10, languages{f}#11, languages.byte{f}#12, languages.long{f}#13, languages.short{f}#14, last_name{f}#15, salary{f}#16, salary_change{f}#17, salary_change.int{f}#18, salary_change.keyword{f}#19, salary_change.long{f}#20, still_hired{f}#21]] + \_EsRelation[employees][avg_worked_seconds{f}#0, birth_date{f}#1, emp_no{f}#22, first_name{f}#2, gender{f}#3, height{f}#4, height.float{f}#5, height.half_float{f}#6, height.scaled_float{f}#7, hire_date{f}#8, is_rehired{f}#9, job_positions{f}#10, languages{f}#11, languages.byte{f}#12, languages.long{f}#13, languages.short{f}#14, last_name{f}#15, salary{f}#16, salary_change{f}#17, salary_change.int{f}#18, salary_change.keyword{f}#19, salary_change.long{f}#20, still_hired{f}#21, does_not_exist_field{f}#23] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testDropAndMatchingStar/nullify/analysis.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testDropAndMatchingStar/nullify/analysis.expected new file mode 100644 index 0000000000000..09d5818b5d458 --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testDropAndMatchingStar/nullify/analysis.expected @@ -0,0 +1,4 @@ +Limit[1000[INTEGER],false,false] +\_Project[[avg_worked_seconds{f}#0, birth_date{f}#1, first_name{f}#2, gender{f}#3, height{f}#4, height.float{f}#5, height.half_float{f}#6, height.scaled_float{f}#7, hire_date{f}#8, is_rehired{f}#9, job_positions{f}#10, languages{f}#11, languages.byte{f}#12, languages.long{f}#13, languages.short{f}#14, last_name{f}#15, salary{f}#16, salary_change{f}#17, salary_change.int{f}#18, salary_change.keyword{f}#19, salary_change.long{f}#20, still_hired{f}#21]] + \_Eval[[null[NULL] AS does_not_exist_field#22]] + \_EsRelation[employees][avg_worked_seconds{f}#0, birth_date{f}#1, emp_no{f}#23, first_name{f}#2, gender{f}#3, height{f}#4, height.float{f}#5, height.half_float{f}#6, height.scaled_float{f}#7, hire_date{f}#8, is_rehired{f}#9, job_positions{f}#10, languages{f}#11, languages.byte{f}#12, languages.long{f}#13, languages.short{f}#14, last_name{f}#15, salary{f}#16, salary_change{f}#17, salary_change.int{f}#18, salary_change.keyword{f}#19, salary_change.long{f}#20, still_hired{f}#21] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testDropAndMatchingStar/query.esql b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testDropAndMatchingStar/query.esql new file mode 100644 index 0000000000000..0b9aa5a1c9b86 --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testDropAndMatchingStar/query.esql @@ -0,0 +1,2 @@ +SET unmapped_fields="load"; FROM employees +| DROP emp_*, does_not_exist_field diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testEval/load/analysis.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testEval/load/analysis.expected new file mode 100644 index 0000000000000..26eeae08a3eb3 --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testEval/load/analysis.expected @@ -0,0 +1,3 @@ +Limit[1000[INTEGER],false,false] +\_Eval[[TODOUBLE(does_not_exist_field{f}#0) + 1[INTEGER] AS x#1]] + \_EsRelation[employees][avg_worked_seconds{f}#2, birth_date{f}#3, emp_no{f}#4, first_name{f}#5, gender{f}#6, height{f}#7, height.float{f}#8, height.half_float{f}#9, height.scaled_float{f}#10, hire_date{f}#11, is_rehired{f}#12, job_positions{f}#13, languages{f}#14, languages.byte{f}#15, languages.long{f}#16, languages.short{f}#17, last_name{f}#18, salary{f}#19, salary_change{f}#20, salary_change.int{f}#21, salary_change.keyword{f}#22, salary_change.long{f}#23, still_hired{f}#24, does_not_exist_field{f}#0] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testEval/nullify/analysis.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testEval/nullify/analysis.expected new file mode 100644 index 0000000000000..58562d7c829d1 --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testEval/nullify/analysis.expected @@ -0,0 +1,4 @@ +Limit[1000[INTEGER],false,false] +\_Eval[[TODOUBLE(does_not_exist_field{r}#0) + 1[INTEGER] AS x#1]] + \_Eval[[null[NULL] AS does_not_exist_field#0]] + \_EsRelation[employees][avg_worked_seconds{f}#2, birth_date{f}#3, emp_no{f}#4, first_name{f}#5, gender{f}#6, height{f}#7, height.float{f}#8, height.half_float{f}#9, height.scaled_float{f}#10, hire_date{f}#11, is_rehired{f}#12, job_positions{f}#13, languages{f}#14, languages.byte{f}#15, languages.long{f}#16, languages.short{f}#17, last_name{f}#18, salary{f}#19, salary_change{f}#20, salary_change.int{f}#21, salary_change.keyword{f}#22, salary_change.long{f}#23, still_hired{f}#24] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testEval/query.esql b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testEval/query.esql new file mode 100644 index 0000000000000..f4ebacdf1a902 --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testEval/query.esql @@ -0,0 +1,2 @@ +SET unmapped_fields="load"; FROM employees +| EVAL x = does_not_exist_field::DOUBLE + 1 diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testEvalAfterKeepStar/load/analysis.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testEvalAfterKeepStar/load/analysis.expected new file mode 100644 index 0000000000000..fffeff38bda8f --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testEvalAfterKeepStar/load/analysis.expected @@ -0,0 +1,5 @@ +Limit[1000[INTEGER],false,false] +\_Eval[[TODOUBLE(does_not_exist_field{f}#0) + 2[INTEGER] AS y#1]] + \_Eval[[emp_no{f}#2 + 1[INTEGER] AS x#3]] + \_Project[[avg_worked_seconds{f}#4, birth_date{f}#5, emp_no{f}#2, first_name{f}#6, gender{f}#7, height{f}#8, height.float{f}#9, height.half_float{f}#10, height.scaled_float{f}#11, hire_date{f}#12, is_rehired{f}#13, job_positions{f}#14, languages{f}#15, languages.byte{f}#16, languages.long{f}#17, languages.short{f}#18, last_name{f}#19, salary{f}#20, salary_change{f}#21, salary_change.int{f}#22, salary_change.keyword{f}#23, salary_change.long{f}#24, still_hired{f}#25, does_not_exist_field{f}#0]] + \_EsRelation[employees][avg_worked_seconds{f}#4, birth_date{f}#5, emp_no{f}#2, first_name{f}#6, gender{f}#7, height{f}#8, height.float{f}#9, height.half_float{f}#10, height.scaled_float{f}#11, hire_date{f}#12, is_rehired{f}#13, job_positions{f}#14, languages{f}#15, languages.byte{f}#16, languages.long{f}#17, languages.short{f}#18, last_name{f}#19, salary{f}#20, salary_change{f}#21, salary_change.int{f}#22, salary_change.keyword{f}#23, salary_change.long{f}#24, still_hired{f}#25, does_not_exist_field{f}#0] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testEvalAfterKeepStar/nullify/analysis.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testEvalAfterKeepStar/nullify/analysis.expected new file mode 100644 index 0000000000000..8a7ed2a845200 --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testEvalAfterKeepStar/nullify/analysis.expected @@ -0,0 +1,6 @@ +Limit[1000[INTEGER],false,false] +\_Eval[[TODOUBLE(does_not_exist_field{r}#0) + 2[INTEGER] AS y#1]] + \_Eval[[emp_no{f}#2 + 1[INTEGER] AS x#3]] + \_Project[[avg_worked_seconds{f}#4, birth_date{f}#5, emp_no{f}#2, first_name{f}#6, gender{f}#7, height{f}#8, height.float{f}#9, height.half_float{f}#10, height.scaled_float{f}#11, hire_date{f}#12, is_rehired{f}#13, job_positions{f}#14, languages{f}#15, languages.byte{f}#16, languages.long{f}#17, languages.short{f}#18, last_name{f}#19, salary{f}#20, salary_change{f}#21, salary_change.int{f}#22, salary_change.keyword{f}#23, salary_change.long{f}#24, still_hired{f}#25, does_not_exist_field{r}#0]] + \_Eval[[null[NULL] AS does_not_exist_field#0]] + \_EsRelation[employees][avg_worked_seconds{f}#4, birth_date{f}#5, emp_no{f}#2, first_name{f}#6, gender{f}#7, height{f}#8, height.float{f}#9, height.half_float{f}#10, height.scaled_float{f}#11, hire_date{f}#12, is_rehired{f}#13, job_positions{f}#14, languages{f}#15, languages.byte{f}#16, languages.long{f}#17, languages.short{f}#18, last_name{f}#19, salary{f}#20, salary_change{f}#21, salary_change.int{f}#22, salary_change.keyword{f}#23, salary_change.long{f}#24, still_hired{f}#25] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testEvalAfterKeepStar/query.esql b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testEvalAfterKeepStar/query.esql new file mode 100644 index 0000000000000..dcd26bdd54bf4 --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testEvalAfterKeepStar/query.esql @@ -0,0 +1,4 @@ +SET unmapped_fields="load"; FROM employees +| KEEP * +| EVAL x = emp_no + 1 +| EVAL y = does_not_exist_field::DOUBLE + 2 diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testEvalAfterMatchingKeepWithWildcard/load/analysis.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testEvalAfterMatchingKeepWithWildcard/load/analysis.expected new file mode 100644 index 0000000000000..985d0ddb1a1f7 --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testEvalAfterMatchingKeepWithWildcard/load/analysis.expected @@ -0,0 +1,5 @@ +Limit[1000[INTEGER],false,false] +\_Eval[[TODOUBLE(emp_does_not_exist_field{f}#0) + 2[INTEGER] AS y#1]] + \_Eval[[emp_no{f}#2 + 1[INTEGER] AS x#3]] + \_Project[[emp_no{f}#2, avg_worked_seconds{f}#4, birth_date{f}#5, first_name{f}#6, gender{f}#7, height{f}#8, height.float{f}#9, height.half_float{f}#10, height.scaled_float{f}#11, hire_date{f}#12, is_rehired{f}#13, job_positions{f}#14, languages{f}#15, languages.byte{f}#16, languages.long{f}#17, languages.short{f}#18, last_name{f}#19, salary{f}#20, salary_change{f}#21, salary_change.int{f}#22, salary_change.keyword{f}#23, salary_change.long{f}#24, still_hired{f}#25, emp_does_not_exist_field{f}#0]] + \_EsRelation[employees][avg_worked_seconds{f}#4, birth_date{f}#5, emp_no{f}#2, first_name{f}#6, gender{f}#7, height{f}#8, height.float{f}#9, height.half_float{f}#10, height.scaled_float{f}#11, hire_date{f}#12, is_rehired{f}#13, job_positions{f}#14, languages{f}#15, languages.byte{f}#16, languages.long{f}#17, languages.short{f}#18, last_name{f}#19, salary{f}#20, salary_change{f}#21, salary_change.int{f}#22, salary_change.keyword{f}#23, salary_change.long{f}#24, still_hired{f}#25, emp_does_not_exist_field{f}#0] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testEvalAfterMatchingKeepWithWildcard/nullify/analysis.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testEvalAfterMatchingKeepWithWildcard/nullify/analysis.expected new file mode 100644 index 0000000000000..c85c64472a028 --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testEvalAfterMatchingKeepWithWildcard/nullify/analysis.expected @@ -0,0 +1,6 @@ +Limit[1000[INTEGER],false,false] +\_Eval[[TODOUBLE(emp_does_not_exist_field{r}#0) + 2[INTEGER] AS y#1]] + \_Eval[[emp_no{f}#2 + 1[INTEGER] AS x#3]] + \_Project[[emp_no{f}#2, avg_worked_seconds{f}#4, birth_date{f}#5, first_name{f}#6, gender{f}#7, height{f}#8, height.float{f}#9, height.half_float{f}#10, height.scaled_float{f}#11, hire_date{f}#12, is_rehired{f}#13, job_positions{f}#14, languages{f}#15, languages.byte{f}#16, languages.long{f}#17, languages.short{f}#18, last_name{f}#19, salary{f}#20, salary_change{f}#21, salary_change.int{f}#22, salary_change.keyword{f}#23, salary_change.long{f}#24, still_hired{f}#25, emp_does_not_exist_field{r}#0]] + \_Eval[[null[NULL] AS emp_does_not_exist_field#0]] + \_EsRelation[employees][avg_worked_seconds{f}#4, birth_date{f}#5, emp_no{f}#2, first_name{f}#6, gender{f}#7, height{f}#8, height.float{f}#9, height.half_float{f}#10, height.scaled_float{f}#11, hire_date{f}#12, is_rehired{f}#13, job_positions{f}#14, languages{f}#15, languages.byte{f}#16, languages.long{f}#17, languages.short{f}#18, last_name{f}#19, salary{f}#20, salary_change{f}#21, salary_change.int{f}#22, salary_change.keyword{f}#23, salary_change.long{f}#24, still_hired{f}#25] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testEvalAfterMatchingKeepWithWildcard/query.esql b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testEvalAfterMatchingKeepWithWildcard/query.esql new file mode 100644 index 0000000000000..598a0d6552097 --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testEvalAfterMatchingKeepWithWildcard/query.esql @@ -0,0 +1,4 @@ +SET unmapped_fields="load"; FROM employees +| KEEP emp_no, * +| EVAL x = emp_no + 1 +| EVAL y = emp_does_not_exist_field::DOUBLE + 2 diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testEvalAndKeep/load/analysis.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testEvalAndKeep/load/analysis.expected new file mode 100644 index 0000000000000..5577ec2723da6 --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testEvalAndKeep/load/analysis.expected @@ -0,0 +1,4 @@ +Limit[1000[INTEGER],false,false] +\_Project[[does_not_exist_field1{f}#0, does_not_exist_field2{f}#1]] + \_Eval[[TOINTEGER(does_not_exist_field1{f}#0) + 42[INTEGER] AS x#2]] + \_EsRelation[employees][avg_worked_seconds{f}#3, birth_date{f}#4, emp_no{f}#5, first_name{f}#6, gender{f}#7, height{f}#8, height.float{f}#9, height.half_float{f}#10, height.scaled_float{f}#11, hire_date{f}#12, is_rehired{f}#13, job_positions{f}#14, languages{f}#15, languages.byte{f}#16, languages.long{f}#17, languages.short{f}#18, last_name{f}#19, salary{f}#20, salary_change{f}#21, salary_change.int{f}#22, salary_change.keyword{f}#23, salary_change.long{f}#24, still_hired{f}#25, does_not_exist_field1{f}#0, does_not_exist_field2{f}#1] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testEvalAndKeep/nullify/analysis.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testEvalAndKeep/nullify/analysis.expected new file mode 100644 index 0000000000000..93470d82bb0f9 --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testEvalAndKeep/nullify/analysis.expected @@ -0,0 +1,5 @@ +Limit[1000[INTEGER],false,false] +\_Project[[does_not_exist_field1{r}#0, does_not_exist_field2{r}#1]] + \_Eval[[TOINTEGER(does_not_exist_field1{r}#0) + 42[INTEGER] AS x#2]] + \_Eval[[null[NULL] AS does_not_exist_field1#0, null[NULL] AS does_not_exist_field2#1]] + \_EsRelation[employees][avg_worked_seconds{f}#3, birth_date{f}#4, emp_no{f}#5, first_name{f}#6, gender{f}#7, height{f}#8, height.float{f}#9, height.half_float{f}#10, height.scaled_float{f}#11, hire_date{f}#12, is_rehired{f}#13, job_positions{f}#14, languages{f}#15, languages.byte{f}#16, languages.long{f}#17, languages.short{f}#18, last_name{f}#19, salary{f}#20, salary_change{f}#21, salary_change.int{f}#22, salary_change.keyword{f}#23, salary_change.long{f}#24, still_hired{f}#25] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testEvalAndKeep/query.esql b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testEvalAndKeep/query.esql new file mode 100644 index 0000000000000..2a2c4f3dea742 --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testEvalAndKeep/query.esql @@ -0,0 +1,3 @@ +SET unmapped_fields="load"; FROM employees +| EVAL x = does_not_exist_field1::INTEGER + 42 +| KEEP does_not_exist_field1, does_not_exist_field2 diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testEvalCast/load/analysis.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testEvalCast/load/analysis.expected new file mode 100644 index 0000000000000..11402fc799020 --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testEvalCast/load/analysis.expected @@ -0,0 +1,3 @@ +Limit[1000[INTEGER],false,false] +\_Eval[[TOLONG(does_not_exist_field{f}#0) AS x#1]] + \_EsRelation[employees][avg_worked_seconds{f}#2, birth_date{f}#3, emp_no{f}#4, first_name{f}#5, gender{f}#6, height{f}#7, height.float{f}#8, height.half_float{f}#9, height.scaled_float{f}#10, hire_date{f}#11, is_rehired{f}#12, job_positions{f}#13, languages{f}#14, languages.byte{f}#15, languages.long{f}#16, languages.short{f}#17, last_name{f}#18, salary{f}#19, salary_change{f}#20, salary_change.int{f}#21, salary_change.keyword{f}#22, salary_change.long{f}#23, still_hired{f}#24, does_not_exist_field{f}#0] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testEvalCast/nullify/analysis.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testEvalCast/nullify/analysis.expected new file mode 100644 index 0000000000000..94776e53044a1 --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testEvalCast/nullify/analysis.expected @@ -0,0 +1,4 @@ +Limit[1000[INTEGER],false,false] +\_Eval[[TOLONG(does_not_exist_field{r}#0) AS x#1]] + \_Eval[[null[NULL] AS does_not_exist_field#0]] + \_EsRelation[employees][avg_worked_seconds{f}#2, birth_date{f}#3, emp_no{f}#4, first_name{f}#5, gender{f}#6, height{f}#7, height.float{f}#8, height.half_float{f}#9, height.scaled_float{f}#10, hire_date{f}#11, is_rehired{f}#12, job_positions{f}#13, languages{f}#14, languages.byte{f}#15, languages.long{f}#16, languages.short{f}#17, last_name{f}#18, salary{f}#19, salary_change{f}#20, salary_change.int{f}#21, salary_change.keyword{f}#22, salary_change.long{f}#23, still_hired{f}#24] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testEvalCast/query.esql b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testEvalCast/query.esql new file mode 100644 index 0000000000000..f26a0fbca818e --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testEvalCast/query.esql @@ -0,0 +1,2 @@ +SET unmapped_fields="load"; FROM employees +| EVAL x = does_not_exist_field::LONG diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testEvalCastInPlace/load/analysis.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testEvalCastInPlace/load/analysis.expected new file mode 100644 index 0000000000000..81f2f5801c839 --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testEvalCastInPlace/load/analysis.expected @@ -0,0 +1,3 @@ +Limit[1000[INTEGER],false,false] +\_Eval[[TOLONG(does_not_exist_field{f}#0) AS does_not_exist_field::LONG#1]] + \_EsRelation[employees][avg_worked_seconds{f}#2, birth_date{f}#3, emp_no{f}#4, first_name{f}#5, gender{f}#6, height{f}#7, height.float{f}#8, height.half_float{f}#9, height.scaled_float{f}#10, hire_date{f}#11, is_rehired{f}#12, job_positions{f}#13, languages{f}#14, languages.byte{f}#15, languages.long{f}#16, languages.short{f}#17, last_name{f}#18, salary{f}#19, salary_change{f}#20, salary_change.int{f}#21, salary_change.keyword{f}#22, salary_change.long{f}#23, still_hired{f}#24, does_not_exist_field{f}#0] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testEvalCastInPlace/nullify/analysis.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testEvalCastInPlace/nullify/analysis.expected new file mode 100644 index 0000000000000..8b534e63aaf3c --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testEvalCastInPlace/nullify/analysis.expected @@ -0,0 +1,4 @@ +Limit[1000[INTEGER],false,false] +\_Eval[[TOLONG(does_not_exist_field{r}#0) AS does_not_exist_field::LONG#1]] + \_Eval[[null[NULL] AS does_not_exist_field#0]] + \_EsRelation[employees][avg_worked_seconds{f}#2, birth_date{f}#3, emp_no{f}#4, first_name{f}#5, gender{f}#6, height{f}#7, height.float{f}#8, height.half_float{f}#9, height.scaled_float{f}#10, hire_date{f}#11, is_rehired{f}#12, job_positions{f}#13, languages{f}#14, languages.byte{f}#15, languages.long{f}#16, languages.short{f}#17, last_name{f}#18, salary{f}#19, salary_change{f}#20, salary_change.int{f}#21, salary_change.keyword{f}#22, salary_change.long{f}#23, still_hired{f}#24] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testEvalCastInPlace/query.esql b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testEvalCastInPlace/query.esql new file mode 100644 index 0000000000000..fde7a9a40d5e3 --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testEvalCastInPlace/query.esql @@ -0,0 +1,2 @@ +SET unmapped_fields="load"; FROM employees +| EVAL does_not_exist_field::LONG diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testEvalReplace/load/analysis.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testEvalReplace/load/analysis.expected new file mode 100644 index 0000000000000..ffb2c79dd6cd0 --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testEvalReplace/load/analysis.expected @@ -0,0 +1,4 @@ +Limit[1000[INTEGER],false,false] +\_Eval[[42[INTEGER] AS does_not_exist_field#0]] + \_Eval[[TODOUBLE(does_not_exist_field{f}#1) + 1[INTEGER] AS x#2]] + \_EsRelation[employees][avg_worked_seconds{f}#3, birth_date{f}#4, emp_no{f}#5, first_name{f}#6, gender{f}#7, height{f}#8, height.float{f}#9, height.half_float{f}#10, height.scaled_float{f}#11, hire_date{f}#12, is_rehired{f}#13, job_positions{f}#14, languages{f}#15, languages.byte{f}#16, languages.long{f}#17, languages.short{f}#18, last_name{f}#19, salary{f}#20, salary_change{f}#21, salary_change.int{f}#22, salary_change.keyword{f}#23, salary_change.long{f}#24, still_hired{f}#25, does_not_exist_field{f}#1] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testEvalReplace/nullify/analysis.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testEvalReplace/nullify/analysis.expected new file mode 100644 index 0000000000000..5ce8713e6a882 --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testEvalReplace/nullify/analysis.expected @@ -0,0 +1,5 @@ +Limit[1000[INTEGER],false,false] +\_Eval[[42[INTEGER] AS does_not_exist_field#0]] + \_Eval[[TODOUBLE(does_not_exist_field{r}#1) + 1[INTEGER] AS x#2]] + \_Eval[[null[NULL] AS does_not_exist_field#1]] + \_EsRelation[employees][avg_worked_seconds{f}#3, birth_date{f}#4, emp_no{f}#5, first_name{f}#6, gender{f}#7, height{f}#8, height.float{f}#9, height.half_float{f}#10, height.scaled_float{f}#11, hire_date{f}#12, is_rehired{f}#13, job_positions{f}#14, languages{f}#15, languages.byte{f}#16, languages.long{f}#17, languages.short{f}#18, last_name{f}#19, salary{f}#20, salary_change{f}#21, salary_change.int{f}#22, salary_change.keyword{f}#23, salary_change.long{f}#24, still_hired{f}#25] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testEvalReplace/query.esql b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testEvalReplace/query.esql new file mode 100644 index 0000000000000..826ae0ac8f745 --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testEvalReplace/query.esql @@ -0,0 +1,3 @@ +SET unmapped_fields="load"; FROM employees +| EVAL x = does_not_exist_field::DOUBLE + 1 +| EVAL does_not_exist_field = 42 diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testInlineStats/load/analysis.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testInlineStats/load/analysis.expected new file mode 100644 index 0000000000000..36814b4fcb812 --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testInlineStats/load/analysis.expected @@ -0,0 +1,4 @@ +Limit[1000[INTEGER],false,false] +\_InlineStats[] + \_Aggregate[[does_not_exist2{f}#0, emp_no{f}#1],[SUM(TODOUBLE(does_not_exist1{f}#2),true[BOOLEAN],PT0S[TIME_DURATION],compensated[KEYWORD]) AS s#3, COUNT(*[KEYWORD],true[BOOLEAN],PT0S[TIME_DURATION]) AS c#4, does_not_exist2{f}#0, emp_no{f}#1]] + \_EsRelation[employees][avg_worked_seconds{f}#5, birth_date{f}#6, emp_no{f}#1, first_name{f}#7, gender{f}#8, height{f}#9, height.float{f}#10, height.half_float{f}#11, height.scaled_float{f}#12, hire_date{f}#13, is_rehired{f}#14, job_positions{f}#15, languages{f}#16, languages.byte{f}#17, languages.long{f}#18, languages.short{f}#19, last_name{f}#20, salary{f}#21, salary_change{f}#22, salary_change.int{f}#23, salary_change.keyword{f}#24, salary_change.long{f}#25, still_hired{f}#26, does_not_exist2{f}#0, does_not_exist1{f}#2] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testInlineStats/nullify/analysis.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testInlineStats/nullify/analysis.expected new file mode 100644 index 0000000000000..5f2ab1697cd95 --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testInlineStats/nullify/analysis.expected @@ -0,0 +1,5 @@ +Limit[1000[INTEGER],false,false] +\_InlineStats[] + \_Aggregate[[does_not_exist2{r}#0, emp_no{f}#1],[SUM(TODOUBLE(does_not_exist1{r}#2),true[BOOLEAN],PT0S[TIME_DURATION],compensated[KEYWORD]) AS s#3, COUNT(*[KEYWORD],true[BOOLEAN],PT0S[TIME_DURATION]) AS c#4, does_not_exist2{r}#0, emp_no{f}#1]] + \_Eval[[null[NULL] AS does_not_exist2#0, null[NULL] AS does_not_exist1#2]] + \_EsRelation[employees][avg_worked_seconds{f}#5, birth_date{f}#6, emp_no{f}#1, first_name{f}#7, gender{f}#8, height{f}#9, height.float{f}#10, height.half_float{f}#11, height.scaled_float{f}#12, hire_date{f}#13, is_rehired{f}#14, job_positions{f}#15, languages{f}#16, languages.byte{f}#17, languages.long{f}#18, languages.short{f}#19, last_name{f}#20, salary{f}#21, salary_change{f}#22, salary_change.int{f}#23, salary_change.keyword{f}#24, salary_change.long{f}#25, still_hired{f}#26] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testInlineStats/query.esql b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testInlineStats/query.esql new file mode 100644 index 0000000000000..8c7146b6bb792 --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testInlineStats/query.esql @@ -0,0 +1,2 @@ +SET unmapped_fields="load"; FROM employees +| INLINE STATS s = SUM(does_not_exist1::DOUBLE), c = COUNT(*) BY does_not_exist2, emp_no diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testKeep/load/analysis.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testKeep/load/analysis.expected new file mode 100644 index 0000000000000..b0d320e2b8ee8 --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testKeep/load/analysis.expected @@ -0,0 +1,3 @@ +Limit[1000[INTEGER],false,false] +\_Project[[does_not_exist_field{f}#0]] + \_EsRelation[employees][avg_worked_seconds{f}#1, birth_date{f}#2, emp_no{f}#3, first_name{f}#4, gender{f}#5, height{f}#6, height.float{f}#7, height.half_float{f}#8, height.scaled_float{f}#9, hire_date{f}#10, is_rehired{f}#11, job_positions{f}#12, languages{f}#13, languages.byte{f}#14, languages.long{f}#15, languages.short{f}#16, last_name{f}#17, salary{f}#18, salary_change{f}#19, salary_change.int{f}#20, salary_change.keyword{f}#21, salary_change.long{f}#22, still_hired{f}#23, does_not_exist_field{f}#0] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testKeep/nullify/analysis.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testKeep/nullify/analysis.expected new file mode 100644 index 0000000000000..4cc092c3f4aee --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testKeep/nullify/analysis.expected @@ -0,0 +1,4 @@ +Limit[1000[INTEGER],false,false] +\_Project[[does_not_exist_field{r}#0]] + \_Eval[[null[NULL] AS does_not_exist_field#0]] + \_EsRelation[employees][avg_worked_seconds{f}#1, birth_date{f}#2, emp_no{f}#3, first_name{f}#4, gender{f}#5, height{f}#6, height.float{f}#7, height.half_float{f}#8, height.scaled_float{f}#9, hire_date{f}#10, is_rehired{f}#11, job_positions{f}#12, languages{f}#13, languages.byte{f}#14, languages.long{f}#15, languages.short{f}#16, last_name{f}#17, salary{f}#18, salary_change{f}#19, salary_change.int{f}#20, salary_change.keyword{f}#21, salary_change.long{f}#22, still_hired{f}#23] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testKeep/query.esql b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testKeep/query.esql new file mode 100644 index 0000000000000..85b4cb1847fc2 --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testKeep/query.esql @@ -0,0 +1,2 @@ +SET unmapped_fields="load"; FROM employees +| KEEP does_not_exist_field diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testKeepAndMatchingStar/load/analysis.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testKeepAndMatchingStar/load/analysis.expected new file mode 100644 index 0000000000000..872c7642ff1f5 --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testKeepAndMatchingStar/load/analysis.expected @@ -0,0 +1,3 @@ +Limit[1000[INTEGER],false,false] +\_Project[[emp_no{f}#0, does_not_exist_field{f}#1]] + \_EsRelation[employees][avg_worked_seconds{f}#2, birth_date{f}#3, emp_no{f}#0, first_name{f}#4, gender{f}#5, height{f}#6, height.float{f}#7, height.half_float{f}#8, height.scaled_float{f}#9, hire_date{f}#10, is_rehired{f}#11, job_positions{f}#12, languages{f}#13, languages.byte{f}#14, languages.long{f}#15, languages.short{f}#16, last_name{f}#17, salary{f}#18, salary_change{f}#19, salary_change.int{f}#20, salary_change.keyword{f}#21, salary_change.long{f}#22, still_hired{f}#23, does_not_exist_field{f}#1] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testKeepAndMatchingStar/nullify/analysis.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testKeepAndMatchingStar/nullify/analysis.expected new file mode 100644 index 0000000000000..cc66e19745707 --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testKeepAndMatchingStar/nullify/analysis.expected @@ -0,0 +1,4 @@ +Limit[1000[INTEGER],false,false] +\_Project[[emp_no{f}#0, does_not_exist_field{r}#1]] + \_Eval[[null[NULL] AS does_not_exist_field#1]] + \_EsRelation[employees][avg_worked_seconds{f}#2, birth_date{f}#3, emp_no{f}#0, first_name{f}#4, gender{f}#5, height{f}#6, height.float{f}#7, height.half_float{f}#8, height.scaled_float{f}#9, hire_date{f}#10, is_rehired{f}#11, job_positions{f}#12, languages{f}#13, languages.byte{f}#14, languages.long{f}#15, languages.short{f}#16, last_name{f}#17, salary{f}#18, salary_change{f}#19, salary_change.int{f}#20, salary_change.keyword{f}#21, salary_change.long{f}#22, still_hired{f}#23] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testKeepAndMatchingStar/query.esql b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testKeepAndMatchingStar/query.esql new file mode 100644 index 0000000000000..5c1bb707e111a --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testKeepAndMatchingStar/query.esql @@ -0,0 +1,2 @@ +SET unmapped_fields="load"; FROM employees +| KEEP emp_*, does_not_exist_field diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testKeepRepeated/load/analysis.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testKeepRepeated/load/analysis.expected new file mode 100644 index 0000000000000..b0d320e2b8ee8 --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testKeepRepeated/load/analysis.expected @@ -0,0 +1,3 @@ +Limit[1000[INTEGER],false,false] +\_Project[[does_not_exist_field{f}#0]] + \_EsRelation[employees][avg_worked_seconds{f}#1, birth_date{f}#2, emp_no{f}#3, first_name{f}#4, gender{f}#5, height{f}#6, height.float{f}#7, height.half_float{f}#8, height.scaled_float{f}#9, hire_date{f}#10, is_rehired{f}#11, job_positions{f}#12, languages{f}#13, languages.byte{f}#14, languages.long{f}#15, languages.short{f}#16, last_name{f}#17, salary{f}#18, salary_change{f}#19, salary_change.int{f}#20, salary_change.keyword{f}#21, salary_change.long{f}#22, still_hired{f}#23, does_not_exist_field{f}#0] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testKeepRepeated/nullify/analysis.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testKeepRepeated/nullify/analysis.expected new file mode 100644 index 0000000000000..4cc092c3f4aee --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testKeepRepeated/nullify/analysis.expected @@ -0,0 +1,4 @@ +Limit[1000[INTEGER],false,false] +\_Project[[does_not_exist_field{r}#0]] + \_Eval[[null[NULL] AS does_not_exist_field#0]] + \_EsRelation[employees][avg_worked_seconds{f}#1, birth_date{f}#2, emp_no{f}#3, first_name{f}#4, gender{f}#5, height{f}#6, height.float{f}#7, height.half_float{f}#8, height.scaled_float{f}#9, hire_date{f}#10, is_rehired{f}#11, job_positions{f}#12, languages{f}#13, languages.byte{f}#14, languages.long{f}#15, languages.short{f}#16, last_name{f}#17, salary{f}#18, salary_change{f}#19, salary_change.int{f}#20, salary_change.keyword{f}#21, salary_change.long{f}#22, still_hired{f}#23] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testKeepRepeated/query.esql b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testKeepRepeated/query.esql new file mode 100644 index 0000000000000..ffc9a50988725 --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testKeepRepeated/query.esql @@ -0,0 +1,2 @@ +SET unmapped_fields="load"; FROM employees +| KEEP does_not_exist_field, does_not_exist_field diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testKeepThenEval/load/analysis.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testKeepThenEval/load/analysis.expected new file mode 100644 index 0000000000000..c6a21f8491422 --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testKeepThenEval/load/analysis.expected @@ -0,0 +1,4 @@ +Limit[1000[INTEGER],false,false] +\_Eval[[42[INTEGER] AS does_not_exist_field#0]] + \_Project[[does_not_exist_field{f}#1]] + \_EsRelation[employees][avg_worked_seconds{f}#2, birth_date{f}#3, emp_no{f}#4, first_name{f}#5, gender{f}#6, height{f}#7, height.float{f}#8, height.half_float{f}#9, height.scaled_float{f}#10, hire_date{f}#11, is_rehired{f}#12, job_positions{f}#13, languages{f}#14, languages.byte{f}#15, languages.long{f}#16, languages.short{f}#17, last_name{f}#18, salary{f}#19, salary_change{f}#20, salary_change.int{f}#21, salary_change.keyword{f}#22, salary_change.long{f}#23, still_hired{f}#24, does_not_exist_field{f}#1] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testKeepThenEval/nullify/analysis.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testKeepThenEval/nullify/analysis.expected new file mode 100644 index 0000000000000..f95ae9f74e6dc --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testKeepThenEval/nullify/analysis.expected @@ -0,0 +1,5 @@ +Limit[1000[INTEGER],false,false] +\_Eval[[42[INTEGER] AS does_not_exist_field#0]] + \_Project[[does_not_exist_field{r}#1]] + \_Eval[[null[NULL] AS does_not_exist_field#1]] + \_EsRelation[employees][avg_worked_seconds{f}#2, birth_date{f}#3, emp_no{f}#4, first_name{f}#5, gender{f}#6, height{f}#7, height.float{f}#8, height.half_float{f}#9, height.scaled_float{f}#10, hire_date{f}#11, is_rehired{f}#12, job_positions{f}#13, languages{f}#14, languages.byte{f}#15, languages.long{f}#16, languages.short{f}#17, last_name{f}#18, salary{f}#19, salary_change{f}#20, salary_change.int{f}#21, salary_change.keyword{f}#22, salary_change.long{f}#23, still_hired{f}#24] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testKeepThenEval/query.esql b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testKeepThenEval/query.esql new file mode 100644 index 0000000000000..945f0e290ca38 --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testKeepThenEval/query.esql @@ -0,0 +1,3 @@ +SET unmapped_fields="load"; FROM employees +| KEEP does_not_exist_field +| EVAL does_not_exist_field = 42 diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testMultipleEval/load/analysis.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testMultipleEval/load/analysis.expected new file mode 100644 index 0000000000000..9b8968ae63fd7 --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testMultipleEval/load/analysis.expected @@ -0,0 +1,5 @@ +Limit[1000[INTEGER],false,false] +\_Eval[[TODOUBLE(b{f}#0) + TODOUBLE(c{f}#1) AS y#2]] + \_Eval[[a{r}#3 + TODOUBLE(b{f}#0) AS x#4]] + \_Eval[[1[INTEGER] AS a#3]] + \_EsRelation[employees][avg_worked_seconds{f}#5, birth_date{f}#6, emp_no{f}#7, first_name{f}#8, gender{f}#9, height{f}#10, height.float{f}#11, height.half_float{f}#12, height.scaled_float{f}#13, hire_date{f}#14, is_rehired{f}#15, job_positions{f}#16, languages{f}#17, languages.byte{f}#18, languages.long{f}#19, languages.short{f}#20, last_name{f}#21, salary{f}#22, salary_change{f}#23, salary_change.int{f}#24, salary_change.keyword{f}#25, salary_change.long{f}#26, still_hired{f}#27, b{f}#0, c{f}#1] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testMultipleEval/nullify/analysis.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testMultipleEval/nullify/analysis.expected new file mode 100644 index 0000000000000..db17e201ae307 --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testMultipleEval/nullify/analysis.expected @@ -0,0 +1,5 @@ +Limit[1000[INTEGER],false,false] +\_Eval[[TODOUBLE(b{r}#0) + TODOUBLE(c{r}#1) AS y#2]] + \_Eval[[a{r}#3 + TODOUBLE(b{r}#0) AS x#4]] + \_Eval[[1[INTEGER] AS a#3, null[NULL] AS b#0, null[NULL] AS c#1]] + \_EsRelation[employees][avg_worked_seconds{f}#5, birth_date{f}#6, emp_no{f}#7, first_name{f}#8, gender{f}#9, height{f}#10, height.float{f}#11, height.half_float{f}#12, height.scaled_float{f}#13, hire_date{f}#14, is_rehired{f}#15, job_positions{f}#16, languages{f}#17, languages.byte{f}#18, languages.long{f}#19, languages.short{f}#20, last_name{f}#21, salary{f}#22, salary_change{f}#23, salary_change.int{f}#24, salary_change.keyword{f}#25, salary_change.long{f}#26, still_hired{f}#27] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testMultipleEval/query.esql b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testMultipleEval/query.esql new file mode 100644 index 0000000000000..78c3271ba9d3c --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testMultipleEval/query.esql @@ -0,0 +1,4 @@ +SET unmapped_fields="load"; FROM employees +| EVAL a = 1 +| EVAL x = a + b::DOUBLE +| EVAL y = b::DOUBLE + c::DOUBLE diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testMvExpand/load/analysis.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testMvExpand/load/analysis.expected new file mode 100644 index 0000000000000..431d39d786c87 --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testMvExpand/load/analysis.expected @@ -0,0 +1,3 @@ +Limit[1000[INTEGER],false,false] +\_MvExpand[does_not_exist{f}#0,does_not_exist{r}#1] + \_EsRelation[employees][avg_worked_seconds{f}#2, birth_date{f}#3, emp_no{f}#4, first_name{f}#5, gender{f}#6, height{f}#7, height.float{f}#8, height.half_float{f}#9, height.scaled_float{f}#10, hire_date{f}#11, is_rehired{f}#12, job_positions{f}#13, languages{f}#14, languages.byte{f}#15, languages.long{f}#16, languages.short{f}#17, last_name{f}#18, salary{f}#19, salary_change{f}#20, salary_change.int{f}#21, salary_change.keyword{f}#22, salary_change.long{f}#23, still_hired{f}#24, does_not_exist{f}#0] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testMvExpand/nullify/analysis.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testMvExpand/nullify/analysis.expected new file mode 100644 index 0000000000000..2720ef7cf3a24 --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testMvExpand/nullify/analysis.expected @@ -0,0 +1,4 @@ +Limit[1000[INTEGER],false,false] +\_MvExpand[does_not_exist{r}#0,does_not_exist{r}#1] + \_Eval[[null[NULL] AS does_not_exist#0]] + \_EsRelation[employees][avg_worked_seconds{f}#2, birth_date{f}#3, emp_no{f}#4, first_name{f}#5, gender{f}#6, height{f}#7, height.float{f}#8, height.half_float{f}#9, height.scaled_float{f}#10, hire_date{f}#11, is_rehired{f}#12, job_positions{f}#13, languages{f}#14, languages.byte{f}#15, languages.long{f}#16, languages.short{f}#17, last_name{f}#18, salary{f}#19, salary_change{f}#20, salary_change.int{f}#21, salary_change.keyword{f}#22, salary_change.long{f}#23, still_hired{f}#24] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testMvExpand/query.esql b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testMvExpand/query.esql new file mode 100644 index 0000000000000..470cc59438c6c --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testMvExpand/query.esql @@ -0,0 +1,2 @@ +SET unmapped_fields="load"; FROM employees +| MV_EXPAND does_not_exist diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testRename/load/analysis.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testRename/load/analysis.expected new file mode 100644 index 0000000000000..d593728177af5 --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testRename/load/analysis.expected @@ -0,0 +1,3 @@ +Limit[1000[INTEGER],false,false] +\_Project[[avg_worked_seconds{f}#0, birth_date{f}#1, emp_no{f}#2 AS employee_number#3, first_name{f}#4, gender{f}#5, height{f}#6, height.float{f}#7, height.half_float{f}#8, height.scaled_float{f}#9, hire_date{f}#10, is_rehired{f}#11, job_positions{f}#12, languages{f}#13, languages.byte{f}#14, languages.long{f}#15, languages.short{f}#16, last_name{f}#17, salary{f}#18, salary_change{f}#19, salary_change.int{f}#20, salary_change.keyword{f}#21, salary_change.long{f}#22, still_hired{f}#23, does_not_exist_field{f}#24 AS now_it_does#25]] + \_EsRelation[employees][avg_worked_seconds{f}#0, birth_date{f}#1, emp_no{f}#2, first_name{f}#4, gender{f}#5, height{f}#6, height.float{f}#7, height.half_float{f}#8, height.scaled_float{f}#9, hire_date{f}#10, is_rehired{f}#11, job_positions{f}#12, languages{f}#13, languages.byte{f}#14, languages.long{f}#15, languages.short{f}#16, last_name{f}#17, salary{f}#18, salary_change{f}#19, salary_change.int{f}#20, salary_change.keyword{f}#21, salary_change.long{f}#22, still_hired{f}#23, does_not_exist_field{f}#24] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testRename/nullify/analysis.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testRename/nullify/analysis.expected new file mode 100644 index 0000000000000..8dd19dd1a11b8 --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testRename/nullify/analysis.expected @@ -0,0 +1,4 @@ +Limit[1000[INTEGER],false,false] +\_Project[[avg_worked_seconds{f}#0, birth_date{f}#1, emp_no{f}#2 AS employee_number#3, first_name{f}#4, gender{f}#5, height{f}#6, height.float{f}#7, height.half_float{f}#8, height.scaled_float{f}#9, hire_date{f}#10, is_rehired{f}#11, job_positions{f}#12, languages{f}#13, languages.byte{f}#14, languages.long{f}#15, languages.short{f}#16, last_name{f}#17, salary{f}#18, salary_change{f}#19, salary_change.int{f}#20, salary_change.keyword{f}#21, salary_change.long{f}#22, still_hired{f}#23, does_not_exist_field{r}#24 AS now_it_does#25]] + \_Eval[[null[NULL] AS does_not_exist_field#24]] + \_EsRelation[employees][avg_worked_seconds{f}#0, birth_date{f}#1, emp_no{f}#2, first_name{f}#4, gender{f}#5, height{f}#6, height.float{f}#7, height.half_float{f}#8, height.scaled_float{f}#9, hire_date{f}#10, is_rehired{f}#11, job_positions{f}#12, languages{f}#13, languages.byte{f}#14, languages.long{f}#15, languages.short{f}#16, last_name{f}#17, salary{f}#18, salary_change{f}#19, salary_change.int{f}#20, salary_change.keyword{f}#21, salary_change.long{f}#22, still_hired{f}#23] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testRename/query.esql b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testRename/query.esql new file mode 100644 index 0000000000000..319f90371ed9c --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testRename/query.esql @@ -0,0 +1,2 @@ +SET unmapped_fields="load"; FROM employees +| RENAME does_not_exist_field AS now_it_does, emp_no AS employee_number diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testRenameEval/load/analysis.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testRenameEval/load/analysis.expected new file mode 100644 index 0000000000000..a802df25ed62b --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testRenameEval/load/analysis.expected @@ -0,0 +1,4 @@ +Limit[1000[INTEGER],false,false] +\_Eval[[TODOUBLE(does_not_exist{f}#0) + 1[INTEGER] AS x#1]] + \_Project[[avg_worked_seconds{f}#2, birth_date{f}#3, emp_no{f}#4 AS employee_number#5, first_name{f}#6, gender{f}#7, height{f}#8, height.float{f}#9, height.half_float{f}#10, height.scaled_float{f}#11, hire_date{f}#12, is_rehired{f}#13, job_positions{f}#14, languages{f}#15, languages.byte{f}#16, languages.long{f}#17, languages.short{f}#18, last_name{f}#19, salary{f}#20, salary_change{f}#21, salary_change.int{f}#22, salary_change.keyword{f}#23, salary_change.long{f}#24, still_hired{f}#25, does_not_exist{f}#0]] + \_EsRelation[employees][avg_worked_seconds{f}#2, birth_date{f}#3, emp_no{f}#4, first_name{f}#6, gender{f}#7, height{f}#8, height.float{f}#9, height.half_float{f}#10, height.scaled_float{f}#11, hire_date{f}#12, is_rehired{f}#13, job_positions{f}#14, languages{f}#15, languages.byte{f}#16, languages.long{f}#17, languages.short{f}#18, last_name{f}#19, salary{f}#20, salary_change{f}#21, salary_change.int{f}#22, salary_change.keyword{f}#23, salary_change.long{f}#24, still_hired{f}#25, does_not_exist{f}#0] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testRenameEval/nullify/analysis.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testRenameEval/nullify/analysis.expected new file mode 100644 index 0000000000000..f96459400cd9a --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testRenameEval/nullify/analysis.expected @@ -0,0 +1,5 @@ +Limit[1000[INTEGER],false,false] +\_Eval[[TODOUBLE(does_not_exist{r}#0) + 1[INTEGER] AS x#1]] + \_Project[[avg_worked_seconds{f}#2, birth_date{f}#3, emp_no{f}#4 AS employee_number#5, first_name{f}#6, gender{f}#7, height{f}#8, height.float{f}#9, height.half_float{f}#10, height.scaled_float{f}#11, hire_date{f}#12, is_rehired{f}#13, job_positions{f}#14, languages{f}#15, languages.byte{f}#16, languages.long{f}#17, languages.short{f}#18, last_name{f}#19, salary{f}#20, salary_change{f}#21, salary_change.int{f}#22, salary_change.keyword{f}#23, salary_change.long{f}#24, still_hired{f}#25, does_not_exist{r}#0]] + \_Eval[[null[NULL] AS does_not_exist#0]] + \_EsRelation[employees][avg_worked_seconds{f}#2, birth_date{f}#3, emp_no{f}#4, first_name{f}#6, gender{f}#7, height{f}#8, height.float{f}#9, height.half_float{f}#10, height.scaled_float{f}#11, hire_date{f}#12, is_rehired{f}#13, job_positions{f}#14, languages{f}#15, languages.byte{f}#16, languages.long{f}#17, languages.short{f}#18, last_name{f}#19, salary{f}#20, salary_change{f}#21, salary_change.int{f}#22, salary_change.keyword{f}#23, salary_change.long{f}#24, still_hired{f}#25] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testRenameEval/query.esql b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testRenameEval/query.esql new file mode 100644 index 0000000000000..15a3d0131d523 --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testRenameEval/query.esql @@ -0,0 +1,3 @@ +SET unmapped_fields="load"; FROM employees +| RENAME emp_no AS employee_number +| EVAL x = does_not_exist::DOUBLE + 1 diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testRenameRepeated/load/analysis.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testRenameRepeated/load/analysis.expected new file mode 100644 index 0000000000000..0cc4d05a2041e --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testRenameRepeated/load/analysis.expected @@ -0,0 +1,3 @@ +Limit[1000[INTEGER],false,false] +\_Project[[avg_worked_seconds{f}#0, birth_date{f}#1, emp_no{f}#2 AS employee_number#3, first_name{f}#4, gender{f}#5, height{f}#6, height.float{f}#7, height.half_float{f}#8, height.scaled_float{f}#9, hire_date{f}#10, is_rehired{f}#11, job_positions{f}#12, languages{f}#13, languages.byte{f}#14, languages.long{f}#15, languages.short{f}#16, last_name{f}#17, salary{f}#18, salary_change{f}#19, salary_change.int{f}#20, salary_change.keyword{f}#21, salary_change.long{f}#22, still_hired{f}#23, neither_does_this{f}#24 AS now_it_does#25]] + \_EsRelation[employees][avg_worked_seconds{f}#0, birth_date{f}#1, emp_no{f}#2, first_name{f}#4, gender{f}#5, height{f}#6, height.float{f}#7, height.half_float{f}#8, height.scaled_float{f}#9, hire_date{f}#10, is_rehired{f}#11, job_positions{f}#12, languages{f}#13, languages.byte{f}#14, languages.long{f}#15, languages.short{f}#16, last_name{f}#17, salary{f}#18, salary_change{f}#19, salary_change.int{f}#20, salary_change.keyword{f}#21, salary_change.long{f}#22, still_hired{f}#23, does_not_exist_field{f}#26, neither_does_this{f}#24] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testRenameRepeated/nullify/analysis.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testRenameRepeated/nullify/analysis.expected new file mode 100644 index 0000000000000..7507e4ff3fa4e --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testRenameRepeated/nullify/analysis.expected @@ -0,0 +1,4 @@ +Limit[1000[INTEGER],false,false] +\_Project[[avg_worked_seconds{f}#0, birth_date{f}#1, emp_no{f}#2 AS employee_number#3, first_name{f}#4, gender{f}#5, height{f}#6, height.float{f}#7, height.half_float{f}#8, height.scaled_float{f}#9, hire_date{f}#10, is_rehired{f}#11, job_positions{f}#12, languages{f}#13, languages.byte{f}#14, languages.long{f}#15, languages.short{f}#16, last_name{f}#17, salary{f}#18, salary_change{f}#19, salary_change.int{f}#20, salary_change.keyword{f}#21, salary_change.long{f}#22, still_hired{f}#23, neither_does_this{r}#24 AS now_it_does#25]] + \_Eval[[null[NULL] AS does_not_exist_field#26, null[NULL] AS neither_does_this#24]] + \_EsRelation[employees][avg_worked_seconds{f}#0, birth_date{f}#1, emp_no{f}#2, first_name{f}#4, gender{f}#5, height{f}#6, height.float{f}#7, height.half_float{f}#8, height.scaled_float{f}#9, hire_date{f}#10, is_rehired{f}#11, job_positions{f}#12, languages{f}#13, languages.byte{f}#14, languages.long{f}#15, languages.short{f}#16, last_name{f}#17, salary{f}#18, salary_change{f}#19, salary_change.int{f}#20, salary_change.keyword{f}#21, salary_change.long{f}#22, still_hired{f}#23] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testRenameRepeated/query.esql b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testRenameRepeated/query.esql new file mode 100644 index 0000000000000..efad9ee315214 --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testRenameRepeated/query.esql @@ -0,0 +1,2 @@ +SET unmapped_fields="load"; FROM employees +| RENAME does_not_exist_field AS now_it_does, neither_does_this AS now_it_does, emp_no AS employee_number diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testSort/load/analysis.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testSort/load/analysis.expected new file mode 100644 index 0000000000000..441f28eeb2c20 --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testSort/load/analysis.expected @@ -0,0 +1,3 @@ +Limit[1000[INTEGER],false,false] +\_OrderBy[[Order[does_not_exist{f}#0,ASC,LAST]]] + \_EsRelation[employees][avg_worked_seconds{f}#1, birth_date{f}#2, emp_no{f}#3, first_name{f}#4, gender{f}#5, height{f}#6, height.float{f}#7, height.half_float{f}#8, height.scaled_float{f}#9, hire_date{f}#10, is_rehired{f}#11, job_positions{f}#12, languages{f}#13, languages.byte{f}#14, languages.long{f}#15, languages.short{f}#16, last_name{f}#17, salary{f}#18, salary_change{f}#19, salary_change.int{f}#20, salary_change.keyword{f}#21, salary_change.long{f}#22, still_hired{f}#23, does_not_exist{f}#0] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testSort/nullify/analysis.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testSort/nullify/analysis.expected new file mode 100644 index 0000000000000..df3459bd98905 --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testSort/nullify/analysis.expected @@ -0,0 +1,4 @@ +Limit[1000[INTEGER],false,false] +\_OrderBy[[Order[does_not_exist{r}#0,ASC,LAST]]] + \_Eval[[null[NULL] AS does_not_exist#0]] + \_EsRelation[employees][avg_worked_seconds{f}#1, birth_date{f}#2, emp_no{f}#3, first_name{f}#4, gender{f}#5, height{f}#6, height.float{f}#7, height.half_float{f}#8, height.scaled_float{f}#9, hire_date{f}#10, is_rehired{f}#11, job_positions{f}#12, languages{f}#13, languages.byte{f}#14, languages.long{f}#15, languages.short{f}#16, last_name{f}#17, salary{f}#18, salary_change{f}#19, salary_change.int{f}#20, salary_change.keyword{f}#21, salary_change.long{f}#22, still_hired{f}#23] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testSort/query.esql b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testSort/query.esql new file mode 100644 index 0000000000000..6f307e4be48c6 --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testSort/query.esql @@ -0,0 +1,2 @@ +SET unmapped_fields="load"; FROM employees +| SORT does_not_exist ASC diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testSortExpression/load/analysis.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testSortExpression/load/analysis.expected new file mode 100644 index 0000000000000..194c11cb2dd74 --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testSortExpression/load/analysis.expected @@ -0,0 +1,3 @@ +Limit[1000[INTEGER],false,false] +\_OrderBy[[Order[TOLONG(does_not_exist{f}#0) + 1[INTEGER],ASC,LAST]]] + \_EsRelation[employees][avg_worked_seconds{f}#1, birth_date{f}#2, emp_no{f}#3, first_name{f}#4, gender{f}#5, height{f}#6, height.float{f}#7, height.half_float{f}#8, height.scaled_float{f}#9, hire_date{f}#10, is_rehired{f}#11, job_positions{f}#12, languages{f}#13, languages.byte{f}#14, languages.long{f}#15, languages.short{f}#16, last_name{f}#17, salary{f}#18, salary_change{f}#19, salary_change.int{f}#20, salary_change.keyword{f}#21, salary_change.long{f}#22, still_hired{f}#23, does_not_exist{f}#0] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testSortExpression/nullify/analysis.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testSortExpression/nullify/analysis.expected new file mode 100644 index 0000000000000..09bb15a967666 --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testSortExpression/nullify/analysis.expected @@ -0,0 +1,4 @@ +Limit[1000[INTEGER],false,false] +\_OrderBy[[Order[TOLONG(does_not_exist{r}#0) + 1[INTEGER],ASC,LAST]]] + \_Eval[[null[NULL] AS does_not_exist#0]] + \_EsRelation[employees][avg_worked_seconds{f}#1, birth_date{f}#2, emp_no{f}#3, first_name{f}#4, gender{f}#5, height{f}#6, height.float{f}#7, height.half_float{f}#8, height.scaled_float{f}#9, hire_date{f}#10, is_rehired{f}#11, job_positions{f}#12, languages{f}#13, languages.byte{f}#14, languages.long{f}#15, languages.short{f}#16, last_name{f}#17, salary{f}#18, salary_change{f}#19, salary_change.int{f}#20, salary_change.keyword{f}#21, salary_change.long{f}#22, still_hired{f}#23] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testSortExpression/query.esql b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testSortExpression/query.esql new file mode 100644 index 0000000000000..0f20bd09a4191 --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testSortExpression/query.esql @@ -0,0 +1,2 @@ +SET unmapped_fields="load"; FROM employees +| SORT does_not_exist::LONG + 1 diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testSortMultiple/load/analysis.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testSortMultiple/load/analysis.expected new file mode 100644 index 0000000000000..663bca06a5e21 --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testSortMultiple/load/analysis.expected @@ -0,0 +1,3 @@ +Limit[1000[INTEGER],false,false] +\_OrderBy[[Order[TOLONG(does_not_exist1{f}#0) + 1[INTEGER],ASC,LAST], Order[does_not_exist2{f}#1,DESC,FIRST], Order[emp_no{f}#2,ASC,LAST]]] + \_EsRelation[employees][avg_worked_seconds{f}#3, birth_date{f}#4, emp_no{f}#2, first_name{f}#5, gender{f}#6, height{f}#7, height.float{f}#8, height.half_float{f}#9, height.scaled_float{f}#10, hire_date{f}#11, is_rehired{f}#12, job_positions{f}#13, languages{f}#14, languages.byte{f}#15, languages.long{f}#16, languages.short{f}#17, last_name{f}#18, salary{f}#19, salary_change{f}#20, salary_change.int{f}#21, salary_change.keyword{f}#22, salary_change.long{f}#23, still_hired{f}#24, does_not_exist1{f}#0, does_not_exist2{f}#1] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testSortMultiple/nullify/analysis.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testSortMultiple/nullify/analysis.expected new file mode 100644 index 0000000000000..f57ed4d6c6fda --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testSortMultiple/nullify/analysis.expected @@ -0,0 +1,4 @@ +Limit[1000[INTEGER],false,false] +\_OrderBy[[Order[TOLONG(does_not_exist1{r}#0) + 1[INTEGER],ASC,LAST], Order[does_not_exist2{r}#1,DESC,FIRST], Order[emp_no{f}#2,ASC,LAST]]] + \_Eval[[null[NULL] AS does_not_exist1#0, null[NULL] AS does_not_exist2#1]] + \_EsRelation[employees][avg_worked_seconds{f}#3, birth_date{f}#4, emp_no{f}#2, first_name{f}#5, gender{f}#6, height{f}#7, height.float{f}#8, height.half_float{f}#9, height.scaled_float{f}#10, hire_date{f}#11, is_rehired{f}#12, job_positions{f}#13, languages{f}#14, languages.byte{f}#15, languages.long{f}#16, languages.short{f}#17, last_name{f}#18, salary{f}#19, salary_change{f}#20, salary_change.int{f}#21, salary_change.keyword{f}#22, salary_change.long{f}#23, still_hired{f}#24] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testSortMultiple/query.esql b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testSortMultiple/query.esql new file mode 100644 index 0000000000000..df129647e7c8a --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testSortMultiple/query.esql @@ -0,0 +1,2 @@ +SET unmapped_fields="load"; FROM employees +| SORT does_not_exist1::LONG + 1, does_not_exist2 DESC, emp_no ASC diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testStatsBy/load/analysis.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testStatsBy/load/analysis.expected new file mode 100644 index 0000000000000..1b58079c3c0e9 --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testStatsBy/load/analysis.expected @@ -0,0 +1,3 @@ +Limit[1000[INTEGER],false,false] +\_Aggregate[[does_not_exist_field{f}#0],[does_not_exist_field{f}#0]] + \_EsRelation[employees][avg_worked_seconds{f}#1, birth_date{f}#2, emp_no{f}#3, first_name{f}#4, gender{f}#5, height{f}#6, height.float{f}#7, height.half_float{f}#8, height.scaled_float{f}#9, hire_date{f}#10, is_rehired{f}#11, job_positions{f}#12, languages{f}#13, languages.byte{f}#14, languages.long{f}#15, languages.short{f}#16, last_name{f}#17, salary{f}#18, salary_change{f}#19, salary_change.int{f}#20, salary_change.keyword{f}#21, salary_change.long{f}#22, still_hired{f}#23, does_not_exist_field{f}#0] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testStatsBy/nullify/analysis.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testStatsBy/nullify/analysis.expected new file mode 100644 index 0000000000000..dc5330d4bd4ae --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testStatsBy/nullify/analysis.expected @@ -0,0 +1,4 @@ +Limit[1000[INTEGER],false,false] +\_Aggregate[[does_not_exist_field{r}#0],[does_not_exist_field{r}#0]] + \_Eval[[null[NULL] AS does_not_exist_field#0]] + \_EsRelation[employees][avg_worked_seconds{f}#1, birth_date{f}#2, emp_no{f}#3, first_name{f}#4, gender{f}#5, height{f}#6, height.float{f}#7, height.half_float{f}#8, height.scaled_float{f}#9, hire_date{f}#10, is_rehired{f}#11, job_positions{f}#12, languages{f}#13, languages.byte{f}#14, languages.long{f}#15, languages.short{f}#16, last_name{f}#17, salary{f}#18, salary_change{f}#19, salary_change.int{f}#20, salary_change.keyword{f}#21, salary_change.long{f}#22, still_hired{f}#23] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testStatsBy/query.esql b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testStatsBy/query.esql new file mode 100644 index 0000000000000..d13f24be60435 --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testStatsBy/query.esql @@ -0,0 +1,2 @@ +SET unmapped_fields="load"; FROM employees +| STATS BY does_not_exist_field diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testStatsCount/load/analysis.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testStatsCount/load/analysis.expected new file mode 100644 index 0000000000000..456247586e3be --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testStatsCount/load/analysis.expected @@ -0,0 +1,3 @@ +Limit[1000[INTEGER],false,false] +\_Aggregate[[],[COUNT(does_not_exist_field{f}#0,true[BOOLEAN],PT0S[TIME_DURATION]) AS cnt#1]] + \_EsRelation[employees][avg_worked_seconds{f}#2, birth_date{f}#3, emp_no{f}#4, first_name{f}#5, gender{f}#6, height{f}#7, height.float{f}#8, height.half_float{f}#9, height.scaled_float{f}#10, hire_date{f}#11, is_rehired{f}#12, job_positions{f}#13, languages{f}#14, languages.byte{f}#15, languages.long{f}#16, languages.short{f}#17, last_name{f}#18, salary{f}#19, salary_change{f}#20, salary_change.int{f}#21, salary_change.keyword{f}#22, salary_change.long{f}#23, still_hired{f}#24, does_not_exist_field{f}#0] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testStatsCount/nullify/analysis.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testStatsCount/nullify/analysis.expected new file mode 100644 index 0000000000000..bce83c7e94ff2 --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testStatsCount/nullify/analysis.expected @@ -0,0 +1,4 @@ +Limit[1000[INTEGER],false,false] +\_Aggregate[[],[COUNT(does_not_exist_field{r}#0,true[BOOLEAN],PT0S[TIME_DURATION]) AS cnt#1]] + \_Eval[[null[NULL] AS does_not_exist_field#0]] + \_EsRelation[employees][avg_worked_seconds{f}#2, birth_date{f}#3, emp_no{f}#4, first_name{f}#5, gender{f}#6, height{f}#7, height.float{f}#8, height.half_float{f}#9, height.scaled_float{f}#10, hire_date{f}#11, is_rehired{f}#12, job_positions{f}#13, languages{f}#14, languages.byte{f}#15, languages.long{f}#16, languages.short{f}#17, last_name{f}#18, salary{f}#19, salary_change{f}#20, salary_change.int{f}#21, salary_change.keyword{f}#22, salary_change.long{f}#23, still_hired{f}#24] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testStatsCount/query.esql b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testStatsCount/query.esql new file mode 100644 index 0000000000000..2e1086f20474e --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testStatsCount/query.esql @@ -0,0 +1,2 @@ +SET unmapped_fields="load"; FROM employees +| STATS cnt = COUNT(does_not_exist_field) diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testStatsCountWhere/load/analysis.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testStatsCountWhere/load/analysis.expected new file mode 100644 index 0000000000000..0e4402c48cdba --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testStatsCountWhere/load/analysis.expected @@ -0,0 +1,3 @@ +Limit[1000[INTEGER],false,false] +\_Aggregate[[],[FilteredExpression[COUNT(*[KEYWORD],true[BOOLEAN],PT0S[TIME_DURATION]),TOLONG(does_not_exist1{f}#0) > 0[INTEGER]] AS c#1]] + \_EsRelation[employees][avg_worked_seconds{f}#2, birth_date{f}#3, emp_no{f}#4, first_name{f}#5, gender{f}#6, height{f}#7, height.float{f}#8, height.half_float{f}#9, height.scaled_float{f}#10, hire_date{f}#11, is_rehired{f}#12, job_positions{f}#13, languages{f}#14, languages.byte{f}#15, languages.long{f}#16, languages.short{f}#17, last_name{f}#18, salary{f}#19, salary_change{f}#20, salary_change.int{f}#21, salary_change.keyword{f}#22, salary_change.long{f}#23, still_hired{f}#24, does_not_exist1{f}#0] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testStatsCountWhere/nullify/analysis.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testStatsCountWhere/nullify/analysis.expected new file mode 100644 index 0000000000000..31ed40e729ba7 --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testStatsCountWhere/nullify/analysis.expected @@ -0,0 +1,4 @@ +Limit[1000[INTEGER],false,false] +\_Aggregate[[],[FilteredExpression[COUNT(*[KEYWORD],true[BOOLEAN],PT0S[TIME_DURATION]),TOLONG(does_not_exist1{r}#0) > 0[INTEGER]] AS c#1]] + \_Eval[[null[NULL] AS does_not_exist1#0]] + \_EsRelation[employees][avg_worked_seconds{f}#2, birth_date{f}#3, emp_no{f}#4, first_name{f}#5, gender{f}#6, height{f}#7, height.float{f}#8, height.half_float{f}#9, height.scaled_float{f}#10, hire_date{f}#11, is_rehired{f}#12, job_positions{f}#13, languages{f}#14, languages.byte{f}#15, languages.long{f}#16, languages.short{f}#17, last_name{f}#18, salary{f}#19, salary_change{f}#20, salary_change.int{f}#21, salary_change.keyword{f}#22, salary_change.long{f}#23, still_hired{f}#24] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testStatsCountWhere/query.esql b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testStatsCountWhere/query.esql new file mode 100644 index 0000000000000..c761b990a28aa --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testStatsCountWhere/query.esql @@ -0,0 +1,2 @@ +SET unmapped_fields="load"; FROM employees +| STATS c = COUNT(*) WHERE does_not_exist1::LONG > 0 diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testStatsMultiple/load/analysis.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testStatsMultiple/load/analysis.expected new file mode 100644 index 0000000000000..860ec580b8dd8 --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testStatsMultiple/load/analysis.expected @@ -0,0 +1,3 @@ +Limit[1000[INTEGER],false,false] +\_Aggregate[[does_not_exist2{f}#0, emp_no{f}#1],[SUM(TODOUBLE(does_not_exist1{f}#2),true[BOOLEAN],PT0S[TIME_DURATION],compensated[KEYWORD]) AS s#3, COUNT(*[KEYWORD],true[BOOLEAN],PT0S[TIME_DURATION]) AS c#4, does_not_exist2{f}#0, emp_no{f}#1]] + \_EsRelation[employees][avg_worked_seconds{f}#5, birth_date{f}#6, emp_no{f}#1, first_name{f}#7, gender{f}#8, height{f}#9, height.float{f}#10, height.half_float{f}#11, height.scaled_float{f}#12, hire_date{f}#13, is_rehired{f}#14, job_positions{f}#15, languages{f}#16, languages.byte{f}#17, languages.long{f}#18, languages.short{f}#19, last_name{f}#20, salary{f}#21, salary_change{f}#22, salary_change.int{f}#23, salary_change.keyword{f}#24, salary_change.long{f}#25, still_hired{f}#26, does_not_exist2{f}#0, does_not_exist1{f}#2] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testStatsMultiple/nullify/analysis.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testStatsMultiple/nullify/analysis.expected new file mode 100644 index 0000000000000..3bd26f310af82 --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testStatsMultiple/nullify/analysis.expected @@ -0,0 +1,4 @@ +Limit[1000[INTEGER],false,false] +\_Aggregate[[does_not_exist2{r}#0, emp_no{f}#1],[SUM(TODOUBLE(does_not_exist1{r}#2),true[BOOLEAN],PT0S[TIME_DURATION],compensated[KEYWORD]) AS s#3, COUNT(*[KEYWORD],true[BOOLEAN],PT0S[TIME_DURATION]) AS c#4, does_not_exist2{r}#0, emp_no{f}#1]] + \_Eval[[null[NULL] AS does_not_exist2#0, null[NULL] AS does_not_exist1#2]] + \_EsRelation[employees][avg_worked_seconds{f}#5, birth_date{f}#6, emp_no{f}#1, first_name{f}#7, gender{f}#8, height{f}#9, height.float{f}#10, height.half_float{f}#11, height.scaled_float{f}#12, hire_date{f}#13, is_rehired{f}#14, job_positions{f}#15, languages{f}#16, languages.byte{f}#17, languages.long{f}#18, languages.short{f}#19, last_name{f}#20, salary{f}#21, salary_change{f}#22, salary_change.int{f}#23, salary_change.keyword{f}#24, salary_change.long{f}#25, still_hired{f}#26] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testStatsMultiple/query.esql b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testStatsMultiple/query.esql new file mode 100644 index 0000000000000..ecc9a01cd10d1 --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testStatsMultiple/query.esql @@ -0,0 +1,2 @@ +SET unmapped_fields="load"; FROM employees +| STATS s = SUM(does_not_exist1::DOUBLE), c = COUNT(*) BY does_not_exist2, emp_no diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testStatsMultipleCountWhere/load/analysis.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testStatsMultipleCountWhere/load/analysis.expected new file mode 100644 index 0000000000000..1ad181f29d080 --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testStatsMultipleCountWhere/load/analysis.expected @@ -0,0 +1,4 @@ +Limit[1000[INTEGER],false,false] +\_Aggregate[[],[FilteredExpression[COUNT(*[KEYWORD],true[BOOLEAN],PT0S[TIME_DURATION]),TOLONG(does_not_exist1{f}#0) > 0[INTEGER] OR emp_no{f}#1 +9 > 0[INTEGER] OR TOLONG(does_not_exist2{f}#2) < 100[INTEGER]] AS c1#3, FilteredExpression[COUNT(*[KEYWORD],true[BOOLEAN],PT0S[TIME_DURATION]),ISNULL(does_not_exist3{f}#4)] AS c2#5]] + \_EsRelation[employees][avg_worked_seconds{f}#6, birth_date{f}#7, emp_no{f}#8, first_name{f}#9, gender{f}#10, height{f}#11, height.float{f}#12, height.half_float{f}#13, height.scaled_float{f}#14, hire_date{f}#15, is_rehired{f}#16, job_positions{f}#17, languages{f}#18, languages.byte{f}#19, languages.long{f}#20, languages.short{f}#21, last_name{f}#22, salary{f}#23, salary_change{f}#24, salary_change.int{f}#25, salary_change.keyword{f}#26, salary_change.long{f}#27, still_hired{f}#28, does_not_exist1{f}#0, does_not_exist2{f}#2, does_not_exist3{f}#4] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testStatsMultipleCountWhere/nullify/analysis.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testStatsMultipleCountWhere/nullify/analysis.expected new file mode 100644 index 0000000000000..54ebfb4203f39 --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testStatsMultipleCountWhere/nullify/analysis.expected @@ -0,0 +1,5 @@ +Limit[1000[INTEGER],false,false] +\_Aggregate[[],[FilteredExpression[COUNT(*[KEYWORD],true[BOOLEAN],PT0S[TIME_DURATION]),TOLONG(does_not_exist1{r}#0) > 0[INTEGER] OR emp_no{f}#1 +1 > 0[INTEGER] OR TOLONG(does_not_exist2{r}#2) < 100[INTEGER]] AS c1#3, FilteredExpression[COUNT(*[KEYWORD],true[BOOLEAN],PT0S[TIME_DURATION]),ISNULL(does_not_exist3{r}#4)] AS c2#5]] + \_Eval[[null[NULL] AS does_not_exist1#0, null[NULL] AS does_not_exist2#2, null[NULL] AS does_not_exist3#4]] + \_EsRelation[employees][avg_worked_seconds{f}#6, birth_date{f}#7, emp_no{f}#8, first_name{f}#9, gender{f}#10, height{f}#11, height.float{f}#12, height.half_float{f}#13, height.scaled_float{f}#14, hire_date{f}#15, is_rehired{f}#16, job_positions{f}#17, languages{f}#18, languages.byte{f}#19, languages.long{f}#20, languages.short{f}#21, last_name{f}#22, salary{f}#23, salary_change{f}#24, salary_change.int{f}#25, salary_change.keyword{f}#26, salary_change.long{f}#27, still_hired{f}#28] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testStatsMultipleCountWhere/query.esql b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testStatsMultipleCountWhere/query.esql new file mode 100644 index 0000000000000..6f052b1a79cb2 --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testStatsMultipleCountWhere/query.esql @@ -0,0 +1,3 @@ +SET unmapped_fields="nullify"; FROM employees +| STATS c1 = COUNT(*) WHERE does_not_exist1::LONG > 0 OR emp_no > 0 OR does_not_exist2::LONG < 100, + c2 = COUNT(*) WHERE does_not_exist3 IS NULL diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testStatsSumBy/load/analysis.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testStatsSumBy/load/analysis.expected new file mode 100644 index 0000000000000..27b179dff2e21 --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testStatsSumBy/load/analysis.expected @@ -0,0 +1,3 @@ +Limit[1000[INTEGER],false,false] +\_Aggregate[[does_not_exist2{f}#0],[SUM(TODOUBLE(does_not_exist1{f}#1),true[BOOLEAN],PT0S[TIME_DURATION],compensated[KEYWORD]) AS s#2, does_not_exist2{f}#0]] + \_EsRelation[employees][avg_worked_seconds{f}#3, birth_date{f}#4, emp_no{f}#5, first_name{f}#6, gender{f}#7, height{f}#8, height.float{f}#9, height.half_float{f}#10, height.scaled_float{f}#11, hire_date{f}#12, is_rehired{f}#13, job_positions{f}#14, languages{f}#15, languages.byte{f}#16, languages.long{f}#17, languages.short{f}#18, last_name{f}#19, salary{f}#20, salary_change{f}#21, salary_change.int{f}#22, salary_change.keyword{f}#23, salary_change.long{f}#24, still_hired{f}#25, does_not_exist2{f}#0, does_not_exist1{f}#1] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testStatsSumBy/nullify/analysis.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testStatsSumBy/nullify/analysis.expected new file mode 100644 index 0000000000000..75f108928c116 --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testStatsSumBy/nullify/analysis.expected @@ -0,0 +1,4 @@ +Limit[1000[INTEGER],false,false] +\_Aggregate[[does_not_exist2{r}#0],[SUM(TODOUBLE(does_not_exist1{r}#1),true[BOOLEAN],PT0S[TIME_DURATION],compensated[KEYWORD]) AS s#2, does_not_exist2{r}#0]] + \_Eval[[null[NULL] AS does_not_exist2#0, null[NULL] AS does_not_exist1#1]] + \_EsRelation[employees][avg_worked_seconds{f}#3, birth_date{f}#4, emp_no{f}#5, first_name{f}#6, gender{f}#7, height{f}#8, height.float{f}#9, height.half_float{f}#10, height.scaled_float{f}#11, hire_date{f}#12, is_rehired{f}#13, job_positions{f}#14, languages{f}#15, languages.byte{f}#16, languages.long{f}#17, languages.short{f}#18, last_name{f}#19, salary{f}#20, salary_change{f}#21, salary_change.int{f}#22, salary_change.keyword{f}#23, salary_change.long{f}#24, still_hired{f}#25] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testStatsSumBy/query.esql b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testStatsSumBy/query.esql new file mode 100644 index 0000000000000..4b45cf86d8cb5 --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testStatsSumBy/query.esql @@ -0,0 +1,2 @@ +SET unmapped_fields="load"; FROM employees +| STATS s = SUM(does_not_exist1::DOUBLE) BY does_not_exist2 diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testStatsSumByComplex/load/analysis.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testStatsSumByComplex/load/analysis.expected new file mode 100644 index 0000000000000..021eab43d5186 --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testStatsSumByComplex/load/analysis.expected @@ -0,0 +1,3 @@ +Limit[1000[INTEGER],false,false] +\_Aggregate[[TODOUBLE(does_not_exist2{f}#0) + TODOUBLE(does_not_exist3{f}#1) AS s0#2, emp_no{f}#3 AS s1#4],[SUM(TODOUBLE(does_not_exist1{f}#5),true[BOOLEAN],PT0S[TIME_DURATION],compensated[KEYWORD]) + s0{r}#2 + s1{r}#4 AS sum#6, s0{r}#2, s1{r}#4]] + \_EsRelation[employees][avg_worked_seconds{f}#7, birth_date{f}#8, emp_no{f}#3, first_name{f}#9, gender{f}#10, height{f}#11, height.float{f}#12, height.half_float{f}#13, height.scaled_float{f}#14, hire_date{f}#15, is_rehired{f}#16, job_positions{f}#17, languages{f}#18, languages.byte{f}#19, languages.long{f}#20, languages.short{f}#21, last_name{f}#22, salary{f}#23, salary_change{f}#24, salary_change.int{f}#25, salary_change.keyword{f}#26, salary_change.long{f}#27, still_hired{f}#28, does_not_exist2{f}#0, does_not_exist3{f}#1, does_not_exist1{f}#5, s0{f}#29] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testStatsSumByComplex/nullify/analysis.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testStatsSumByComplex/nullify/analysis.expected new file mode 100644 index 0000000000000..a877b9d0f0588 --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testStatsSumByComplex/nullify/analysis.expected @@ -0,0 +1,4 @@ +Limit[1000[INTEGER],false,false] +\_Aggregate[[TODOUBLE(does_not_exist2{r}#0) + TODOUBLE(does_not_exist3{r}#1) AS s0#2, emp_no{f}#3 AS s1#4],[SUM(TODOUBLE(does_not_exist1{r}#5),true[BOOLEAN],PT0S[TIME_DURATION],compensated[KEYWORD]) + s0{r}#2 + s1{r}#4 AS sum#6, s0{r}#2, s1{r}#4]] + \_Eval[[null[NULL] AS does_not_exist2#0, null[NULL] AS does_not_exist3#1, null[NULL] AS does_not_exist1#5, null[NULL] AS s0#7]] + \_EsRelation[employees][avg_worked_seconds{f}#8, birth_date{f}#9, emp_no{f}#3, first_name{f}#10, gender{f}#11, height{f}#12, height.float{f}#13, height.half_float{f}#14, height.scaled_float{f}#15, hire_date{f}#16, is_rehired{f}#17, job_positions{f}#18, languages{f}#19, languages.byte{f}#20, languages.long{f}#21, languages.short{f}#22, last_name{f}#23, salary{f}#24, salary_change{f}#25, salary_change.int{f}#26, salary_change.keyword{f}#27, salary_change.long{f}#28, still_hired{f}#29] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testStatsSumByComplex/query.esql b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testStatsSumByComplex/query.esql new file mode 100644 index 0000000000000..c8ed9b159cb2a --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testStatsSumByComplex/query.esql @@ -0,0 +1,2 @@ +SET unmapped_fields="load"; FROM employees +| STATS sum = SUM(does_not_exist1::DOUBLE) + s0 + s1 BY s0 = does_not_exist2::DOUBLE + does_not_exist3::DOUBLE, s1 = emp_no diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testStatsSumByMultiple/load/analysis.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testStatsSumByMultiple/load/analysis.expected new file mode 100644 index 0000000000000..2ad8609f9bac6 --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testStatsSumByMultiple/load/analysis.expected @@ -0,0 +1,3 @@ +Limit[1000[INTEGER],false,false] +\_Aggregate[[TODOUBLE(does_not_exist2{f}#0) AS d2#1, emp_no{f}#2],[SUM(TODOUBLE(does_not_exist1{f}#3),true[BOOLEAN],PT0S[TIME_DURATION],compensated[KEYWORD]) + d2{r}#1 AS s#4, d2{r}#1, emp_no{f}#2]] + \_EsRelation[employees][avg_worked_seconds{f}#5, birth_date{f}#6, emp_no{f}#2, first_name{f}#7, gender{f}#8, height{f}#9, height.float{f}#10, height.half_float{f}#11, height.scaled_float{f}#12, hire_date{f}#13, is_rehired{f}#14, job_positions{f}#15, languages{f}#16, languages.byte{f}#17, languages.long{f}#18, languages.short{f}#19, last_name{f}#20, salary{f}#21, salary_change{f}#22, salary_change.int{f}#23, salary_change.keyword{f}#24, salary_change.long{f}#25, still_hired{f}#26, does_not_exist2{f}#0, does_not_exist1{f}#3, d2{f}#27] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testStatsSumByMultiple/nullify/analysis.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testStatsSumByMultiple/nullify/analysis.expected new file mode 100644 index 0000000000000..f06e76b90283d --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testStatsSumByMultiple/nullify/analysis.expected @@ -0,0 +1,4 @@ +Limit[1000[INTEGER],false,false] +\_Aggregate[[TODOUBLE(does_not_exist2{r}#0) AS d2#1, emp_no{f}#2],[SUM(TODOUBLE(does_not_exist1{r}#3),true[BOOLEAN],PT0S[TIME_DURATION],compensated[KEYWORD]) + d2{r}#1 AS s#4, d2{r}#1, emp_no{f}#2]] + \_Eval[[null[NULL] AS does_not_exist2#0, null[NULL] AS does_not_exist1#3, null[NULL] AS d2#5]] + \_EsRelation[employees][avg_worked_seconds{f}#6, birth_date{f}#7, emp_no{f}#2, first_name{f}#8, gender{f}#9, height{f}#10, height.float{f}#11, height.half_float{f}#12, height.scaled_float{f}#13, hire_date{f}#14, is_rehired{f}#15, job_positions{f}#16, languages{f}#17, languages.byte{f}#18, languages.long{f}#19, languages.short{f}#20, last_name{f}#21, salary{f}#22, salary_change{f}#23, salary_change.int{f}#24, salary_change.keyword{f}#25, salary_change.long{f}#26, still_hired{f}#27] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testStatsSumByMultiple/query.esql b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testStatsSumByMultiple/query.esql new file mode 100644 index 0000000000000..d548e72eda5de --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testStatsSumByMultiple/query.esql @@ -0,0 +1,2 @@ +SET unmapped_fields="load"; FROM employees +| STATS s = SUM(does_not_exist1::DOUBLE) + d2 BY d2 = does_not_exist2::DOUBLE, emp_no diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testWhere/load/analysis.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testWhere/load/analysis.expected new file mode 100644 index 0000000000000..d413739fd03bc --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testWhere/load/analysis.expected @@ -0,0 +1,3 @@ +Limit[1000[INTEGER],false,false] +\_Filter[TOLONG(does_not_exist{f}#0) > 0[INTEGER]] + \_EsRelation[employees][avg_worked_seconds{f}#1, birth_date{f}#2, emp_no{f}#3, first_name{f}#4, gender{f}#5, height{f}#6, height.float{f}#7, height.half_float{f}#8, height.scaled_float{f}#9, hire_date{f}#10, is_rehired{f}#11, job_positions{f}#12, languages{f}#13, languages.byte{f}#14, languages.long{f}#15, languages.short{f}#16, last_name{f}#17, salary{f}#18, salary_change{f}#19, salary_change.int{f}#20, salary_change.keyword{f}#21, salary_change.long{f}#22, still_hired{f}#23, does_not_exist{f}#0] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testWhere/nullify/analysis.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testWhere/nullify/analysis.expected new file mode 100644 index 0000000000000..d56f0e5969628 --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testWhere/nullify/analysis.expected @@ -0,0 +1,4 @@ +Limit[1000[INTEGER],false,false] +\_Filter[TOLONG(does_not_exist{r}#0) > 0[INTEGER]] + \_Eval[[null[NULL] AS does_not_exist#0]] + \_EsRelation[employees][avg_worked_seconds{f}#1, birth_date{f}#2, emp_no{f}#3, first_name{f}#4, gender{f}#5, height{f}#6, height.float{f}#7, height.half_float{f}#8, height.scaled_float{f}#9, hire_date{f}#10, is_rehired{f}#11, job_positions{f}#12, languages{f}#13, languages.byte{f}#14, languages.long{f}#15, languages.short{f}#16, last_name{f}#17, salary{f}#18, salary_change{f}#19, salary_change.int{f}#20, salary_change.keyword{f}#21, salary_change.long{f}#22, still_hired{f}#23] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testWhere/query.esql b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testWhere/query.esql new file mode 100644 index 0000000000000..e713ad65f4f21 --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testWhere/query.esql @@ -0,0 +1,2 @@ +SET unmapped_fields="load"; FROM employees +| WHERE does_not_exist::LONG > 0 diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testWhereComplex/load/analysis.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testWhereComplex/load/analysis.expected new file mode 100644 index 0000000000000..8d9fcfe30c2c2 --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testWhereComplex/load/analysis.expected @@ -0,0 +1,3 @@ +Limit[1000[INTEGER],false,false] +\_Filter[TOLONG(does_not_exist1{f}#0) > 0[INTEGER] OR emp_no{f}#1 > 0[INTEGER] AND TOLONG(does_not_exist2{f}#2) < 100[INTEGER]] + \_EsRelation[employees][avg_worked_seconds{f}#3, birth_date{f}#4, emp_no{f}#1, first_name{f}#5, gender{f}#6, height{f}#7, height.float{f}#8, height.half_float{f}#9, height.scaled_float{f}#10, hire_date{f}#11, is_rehired{f}#12, job_positions{f}#13, languages{f}#14, languages.byte{f}#15, languages.long{f}#16, languages.short{f}#17, last_name{f}#18, salary{f}#19, salary_change{f}#20, salary_change.int{f}#21, salary_change.keyword{f}#22, salary_change.long{f}#23, still_hired{f}#24, does_not_exist1{f}#0, does_not_exist2{f}#2] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testWhereComplex/nullify/analysis.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testWhereComplex/nullify/analysis.expected new file mode 100644 index 0000000000000..6364f29c1da43 --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testWhereComplex/nullify/analysis.expected @@ -0,0 +1,4 @@ +Limit[1000[INTEGER],false,false] +\_Filter[TOLONG(does_not_exist1{r}#0) > 0[INTEGER] OR emp_no{f}#1 > 0[INTEGER] AND TOLONG(does_not_exist2{r}#2) < 100[INTEGER]] + \_Eval[[null[NULL] AS does_not_exist1#0, null[NULL] AS does_not_exist2#2]] + \_EsRelation[employees][avg_worked_seconds{f}#3, birth_date{f}#4, emp_no{f}#1, first_name{f}#5, gender{f}#6, height{f}#7, height.float{f}#8, height.half_float{f}#9, height.scaled_float{f}#10, hire_date{f}#11, is_rehired{f}#12, job_positions{f}#13, languages{f}#14, languages.byte{f}#15, languages.long{f}#16, languages.short{f}#17, last_name{f}#18, salary{f}#19, salary_change{f}#20, salary_change.int{f}#21, salary_change.keyword{f}#22, salary_change.long{f}#23, still_hired{f}#24] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testWhereComplex/query.esql b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testWhereComplex/query.esql new file mode 100644 index 0000000000000..ca0a222d0d3c8 --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testWhereComplex/query.esql @@ -0,0 +1,2 @@ +SET unmapped_fields="load"; FROM employees +| WHERE does_not_exist1::LONG > 0 OR emp_no > 0 AND does_not_exist2::LONG < 100 diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testWhereOr/load/analysis.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testWhereOr/load/analysis.expected new file mode 100644 index 0000000000000..4e5bd4c4b8b68 --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testWhereOr/load/analysis.expected @@ -0,0 +1,3 @@ +Limit[1000[INTEGER],false,false] +\_Filter[TOLONG(does_not_exist{f}#0) > 0[INTEGER] OR emp_no{f}#1 > 0[INTEGER]] + \_EsRelation[employees][avg_worked_seconds{f}#2, birth_date{f}#3, emp_no{f}#1, first_name{f}#4, gender{f}#5, height{f}#6, height.float{f}#7, height.half_float{f}#8, height.scaled_float{f}#9, hire_date{f}#10, is_rehired{f}#11, job_positions{f}#12, languages{f}#13, languages.byte{f}#14, languages.long{f}#15, languages.short{f}#16, last_name{f}#17, salary{f}#18, salary_change{f}#19, salary_change.int{f}#20, salary_change.keyword{f}#21, salary_change.long{f}#22, still_hired{f}#23, does_not_exist{f}#0] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testWhereOr/nullify/analysis.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testWhereOr/nullify/analysis.expected new file mode 100644 index 0000000000000..f6c3ff4db63bb --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testWhereOr/nullify/analysis.expected @@ -0,0 +1,4 @@ +Limit[1000[INTEGER],false,false] +\_Filter[TOLONG(does_not_exist{r}#0) > 0[INTEGER] OR emp_no{f}#1 > 0[INTEGER]] + \_Eval[[null[NULL] AS does_not_exist#0]] + \_EsRelation[employees][avg_worked_seconds{f}#2, birth_date{f}#3, emp_no{f}#1, first_name{f}#4, gender{f}#5, height{f}#6, height.float{f}#7, height.half_float{f}#8, height.scaled_float{f}#9, hire_date{f}#10, is_rehired{f}#11, job_positions{f}#12, languages{f}#13, languages.byte{f}#14, languages.long{f}#15, languages.short{f}#16, last_name{f}#17, salary{f}#18, salary_change{f}#19, salary_change.int{f}#20, salary_change.keyword{f}#21, salary_change.long{f}#22, still_hired{f}#23] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testWhereOr/query.esql b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testWhereOr/query.esql new file mode 100644 index 0000000000000..733eddf433f08 --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testWhereOr/query.esql @@ -0,0 +1,2 @@ +SET unmapped_fields="load"; FROM employees +| WHERE does_not_exist::LONG > 0 OR emp_no > 0 From 6aeccac178d014812bb4ba860300a16cf0387f4f Mon Sep 17 00:00:00 2001 From: Gal Lalouche Date: Tue, 3 Feb 2026 17:59:00 +0200 Subject: [PATCH 15/25] TEMP --- .../elasticsearch/xpack/esql/optimizer/GoldenTestCase.java | 4 +--- .../testStatsMultipleCountWhere/load/analysis.expected | 2 +- .../testStatsMultipleCountWhere/nullify/analysis.expected | 2 +- .../testStatsMultipleCountWhere/query.esql | 2 +- 4 files changed, 4 insertions(+), 6 deletions(-) diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/optimizer/GoldenTestCase.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/optimizer/GoldenTestCase.java index 5a3390f4d530c..95e2c140c197d 100644 --- a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/optimizer/GoldenTestCase.java +++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/optimizer/GoldenTestCase.java @@ -25,14 +25,12 @@ import org.elasticsearch.xpack.esql.analysis.Analyzer; import org.elasticsearch.xpack.esql.analysis.AnalyzerContext; import org.elasticsearch.xpack.esql.analysis.EnrichResolution; -import org.elasticsearch.xpack.esql.analysis.UnmappedResolution; import org.elasticsearch.xpack.esql.core.expression.FoldContext; import org.elasticsearch.xpack.esql.core.tree.Node; import org.elasticsearch.xpack.esql.expression.function.EsqlFunctionRegistry; import org.elasticsearch.xpack.esql.inference.InferenceResolution; import org.elasticsearch.xpack.esql.parser.EsqlParser; import org.elasticsearch.xpack.esql.plan.QueryPlan; -import org.elasticsearch.xpack.esql.plan.logical.LogicalPlan; import org.elasticsearch.xpack.esql.plan.physical.ExchangeExec; import org.elasticsearch.xpack.esql.plan.physical.ExchangeSinkExec; import org.elasticsearch.xpack.esql.plan.physical.PhysicalPlan; @@ -68,8 +66,8 @@ import static org.elasticsearch.xpack.esql.EsqlTestUtils.TEST_VERIFIER; import static org.elasticsearch.xpack.esql.EsqlTestUtils.randomMinimumVersion; import static org.elasticsearch.xpack.esql.EsqlTestUtils.withDefaultLimitWarning; -import static org.elasticsearch.xpack.esql.plan.QuerySettings.UNMAPPED_FIELDS; import static org.elasticsearch.xpack.esql.analysis.AnalyzerTestUtils.defaultLookupResolution; +import static org.elasticsearch.xpack.esql.plan.QuerySettings.UNMAPPED_FIELDS; /** See GoldenTestsReadme.md for more information about these tests. */ @Listeners({ GoldenTestCase.GoldenTestReproduceInfoPrinter.class }) diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testStatsMultipleCountWhere/load/analysis.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testStatsMultipleCountWhere/load/analysis.expected index 1ad181f29d080..ae6b7c030b624 100644 --- a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testStatsMultipleCountWhere/load/analysis.expected +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testStatsMultipleCountWhere/load/analysis.expected @@ -1,4 +1,4 @@ Limit[1000[INTEGER],false,false] \_Aggregate[[],[FilteredExpression[COUNT(*[KEYWORD],true[BOOLEAN],PT0S[TIME_DURATION]),TOLONG(does_not_exist1{f}#0) > 0[INTEGER] OR emp_no{f}#1 -9 > 0[INTEGER] OR TOLONG(does_not_exist2{f}#2) < 100[INTEGER]] AS c1#3, FilteredExpression[COUNT(*[KEYWORD],true[BOOLEAN],PT0S[TIME_DURATION]),ISNULL(does_not_exist3{f}#4)] AS c2#5]] +523 > 0[INTEGER] OR TOLONG(does_not_exist2{f}#2) < 100[INTEGER]] AS c1#3, FilteredExpression[COUNT(*[KEYWORD],true[BOOLEAN],PT0S[TIME_DURATION]),ISNULL(does_not_exist3{f}#4)] AS c2#5]] \_EsRelation[employees][avg_worked_seconds{f}#6, birth_date{f}#7, emp_no{f}#8, first_name{f}#9, gender{f}#10, height{f}#11, height.float{f}#12, height.half_float{f}#13, height.scaled_float{f}#14, hire_date{f}#15, is_rehired{f}#16, job_positions{f}#17, languages{f}#18, languages.byte{f}#19, languages.long{f}#20, languages.short{f}#21, last_name{f}#22, salary{f}#23, salary_change{f}#24, salary_change.int{f}#25, salary_change.keyword{f}#26, salary_change.long{f}#27, still_hired{f}#28, does_not_exist1{f}#0, does_not_exist2{f}#2, does_not_exist3{f}#4] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testStatsMultipleCountWhere/nullify/analysis.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testStatsMultipleCountWhere/nullify/analysis.expected index 54ebfb4203f39..ed20d1ae39bbe 100644 --- a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testStatsMultipleCountWhere/nullify/analysis.expected +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testStatsMultipleCountWhere/nullify/analysis.expected @@ -1,5 +1,5 @@ Limit[1000[INTEGER],false,false] \_Aggregate[[],[FilteredExpression[COUNT(*[KEYWORD],true[BOOLEAN],PT0S[TIME_DURATION]),TOLONG(does_not_exist1{r}#0) > 0[INTEGER] OR emp_no{f}#1 -1 > 0[INTEGER] OR TOLONG(does_not_exist2{r}#2) < 100[INTEGER]] AS c1#3, FilteredExpression[COUNT(*[KEYWORD],true[BOOLEAN],PT0S[TIME_DURATION]),ISNULL(does_not_exist3{r}#4)] AS c2#5]] +485 > 0[INTEGER] OR TOLONG(does_not_exist2{r}#2) < 100[INTEGER]] AS c1#3, FilteredExpression[COUNT(*[KEYWORD],true[BOOLEAN],PT0S[TIME_DURATION]),ISNULL(does_not_exist3{r}#4)] AS c2#5]] \_Eval[[null[NULL] AS does_not_exist1#0, null[NULL] AS does_not_exist2#2, null[NULL] AS does_not_exist3#4]] \_EsRelation[employees][avg_worked_seconds{f}#6, birth_date{f}#7, emp_no{f}#8, first_name{f}#9, gender{f}#10, height{f}#11, height.float{f}#12, height.half_float{f}#13, height.scaled_float{f}#14, hire_date{f}#15, is_rehired{f}#16, job_positions{f}#17, languages{f}#18, languages.byte{f}#19, languages.long{f}#20, languages.short{f}#21, last_name{f}#22, salary{f}#23, salary_change{f}#24, salary_change.int{f}#25, salary_change.keyword{f}#26, salary_change.long{f}#27, still_hired{f}#28] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testStatsMultipleCountWhere/query.esql b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testStatsMultipleCountWhere/query.esql index 6f052b1a79cb2..3078319477f7f 100644 --- a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testStatsMultipleCountWhere/query.esql +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testStatsMultipleCountWhere/query.esql @@ -1,3 +1,3 @@ -SET unmapped_fields="nullify"; FROM employees +SET unmapped_fields="load"; FROM employees | STATS c1 = COUNT(*) WHERE does_not_exist1::LONG > 0 OR emp_no > 0 OR does_not_exist2::LONG < 100, c2 = COUNT(*) WHERE does_not_exist3 IS NULL From d47e18b35627013f2d3b30356253b37c5b8676d7 Mon Sep 17 00:00:00 2001 From: Gal Lalouche Date: Tue, 3 Feb 2026 18:26:42 +0200 Subject: [PATCH 16/25] Fix query.esql --- .../xpack/esql/optimizer/GoldenTestCase.java | 30 ++++++++++++------- .../testDrop/{ => load}/query.esql | 0 .../testDrop/nullify/query.esql | 2 ++ .../{ => load}/query.esql | 0 .../nullify/query.esql | 2 ++ .../testEval/{ => load}/query.esql | 0 .../testEval/nullify/query.esql | 2 ++ .../{ => load}/query.esql | 0 .../testEvalAfterKeepStar/nullify/query.esql | 4 +++ .../{ => load}/query.esql | 0 .../nullify/query.esql | 4 +++ .../testEvalAndKeep/{ => load}/query.esql | 0 .../testEvalAndKeep/nullify/query.esql | 3 ++ .../testEvalCast/{ => load}/query.esql | 0 .../testEvalCast/nullify/query.esql | 2 ++ .../testEvalCastInPlace/{ => load}/query.esql | 0 .../testEvalCastInPlace/nullify/query.esql | 2 ++ .../testEvalReplace/{ => load}/query.esql | 0 .../testEvalReplace/nullify/query.esql | 3 ++ .../testInlineStats/{ => load}/query.esql | 0 .../testInlineStats/nullify/query.esql | 2 ++ .../testKeep/{ => load}/query.esql | 0 .../testKeep/nullify/query.esql | 2 ++ .../{ => load}/query.esql | 0 .../nullify/query.esql | 2 ++ .../testKeepRepeated/{ => load}/query.esql | 0 .../testKeepRepeated/nullify/query.esql | 2 ++ .../testKeepThenEval/{ => load}/query.esql | 0 .../testKeepThenEval/nullify/query.esql | 3 ++ .../testMultipleEval/{ => load}/query.esql | 0 .../testMultipleEval/nullify/query.esql | 4 +++ .../testMvExpand/{ => load}/query.esql | 0 .../testMvExpand/nullify/query.esql | 2 ++ .../testRename/{ => load}/query.esql | 0 .../testRename/nullify/query.esql | 2 ++ .../testRenameEval/{ => load}/query.esql | 0 .../testRenameEval/nullify/query.esql | 3 ++ .../testRenameRepeated/{ => load}/query.esql | 0 .../testRenameRepeated/nullify/query.esql | 2 ++ .../testSort/{ => load}/query.esql | 0 .../testSort/nullify/query.esql | 2 ++ .../testSortExpression/{ => load}/query.esql | 0 .../testSortExpression/nullify/query.esql | 2 ++ .../testSortMultiple/{ => load}/query.esql | 0 .../testSortMultiple/nullify/query.esql | 2 ++ .../testStatsBy/{ => load}/query.esql | 0 .../testStatsBy/nullify/query.esql | 2 ++ .../testStatsCount/{ => load}/query.esql | 0 .../testStatsCount/nullify/query.esql | 2 ++ .../testStatsCountWhere/{ => load}/query.esql | 0 .../testStatsCountWhere/nullify/query.esql | 2 ++ .../testStatsMultiple/{ => load}/query.esql | 0 .../testStatsMultiple/nullify/query.esql | 2 ++ .../load/analysis.expected | 2 +- .../{ => load}/query.esql | 0 .../nullify/analysis.expected | 2 +- .../nullify/query.esql | 3 ++ .../testStatsSumBy/{ => load}/query.esql | 0 .../testStatsSumBy/nullify/query.esql | 2 ++ .../{ => load}/query.esql | 0 .../testStatsSumByComplex/nullify/query.esql | 2 ++ .../{ => load}/query.esql | 0 .../testStatsSumByMultiple/nullify/query.esql | 2 ++ .../testWhere/{ => load}/query.esql | 0 .../testWhere/nullify/query.esql | 2 ++ .../testWhereComplex/{ => load}/query.esql | 0 .../testWhereComplex/nullify/query.esql | 2 ++ .../testWhereOr/{ => load}/query.esql | 0 .../testWhereOr/nullify/query.esql | 2 ++ .../bucket/query.esql | 4 +++ .../date_trunc/query.esql | 4 +++ .../round_to/query.esql | 4 +++ .../bucket/query.esql | 4 +++ .../date_trunc/query.esql | 4 +++ .../round_to/query.esql | 4 +++ .../bucket/query.esql | 2 ++ .../date_trunc/query.esql | 2 ++ .../round_to/query.esql | 2 ++ .../bucket/query.esql | 2 ++ .../date_trunc/query.esql | 2 ++ .../round_to/query.esql | 2 ++ .../bucket/query.esql | 2 ++ .../date_trunc/query.esql | 2 ++ .../round_to/query.esql | 2 ++ .../bucket/date_range/query.esql | 3 ++ .../bucket/keyword_equality/query.esql | 3 ++ .../bucket/keyword_match/query.esql | 3 ++ .../date_trunc/date_range/query.esql | 3 ++ .../date_trunc/keyword_equality/query.esql | 3 ++ .../date_trunc/keyword_match/query.esql | 3 ++ .../round_to/date_range/query.esql | 3 ++ .../round_to/keyword_equality/query.esql | 3 ++ .../round_to/keyword_match/query.esql | 3 ++ .../bucket/query.esql | 2 ++ .../date_trunc/query.esql | 2 ++ .../round_to/query.esql | 2 ++ .../date_trunc/query.esql | 5 ++++ .../round_to/query.esql | 5 ++++ .../byte/query.esql | 2 ++ .../date/query.esql | 2 ++ .../date_nanos/query.esql | 2 ++ .../double/query.esql | 2 ++ .../float/query.esql | 2 ++ .../half_float/query.esql | 2 ++ .../integer/query.esql | 2 ++ .../long/query.esql | 2 ++ .../scaled_float/query.esql | 2 ++ .../short/query.esql | 2 ++ ...l_reduce_physical_optimization_data_driver | 4 +++ .../local_reduce_planned_data_driver | 5 ++++ .../local_reduce_planned_reduce_driver | 5 ++++ ...l_reduce_physical_optimization_data_driver | 6 ++++ .../local_reduce_planned_data_driver | 6 ++++ .../local_reduce_planned_reduce_driver | 5 ++++ ...l_reduce_physical_optimization_data_driver | 6 ++++ .../local_reduce_planned_data_driver | 6 ++++ .../local_reduce_planned_reduce_driver | 5 ++++ ...l_reduce_physical_optimization_data_driver | 25 ++++++++++++++++ .../local_reduce_planned_data_driver | 9 ++++++ .../local_reduce_planned_reduce_driver | 5 ++++ ...l_reduce_physical_optimization_data_driver | 4 +++ .../local_reduce_planned_data_driver | 5 ++++ .../local_reduce_planned_reduce_driver | 5 ++++ ...l_reduce_physical_optimization_data_driver | 4 +++ .../local_reduce_planned_data_driver | 5 ++++ .../local_reduce_planned_reduce_driver | 5 ++++ ...l_reduce_physical_optimization_data_driver | 7 +++++ ...reduce_physical_optimization_reduce_driver | 3 ++ .../local_reduce_planned_data_driver | 7 +++++ .../local_reduce_planned_reduce_driver | 3 ++ ...l_reduce_physical_optimization_data_driver | 4 +++ .../local_reduce_planned_data_driver | 5 ++++ .../local_reduce_planned_reduce_driver | 5 ++++ ...l_reduce_physical_optimization_data_driver | 17 +++++++++++ .../local_reduce_planned_data_driver | 6 ++++ .../local_reduce_planned_reduce_driver | 5 ++++ ...l_reduce_physical_optimization_data_driver | 4 +++ .../local_reduce_planned_data_driver | 5 ++++ .../local_reduce_planned_reduce_driver | 5 ++++ ...l_reduce_physical_optimization_data_driver | 4 +++ .../local_reduce_planned_data_driver | 5 ++++ .../local_reduce_planned_reduce_driver | 5 ++++ 142 files changed, 409 insertions(+), 12 deletions(-) rename x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testDrop/{ => load}/query.esql (100%) create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testDrop/nullify/query.esql rename x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testDropAndMatchingStar/{ => load}/query.esql (100%) create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testDropAndMatchingStar/nullify/query.esql rename x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testEval/{ => load}/query.esql (100%) create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testEval/nullify/query.esql rename x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testEvalAfterKeepStar/{ => load}/query.esql (100%) create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testEvalAfterKeepStar/nullify/query.esql rename x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testEvalAfterMatchingKeepWithWildcard/{ => load}/query.esql (100%) create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testEvalAfterMatchingKeepWithWildcard/nullify/query.esql rename x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testEvalAndKeep/{ => load}/query.esql (100%) create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testEvalAndKeep/nullify/query.esql rename x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testEvalCast/{ => load}/query.esql (100%) create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testEvalCast/nullify/query.esql rename x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testEvalCastInPlace/{ => load}/query.esql (100%) create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testEvalCastInPlace/nullify/query.esql rename x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testEvalReplace/{ => load}/query.esql (100%) create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testEvalReplace/nullify/query.esql rename x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testInlineStats/{ => load}/query.esql (100%) create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testInlineStats/nullify/query.esql rename x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testKeep/{ => load}/query.esql (100%) create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testKeep/nullify/query.esql rename x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testKeepAndMatchingStar/{ => load}/query.esql (100%) create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testKeepAndMatchingStar/nullify/query.esql rename x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testKeepRepeated/{ => load}/query.esql (100%) create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testKeepRepeated/nullify/query.esql rename x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testKeepThenEval/{ => load}/query.esql (100%) create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testKeepThenEval/nullify/query.esql rename x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testMultipleEval/{ => load}/query.esql (100%) create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testMultipleEval/nullify/query.esql rename x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testMvExpand/{ => load}/query.esql (100%) create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testMvExpand/nullify/query.esql rename x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testRename/{ => load}/query.esql (100%) create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testRename/nullify/query.esql rename x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testRenameEval/{ => load}/query.esql (100%) create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testRenameEval/nullify/query.esql rename x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testRenameRepeated/{ => load}/query.esql (100%) create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testRenameRepeated/nullify/query.esql rename x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testSort/{ => load}/query.esql (100%) create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testSort/nullify/query.esql rename x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testSortExpression/{ => load}/query.esql (100%) create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testSortExpression/nullify/query.esql rename x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testSortMultiple/{ => load}/query.esql (100%) create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testSortMultiple/nullify/query.esql rename x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testStatsBy/{ => load}/query.esql (100%) create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testStatsBy/nullify/query.esql rename x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testStatsCount/{ => load}/query.esql (100%) create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testStatsCount/nullify/query.esql rename x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testStatsCountWhere/{ => load}/query.esql (100%) create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testStatsCountWhere/nullify/query.esql rename x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testStatsMultiple/{ => load}/query.esql (100%) create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testStatsMultiple/nullify/query.esql rename x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testStatsMultipleCountWhere/{ => load}/query.esql (100%) create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testStatsMultipleCountWhere/nullify/query.esql rename x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testStatsSumBy/{ => load}/query.esql (100%) create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testStatsSumBy/nullify/query.esql rename x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testStatsSumByComplex/{ => load}/query.esql (100%) create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testStatsSumByComplex/nullify/query.esql rename x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testStatsSumByMultiple/{ => load}/query.esql (100%) create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testStatsSumByMultiple/nullify/query.esql rename x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testWhere/{ => load}/query.esql (100%) create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testWhere/nullify/query.esql rename x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testWhereComplex/{ => load}/query.esql (100%) create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testWhereComplex/nullify/query.esql rename x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testWhereOr/{ => load}/query.esql (100%) create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testWhereOr/nullify/query.esql create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testDateTruncBucketNotTransformToQueryAndTagsWithFork/bucket/query.esql create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testDateTruncBucketNotTransformToQueryAndTagsWithFork/date_trunc/query.esql create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testDateTruncBucketNotTransformToQueryAndTagsWithFork/round_to/query.esql create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testDateTruncBucketNotTransformToQueryAndTagsWithLookupJoin/bucket/query.esql create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testDateTruncBucketNotTransformToQueryAndTagsWithLookupJoin/date_trunc/query.esql create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testDateTruncBucketNotTransformToQueryAndTagsWithLookupJoin/round_to/query.esql create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testDateTruncBucketTransformToQueryAndTags/bucket/query.esql create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testDateTruncBucketTransformToQueryAndTags/date_trunc/query.esql create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testDateTruncBucketTransformToQueryAndTags/round_to/query.esql create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testDateTruncBucketTransformToQueryAndTagsWithEsFilter/bucket/query.esql create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testDateTruncBucketTransformToQueryAndTagsWithEsFilter/date_trunc/query.esql create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testDateTruncBucketTransformToQueryAndTagsWithEsFilter/round_to/query.esql create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testDateTruncBucketTransformToQueryAndTagsWithMultipleAggregates/bucket/query.esql create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testDateTruncBucketTransformToQueryAndTagsWithMultipleAggregates/date_trunc/query.esql create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testDateTruncBucketTransformToQueryAndTagsWithMultipleAggregates/round_to/query.esql create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testDateTruncBucketTransformToQueryAndTagsWithOtherPushdownFunctions/bucket/date_range/query.esql create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testDateTruncBucketTransformToQueryAndTagsWithOtherPushdownFunctions/bucket/keyword_equality/query.esql create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testDateTruncBucketTransformToQueryAndTagsWithOtherPushdownFunctions/bucket/keyword_match/query.esql create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testDateTruncBucketTransformToQueryAndTagsWithOtherPushdownFunctions/date_trunc/date_range/query.esql create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testDateTruncBucketTransformToQueryAndTagsWithOtherPushdownFunctions/date_trunc/keyword_equality/query.esql create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testDateTruncBucketTransformToQueryAndTagsWithOtherPushdownFunctions/date_trunc/keyword_match/query.esql create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testDateTruncBucketTransformToQueryAndTagsWithOtherPushdownFunctions/round_to/date_range/query.esql create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testDateTruncBucketTransformToQueryAndTagsWithOtherPushdownFunctions/round_to/keyword_equality/query.esql create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testDateTruncBucketTransformToQueryAndTagsWithOtherPushdownFunctions/round_to/keyword_match/query.esql create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testDateTruncBucketTransformToQueryAndTagsWithWhereInsideAggregation/bucket/query.esql create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testDateTruncBucketTransformToQueryAndTagsWithWhereInsideAggregation/date_trunc/query.esql create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testDateTruncBucketTransformToQueryAndTagsWithWhereInsideAggregation/round_to/query.esql create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testDateTruncNotTransformToQueryAndTags/date_trunc/query.esql create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testDateTruncNotTransformToQueryAndTags/round_to/query.esql create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testRoundToTransformToQueryAndTags/byte/query.esql create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testRoundToTransformToQueryAndTags/date/query.esql create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testRoundToTransformToQueryAndTags/date_nanos/query.esql create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testRoundToTransformToQueryAndTags/double/query.esql create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testRoundToTransformToQueryAndTags/float/query.esql create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testRoundToTransformToQueryAndTags/half_float/query.esql create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testRoundToTransformToQueryAndTags/integer/query.esql create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testRoundToTransformToQueryAndTags/long/query.esql create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testRoundToTransformToQueryAndTags/scaled_float/query.esql create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testRoundToTransformToQueryAndTags/short/query.esql create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testBasicTopNLateMaterialization/local_reduce_physical_optimization_data_driver create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testBasicTopNLateMaterialization/local_reduce_planned_data_driver create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testBasicTopNLateMaterialization/local_reduce_planned_reduce_driver create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testExpressionSortTopNKeepAfterSort/local_reduce_physical_optimization_data_driver create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testExpressionSortTopNKeepAfterSort/local_reduce_planned_data_driver create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testExpressionSortTopNKeepAfterSort/local_reduce_planned_reduce_driver create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testExpressionSortTopNKeepBeforeSort/local_reduce_physical_optimization_data_driver create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testExpressionSortTopNKeepBeforeSort/local_reduce_planned_data_driver create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testExpressionSortTopNKeepBeforeSort/local_reduce_planned_reduce_driver create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testLookupJoinOnDataNode/local_reduce_physical_optimization_data_driver create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testLookupJoinOnDataNode/local_reduce_planned_data_driver create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testLookupJoinOnDataNode/local_reduce_planned_reduce_driver create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testMultipleFieldSortTopN/local_reduce_physical_optimization_data_driver create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testMultipleFieldSortTopN/local_reduce_planned_data_driver create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testMultipleFieldSortTopN/local_reduce_planned_reduce_driver create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testMultipleTopN/local_reduce_physical_optimization_data_driver create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testMultipleTopN/local_reduce_planned_data_driver create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testMultipleTopN/local_reduce_planned_reduce_driver create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testMvExpandBeforeTopN/local_reduce_physical_optimization_data_driver create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testMvExpandBeforeTopN/local_reduce_physical_optimization_reduce_driver create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testMvExpandBeforeTopN/local_reduce_planned_data_driver create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testMvExpandBeforeTopN/local_reduce_planned_reduce_driver create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testPushedDownTopN/local_reduce_physical_optimization_data_driver create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testPushedDownTopN/local_reduce_planned_data_driver create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testPushedDownTopN/local_reduce_planned_reduce_driver create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testSomeFieldsNeededBeforeLateMaterialization/local_reduce_physical_optimization_data_driver create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testSomeFieldsNeededBeforeLateMaterialization/local_reduce_planned_data_driver create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testSomeFieldsNeededBeforeLateMaterialization/local_reduce_planned_reduce_driver create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testTopNThenStats/local_reduce_physical_optimization_data_driver create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testTopNThenStats/local_reduce_planned_data_driver create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testTopNThenStats/local_reduce_planned_reduce_driver create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testTopNWithMissingSortField/local_reduce_physical_optimization_data_driver create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testTopNWithMissingSortField/local_reduce_planned_data_driver create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testTopNWithMissingSortField/local_reduce_planned_reduce_driver diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/optimizer/GoldenTestCase.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/optimizer/GoldenTestCase.java index 95e2c140c197d..9044b2e9918dd 100644 --- a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/optimizer/GoldenTestCase.java +++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/optimizer/GoldenTestCase.java @@ -201,8 +201,8 @@ private void doTest() { private List> doTests() throws IOException { var statement = EsqlParser.INSTANCE.createStatement(esqlQuery); var parsedPlan = statement.plan(); - Files.createDirectories(PathUtils.get(basePath.toString(), testName)); - Files.writeString(PathUtils.get(basePath.toString(), testName, "query.esql"), esqlQuery); + Files.createDirectories(PathUtils.get(basePath.toString(), pathArray(0))); + Files.writeString(outputPath("query.esql"), esqlQuery); var analyzer = new Analyzer( new AnalyzerContext( EsqlTestUtils.TEST_CFG, @@ -303,6 +303,14 @@ private List> doTests() throws IOException { return result; } + // FIXME(gal, NOCOMMIT) Not a fan of this signature + private String[] pathArray(int extraElements) { + var paths = new String[nestedPath.length + 1 + extraElements]; + paths[0] = testName; + System.arraycopy(nestedPath, 0, paths, 1, nestedPath.length); + return paths; + } + private enum TestResult { SUCCESS, FAILURE, @@ -335,7 +343,7 @@ private List> addDualPlanResult( } private > TestResult verifyOrWrite(T plan, Stage stage) throws IOException { - return verifyOrWrite(plan, outputPath(stage)); + return verifyOrWrite(plan, stageOutputPath(stage)); } private > TestResult verifyOrWrite(T plan, Path outputFile) throws IOException { @@ -352,15 +360,17 @@ private > TestResult verifyOrWrite(T plan, Path outputFil } } - private Path outputPath(Stage stage) { - return outputPath(((SingleFileOutput) stage.fileOutput).output()); + private Path stageOutputPath(Stage stage) { + return stageOutputPath(((SingleFileOutput) stage.fileOutput).output()); } - private Path outputPath(String stageName) { - var paths = new String[nestedPath.length + 2]; - paths[0] = testName; - System.arraycopy(nestedPath, 0, paths, 1, nestedPath.length); - paths[paths.length - 1] = Strings.format("%s.expected", stageName); + private Path stageOutputPath(String stageName) { + return outputPath(stageName + ".expected"); + } + + private Path outputPath(String fileName) { + var paths = pathArray(1); + paths[paths.length - 1] = fileName; return PathUtils.get(basePath.toString(), paths); } diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testDrop/query.esql b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testDrop/load/query.esql similarity index 100% rename from x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testDrop/query.esql rename to x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testDrop/load/query.esql diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testDrop/nullify/query.esql b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testDrop/nullify/query.esql new file mode 100644 index 0000000000000..deb3bd1826afc --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testDrop/nullify/query.esql @@ -0,0 +1,2 @@ +SET unmapped_fields="nullify"; FROM employees +| DROP does_not_exist_field, emp_no diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testDropAndMatchingStar/query.esql b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testDropAndMatchingStar/load/query.esql similarity index 100% rename from x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testDropAndMatchingStar/query.esql rename to x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testDropAndMatchingStar/load/query.esql diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testDropAndMatchingStar/nullify/query.esql b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testDropAndMatchingStar/nullify/query.esql new file mode 100644 index 0000000000000..7064d202cbedc --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testDropAndMatchingStar/nullify/query.esql @@ -0,0 +1,2 @@ +SET unmapped_fields="nullify"; FROM employees +| DROP emp_*, does_not_exist_field diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testEval/query.esql b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testEval/load/query.esql similarity index 100% rename from x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testEval/query.esql rename to x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testEval/load/query.esql diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testEval/nullify/query.esql b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testEval/nullify/query.esql new file mode 100644 index 0000000000000..8a1085423e2ed --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testEval/nullify/query.esql @@ -0,0 +1,2 @@ +SET unmapped_fields="nullify"; FROM employees +| EVAL x = does_not_exist_field::DOUBLE + 1 diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testEvalAfterKeepStar/query.esql b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testEvalAfterKeepStar/load/query.esql similarity index 100% rename from x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testEvalAfterKeepStar/query.esql rename to x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testEvalAfterKeepStar/load/query.esql diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testEvalAfterKeepStar/nullify/query.esql b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testEvalAfterKeepStar/nullify/query.esql new file mode 100644 index 0000000000000..6f6ce85c55b54 --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testEvalAfterKeepStar/nullify/query.esql @@ -0,0 +1,4 @@ +SET unmapped_fields="nullify"; FROM employees +| KEEP * +| EVAL x = emp_no + 1 +| EVAL y = does_not_exist_field::DOUBLE + 2 diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testEvalAfterMatchingKeepWithWildcard/query.esql b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testEvalAfterMatchingKeepWithWildcard/load/query.esql similarity index 100% rename from x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testEvalAfterMatchingKeepWithWildcard/query.esql rename to x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testEvalAfterMatchingKeepWithWildcard/load/query.esql diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testEvalAfterMatchingKeepWithWildcard/nullify/query.esql b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testEvalAfterMatchingKeepWithWildcard/nullify/query.esql new file mode 100644 index 0000000000000..b96afd6be3bc8 --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testEvalAfterMatchingKeepWithWildcard/nullify/query.esql @@ -0,0 +1,4 @@ +SET unmapped_fields="nullify"; FROM employees +| KEEP emp_no, * +| EVAL x = emp_no + 1 +| EVAL y = emp_does_not_exist_field::DOUBLE + 2 diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testEvalAndKeep/query.esql b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testEvalAndKeep/load/query.esql similarity index 100% rename from x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testEvalAndKeep/query.esql rename to x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testEvalAndKeep/load/query.esql diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testEvalAndKeep/nullify/query.esql b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testEvalAndKeep/nullify/query.esql new file mode 100644 index 0000000000000..b835bd71bd018 --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testEvalAndKeep/nullify/query.esql @@ -0,0 +1,3 @@ +SET unmapped_fields="nullify"; FROM employees +| EVAL x = does_not_exist_field1::INTEGER + 42 +| KEEP does_not_exist_field1, does_not_exist_field2 diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testEvalCast/query.esql b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testEvalCast/load/query.esql similarity index 100% rename from x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testEvalCast/query.esql rename to x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testEvalCast/load/query.esql diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testEvalCast/nullify/query.esql b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testEvalCast/nullify/query.esql new file mode 100644 index 0000000000000..645643aa1255c --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testEvalCast/nullify/query.esql @@ -0,0 +1,2 @@ +SET unmapped_fields="nullify"; FROM employees +| EVAL x = does_not_exist_field::LONG diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testEvalCastInPlace/query.esql b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testEvalCastInPlace/load/query.esql similarity index 100% rename from x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testEvalCastInPlace/query.esql rename to x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testEvalCastInPlace/load/query.esql diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testEvalCastInPlace/nullify/query.esql b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testEvalCastInPlace/nullify/query.esql new file mode 100644 index 0000000000000..91f24cce1fb92 --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testEvalCastInPlace/nullify/query.esql @@ -0,0 +1,2 @@ +SET unmapped_fields="nullify"; FROM employees +| EVAL does_not_exist_field::LONG diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testEvalReplace/query.esql b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testEvalReplace/load/query.esql similarity index 100% rename from x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testEvalReplace/query.esql rename to x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testEvalReplace/load/query.esql diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testEvalReplace/nullify/query.esql b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testEvalReplace/nullify/query.esql new file mode 100644 index 0000000000000..241e39491fa9a --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testEvalReplace/nullify/query.esql @@ -0,0 +1,3 @@ +SET unmapped_fields="nullify"; FROM employees +| EVAL x = does_not_exist_field::DOUBLE + 1 +| EVAL does_not_exist_field = 42 diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testInlineStats/query.esql b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testInlineStats/load/query.esql similarity index 100% rename from x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testInlineStats/query.esql rename to x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testInlineStats/load/query.esql diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testInlineStats/nullify/query.esql b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testInlineStats/nullify/query.esql new file mode 100644 index 0000000000000..314e176a1843d --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testInlineStats/nullify/query.esql @@ -0,0 +1,2 @@ +SET unmapped_fields="nullify"; FROM employees +| INLINE STATS s = SUM(does_not_exist1::DOUBLE), c = COUNT(*) BY does_not_exist2, emp_no diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testKeep/query.esql b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testKeep/load/query.esql similarity index 100% rename from x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testKeep/query.esql rename to x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testKeep/load/query.esql diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testKeep/nullify/query.esql b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testKeep/nullify/query.esql new file mode 100644 index 0000000000000..aa0cb37ad9b24 --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testKeep/nullify/query.esql @@ -0,0 +1,2 @@ +SET unmapped_fields="nullify"; FROM employees +| KEEP does_not_exist_field diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testKeepAndMatchingStar/query.esql b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testKeepAndMatchingStar/load/query.esql similarity index 100% rename from x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testKeepAndMatchingStar/query.esql rename to x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testKeepAndMatchingStar/load/query.esql diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testKeepAndMatchingStar/nullify/query.esql b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testKeepAndMatchingStar/nullify/query.esql new file mode 100644 index 0000000000000..0a9ada347fc6a --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testKeepAndMatchingStar/nullify/query.esql @@ -0,0 +1,2 @@ +SET unmapped_fields="nullify"; FROM employees +| KEEP emp_*, does_not_exist_field diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testKeepRepeated/query.esql b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testKeepRepeated/load/query.esql similarity index 100% rename from x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testKeepRepeated/query.esql rename to x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testKeepRepeated/load/query.esql diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testKeepRepeated/nullify/query.esql b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testKeepRepeated/nullify/query.esql new file mode 100644 index 0000000000000..cef77352827e4 --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testKeepRepeated/nullify/query.esql @@ -0,0 +1,2 @@ +SET unmapped_fields="nullify"; FROM employees +| KEEP does_not_exist_field, does_not_exist_field diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testKeepThenEval/query.esql b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testKeepThenEval/load/query.esql similarity index 100% rename from x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testKeepThenEval/query.esql rename to x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testKeepThenEval/load/query.esql diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testKeepThenEval/nullify/query.esql b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testKeepThenEval/nullify/query.esql new file mode 100644 index 0000000000000..4337b35ba4b2e --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testKeepThenEval/nullify/query.esql @@ -0,0 +1,3 @@ +SET unmapped_fields="nullify"; FROM employees +| KEEP does_not_exist_field +| EVAL does_not_exist_field = 42 diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testMultipleEval/query.esql b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testMultipleEval/load/query.esql similarity index 100% rename from x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testMultipleEval/query.esql rename to x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testMultipleEval/load/query.esql diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testMultipleEval/nullify/query.esql b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testMultipleEval/nullify/query.esql new file mode 100644 index 0000000000000..1c122d2bc9737 --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testMultipleEval/nullify/query.esql @@ -0,0 +1,4 @@ +SET unmapped_fields="nullify"; FROM employees +| EVAL a = 1 +| EVAL x = a + b::DOUBLE +| EVAL y = b::DOUBLE + c::DOUBLE diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testMvExpand/query.esql b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testMvExpand/load/query.esql similarity index 100% rename from x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testMvExpand/query.esql rename to x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testMvExpand/load/query.esql diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testMvExpand/nullify/query.esql b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testMvExpand/nullify/query.esql new file mode 100644 index 0000000000000..4028dd22bad3d --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testMvExpand/nullify/query.esql @@ -0,0 +1,2 @@ +SET unmapped_fields="nullify"; FROM employees +| MV_EXPAND does_not_exist diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testRename/query.esql b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testRename/load/query.esql similarity index 100% rename from x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testRename/query.esql rename to x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testRename/load/query.esql diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testRename/nullify/query.esql b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testRename/nullify/query.esql new file mode 100644 index 0000000000000..5b99834da2a5a --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testRename/nullify/query.esql @@ -0,0 +1,2 @@ +SET unmapped_fields="nullify"; FROM employees +| RENAME does_not_exist_field AS now_it_does, emp_no AS employee_number diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testRenameEval/query.esql b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testRenameEval/load/query.esql similarity index 100% rename from x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testRenameEval/query.esql rename to x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testRenameEval/load/query.esql diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testRenameEval/nullify/query.esql b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testRenameEval/nullify/query.esql new file mode 100644 index 0000000000000..7475a95153a3a --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testRenameEval/nullify/query.esql @@ -0,0 +1,3 @@ +SET unmapped_fields="nullify"; FROM employees +| RENAME emp_no AS employee_number +| EVAL x = does_not_exist::DOUBLE + 1 diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testRenameRepeated/query.esql b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testRenameRepeated/load/query.esql similarity index 100% rename from x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testRenameRepeated/query.esql rename to x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testRenameRepeated/load/query.esql diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testRenameRepeated/nullify/query.esql b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testRenameRepeated/nullify/query.esql new file mode 100644 index 0000000000000..db1febeb315ad --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testRenameRepeated/nullify/query.esql @@ -0,0 +1,2 @@ +SET unmapped_fields="nullify"; FROM employees +| RENAME does_not_exist_field AS now_it_does, neither_does_this AS now_it_does, emp_no AS employee_number diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testSort/query.esql b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testSort/load/query.esql similarity index 100% rename from x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testSort/query.esql rename to x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testSort/load/query.esql diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testSort/nullify/query.esql b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testSort/nullify/query.esql new file mode 100644 index 0000000000000..e2e03a32e90b3 --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testSort/nullify/query.esql @@ -0,0 +1,2 @@ +SET unmapped_fields="nullify"; FROM employees +| SORT does_not_exist ASC diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testSortExpression/query.esql b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testSortExpression/load/query.esql similarity index 100% rename from x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testSortExpression/query.esql rename to x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testSortExpression/load/query.esql diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testSortExpression/nullify/query.esql b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testSortExpression/nullify/query.esql new file mode 100644 index 0000000000000..4f3e51522c415 --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testSortExpression/nullify/query.esql @@ -0,0 +1,2 @@ +SET unmapped_fields="nullify"; FROM employees +| SORT does_not_exist::LONG + 1 diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testSortMultiple/query.esql b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testSortMultiple/load/query.esql similarity index 100% rename from x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testSortMultiple/query.esql rename to x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testSortMultiple/load/query.esql diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testSortMultiple/nullify/query.esql b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testSortMultiple/nullify/query.esql new file mode 100644 index 0000000000000..7b1dadb3f7ed2 --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testSortMultiple/nullify/query.esql @@ -0,0 +1,2 @@ +SET unmapped_fields="nullify"; FROM employees +| SORT does_not_exist1::LONG + 1, does_not_exist2 DESC, emp_no ASC diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testStatsBy/query.esql b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testStatsBy/load/query.esql similarity index 100% rename from x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testStatsBy/query.esql rename to x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testStatsBy/load/query.esql diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testStatsBy/nullify/query.esql b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testStatsBy/nullify/query.esql new file mode 100644 index 0000000000000..b4ef8dbc01160 --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testStatsBy/nullify/query.esql @@ -0,0 +1,2 @@ +SET unmapped_fields="nullify"; FROM employees +| STATS BY does_not_exist_field diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testStatsCount/query.esql b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testStatsCount/load/query.esql similarity index 100% rename from x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testStatsCount/query.esql rename to x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testStatsCount/load/query.esql diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testStatsCount/nullify/query.esql b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testStatsCount/nullify/query.esql new file mode 100644 index 0000000000000..e8fb3888650cf --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testStatsCount/nullify/query.esql @@ -0,0 +1,2 @@ +SET unmapped_fields="nullify"; FROM employees +| STATS cnt = COUNT(does_not_exist_field) diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testStatsCountWhere/query.esql b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testStatsCountWhere/load/query.esql similarity index 100% rename from x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testStatsCountWhere/query.esql rename to x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testStatsCountWhere/load/query.esql diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testStatsCountWhere/nullify/query.esql b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testStatsCountWhere/nullify/query.esql new file mode 100644 index 0000000000000..7c028cc985242 --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testStatsCountWhere/nullify/query.esql @@ -0,0 +1,2 @@ +SET unmapped_fields="nullify"; FROM employees +| STATS c = COUNT(*) WHERE does_not_exist1::LONG > 0 diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testStatsMultiple/query.esql b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testStatsMultiple/load/query.esql similarity index 100% rename from x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testStatsMultiple/query.esql rename to x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testStatsMultiple/load/query.esql diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testStatsMultiple/nullify/query.esql b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testStatsMultiple/nullify/query.esql new file mode 100644 index 0000000000000..6887849dbdcd4 --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testStatsMultiple/nullify/query.esql @@ -0,0 +1,2 @@ +SET unmapped_fields="nullify"; FROM employees +| STATS s = SUM(does_not_exist1::DOUBLE), c = COUNT(*) BY does_not_exist2, emp_no diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testStatsMultipleCountWhere/load/analysis.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testStatsMultipleCountWhere/load/analysis.expected index ae6b7c030b624..7a9858e13cc71 100644 --- a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testStatsMultipleCountWhere/load/analysis.expected +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testStatsMultipleCountWhere/load/analysis.expected @@ -1,4 +1,4 @@ Limit[1000[INTEGER],false,false] \_Aggregate[[],[FilteredExpression[COUNT(*[KEYWORD],true[BOOLEAN],PT0S[TIME_DURATION]),TOLONG(does_not_exist1{f}#0) > 0[INTEGER] OR emp_no{f}#1 -523 > 0[INTEGER] OR TOLONG(does_not_exist2{f}#2) < 100[INTEGER]] AS c1#3, FilteredExpression[COUNT(*[KEYWORD],true[BOOLEAN],PT0S[TIME_DURATION]),ISNULL(does_not_exist3{f}#4)] AS c2#5]] +5 > 0[INTEGER] OR TOLONG(does_not_exist2{f}#2) < 100[INTEGER]] AS c1#3, FilteredExpression[COUNT(*[KEYWORD],true[BOOLEAN],PT0S[TIME_DURATION]),ISNULL(does_not_exist3{f}#4)] AS c2#5]] \_EsRelation[employees][avg_worked_seconds{f}#6, birth_date{f}#7, emp_no{f}#8, first_name{f}#9, gender{f}#10, height{f}#11, height.float{f}#12, height.half_float{f}#13, height.scaled_float{f}#14, hire_date{f}#15, is_rehired{f}#16, job_positions{f}#17, languages{f}#18, languages.byte{f}#19, languages.long{f}#20, languages.short{f}#21, last_name{f}#22, salary{f}#23, salary_change{f}#24, salary_change.int{f}#25, salary_change.keyword{f}#26, salary_change.long{f}#27, still_hired{f}#28, does_not_exist1{f}#0, does_not_exist2{f}#2, does_not_exist3{f}#4] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testStatsMultipleCountWhere/query.esql b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testStatsMultipleCountWhere/load/query.esql similarity index 100% rename from x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testStatsMultipleCountWhere/query.esql rename to x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testStatsMultipleCountWhere/load/query.esql diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testStatsMultipleCountWhere/nullify/analysis.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testStatsMultipleCountWhere/nullify/analysis.expected index ed20d1ae39bbe..1b1b5a8f9580e 100644 --- a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testStatsMultipleCountWhere/nullify/analysis.expected +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testStatsMultipleCountWhere/nullify/analysis.expected @@ -1,5 +1,5 @@ Limit[1000[INTEGER],false,false] \_Aggregate[[],[FilteredExpression[COUNT(*[KEYWORD],true[BOOLEAN],PT0S[TIME_DURATION]),TOLONG(does_not_exist1{r}#0) > 0[INTEGER] OR emp_no{f}#1 -485 > 0[INTEGER] OR TOLONG(does_not_exist2{r}#2) < 100[INTEGER]] AS c1#3, FilteredExpression[COUNT(*[KEYWORD],true[BOOLEAN],PT0S[TIME_DURATION]),ISNULL(does_not_exist3{r}#4)] AS c2#5]] +7 > 0[INTEGER] OR TOLONG(does_not_exist2{r}#2) < 100[INTEGER]] AS c1#3, FilteredExpression[COUNT(*[KEYWORD],true[BOOLEAN],PT0S[TIME_DURATION]),ISNULL(does_not_exist3{r}#4)] AS c2#5]] \_Eval[[null[NULL] AS does_not_exist1#0, null[NULL] AS does_not_exist2#2, null[NULL] AS does_not_exist3#4]] \_EsRelation[employees][avg_worked_seconds{f}#6, birth_date{f}#7, emp_no{f}#8, first_name{f}#9, gender{f}#10, height{f}#11, height.float{f}#12, height.half_float{f}#13, height.scaled_float{f}#14, hire_date{f}#15, is_rehired{f}#16, job_positions{f}#17, languages{f}#18, languages.byte{f}#19, languages.long{f}#20, languages.short{f}#21, last_name{f}#22, salary{f}#23, salary_change{f}#24, salary_change.int{f}#25, salary_change.keyword{f}#26, salary_change.long{f}#27, still_hired{f}#28] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testStatsMultipleCountWhere/nullify/query.esql b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testStatsMultipleCountWhere/nullify/query.esql new file mode 100644 index 0000000000000..6f052b1a79cb2 --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testStatsMultipleCountWhere/nullify/query.esql @@ -0,0 +1,3 @@ +SET unmapped_fields="nullify"; FROM employees +| STATS c1 = COUNT(*) WHERE does_not_exist1::LONG > 0 OR emp_no > 0 OR does_not_exist2::LONG < 100, + c2 = COUNT(*) WHERE does_not_exist3 IS NULL diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testStatsSumBy/query.esql b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testStatsSumBy/load/query.esql similarity index 100% rename from x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testStatsSumBy/query.esql rename to x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testStatsSumBy/load/query.esql diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testStatsSumBy/nullify/query.esql b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testStatsSumBy/nullify/query.esql new file mode 100644 index 0000000000000..29d53f6beba5b --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testStatsSumBy/nullify/query.esql @@ -0,0 +1,2 @@ +SET unmapped_fields="nullify"; FROM employees +| STATS s = SUM(does_not_exist1::DOUBLE) BY does_not_exist2 diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testStatsSumByComplex/query.esql b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testStatsSumByComplex/load/query.esql similarity index 100% rename from x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testStatsSumByComplex/query.esql rename to x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testStatsSumByComplex/load/query.esql diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testStatsSumByComplex/nullify/query.esql b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testStatsSumByComplex/nullify/query.esql new file mode 100644 index 0000000000000..d4152fb7a5e2f --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testStatsSumByComplex/nullify/query.esql @@ -0,0 +1,2 @@ +SET unmapped_fields="nullify"; FROM employees +| STATS sum = SUM(does_not_exist1::DOUBLE) + s0 + s1 BY s0 = does_not_exist2::DOUBLE + does_not_exist3::DOUBLE, s1 = emp_no diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testStatsSumByMultiple/query.esql b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testStatsSumByMultiple/load/query.esql similarity index 100% rename from x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testStatsSumByMultiple/query.esql rename to x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testStatsSumByMultiple/load/query.esql diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testStatsSumByMultiple/nullify/query.esql b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testStatsSumByMultiple/nullify/query.esql new file mode 100644 index 0000000000000..c9f8f55bbee50 --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testStatsSumByMultiple/nullify/query.esql @@ -0,0 +1,2 @@ +SET unmapped_fields="nullify"; FROM employees +| STATS s = SUM(does_not_exist1::DOUBLE) + d2 BY d2 = does_not_exist2::DOUBLE, emp_no diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testWhere/query.esql b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testWhere/load/query.esql similarity index 100% rename from x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testWhere/query.esql rename to x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testWhere/load/query.esql diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testWhere/nullify/query.esql b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testWhere/nullify/query.esql new file mode 100644 index 0000000000000..3d9a2e14cc93c --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testWhere/nullify/query.esql @@ -0,0 +1,2 @@ +SET unmapped_fields="nullify"; FROM employees +| WHERE does_not_exist::LONG > 0 diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testWhereComplex/query.esql b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testWhereComplex/load/query.esql similarity index 100% rename from x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testWhereComplex/query.esql rename to x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testWhereComplex/load/query.esql diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testWhereComplex/nullify/query.esql b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testWhereComplex/nullify/query.esql new file mode 100644 index 0000000000000..6da7b544c73b8 --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testWhereComplex/nullify/query.esql @@ -0,0 +1,2 @@ +SET unmapped_fields="nullify"; FROM employees +| WHERE does_not_exist1::LONG > 0 OR emp_no > 0 AND does_not_exist2::LONG < 100 diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testWhereOr/query.esql b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testWhereOr/load/query.esql similarity index 100% rename from x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testWhereOr/query.esql rename to x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testWhereOr/load/query.esql diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testWhereOr/nullify/query.esql b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testWhereOr/nullify/query.esql new file mode 100644 index 0000000000000..6a4dcd6d7226f --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testWhereOr/nullify/query.esql @@ -0,0 +1,2 @@ +SET unmapped_fields="nullify"; FROM employees +| WHERE does_not_exist::LONG > 0 OR emp_no > 0 diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testDateTruncBucketNotTransformToQueryAndTagsWithFork/bucket/query.esql b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testDateTruncBucketNotTransformToQueryAndTagsWithFork/bucket/query.esql new file mode 100644 index 0000000000000..b615c9c44e290 --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testDateTruncBucketNotTransformToQueryAndTagsWithFork/bucket/query.esql @@ -0,0 +1,4 @@ +from all_types +| fork (where integer > 100) +(where keyword : "keyword") +| stats count(*) by x = bucket(date, 1 day) diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testDateTruncBucketNotTransformToQueryAndTagsWithFork/date_trunc/query.esql b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testDateTruncBucketNotTransformToQueryAndTagsWithFork/date_trunc/query.esql new file mode 100644 index 0000000000000..58c5f6728342c --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testDateTruncBucketNotTransformToQueryAndTagsWithFork/date_trunc/query.esql @@ -0,0 +1,4 @@ +from all_types +| fork (where integer > 100) +(where keyword : "keyword") +| stats count(*) by x = date_trunc(1 day, date) diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testDateTruncBucketNotTransformToQueryAndTagsWithFork/round_to/query.esql b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testDateTruncBucketNotTransformToQueryAndTagsWithFork/round_to/query.esql new file mode 100644 index 0000000000000..c8f08b2e6dd38 --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testDateTruncBucketNotTransformToQueryAndTagsWithFork/round_to/query.esql @@ -0,0 +1,4 @@ +from all_types +| fork (where integer > 100) +(where keyword : "keyword") +| stats count(*) by x = round_to(date, "2023-10-20", "2023-10-21", "2023-10-22", "2023-10-23") diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testDateTruncBucketNotTransformToQueryAndTagsWithLookupJoin/bucket/query.esql b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testDateTruncBucketNotTransformToQueryAndTagsWithLookupJoin/bucket/query.esql new file mode 100644 index 0000000000000..f24a6518c3f51 --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testDateTruncBucketNotTransformToQueryAndTagsWithLookupJoin/bucket/query.esql @@ -0,0 +1,4 @@ +from all_types +| rename integer as language_code +| lookup join languages_lookup on language_code +| stats count(*) by x = bucket(date, 1 day) diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testDateTruncBucketNotTransformToQueryAndTagsWithLookupJoin/date_trunc/query.esql b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testDateTruncBucketNotTransformToQueryAndTagsWithLookupJoin/date_trunc/query.esql new file mode 100644 index 0000000000000..74629dcb51051 --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testDateTruncBucketNotTransformToQueryAndTagsWithLookupJoin/date_trunc/query.esql @@ -0,0 +1,4 @@ +from all_types +| rename integer as language_code +| lookup join languages_lookup on language_code +| stats count(*) by x = date_trunc(1 day, date) diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testDateTruncBucketNotTransformToQueryAndTagsWithLookupJoin/round_to/query.esql b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testDateTruncBucketNotTransformToQueryAndTagsWithLookupJoin/round_to/query.esql new file mode 100644 index 0000000000000..7472b3a4d943e --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testDateTruncBucketNotTransformToQueryAndTagsWithLookupJoin/round_to/query.esql @@ -0,0 +1,4 @@ +from all_types +| rename integer as language_code +| lookup join languages_lookup on language_code +| stats count(*) by x = round_to(date, "2023-10-20", "2023-10-21", "2023-10-22", "2023-10-23") diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testDateTruncBucketTransformToQueryAndTags/bucket/query.esql b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testDateTruncBucketTransformToQueryAndTags/bucket/query.esql new file mode 100644 index 0000000000000..22fca42d878fd --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testDateTruncBucketTransformToQueryAndTags/bucket/query.esql @@ -0,0 +1,2 @@ +from all_types +| stats count(*) by x = bucket(date, 1 day) diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testDateTruncBucketTransformToQueryAndTags/date_trunc/query.esql b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testDateTruncBucketTransformToQueryAndTags/date_trunc/query.esql new file mode 100644 index 0000000000000..fa1300117c2a8 --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testDateTruncBucketTransformToQueryAndTags/date_trunc/query.esql @@ -0,0 +1,2 @@ +from all_types +| stats count(*) by x = date_trunc(1 day, date) diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testDateTruncBucketTransformToQueryAndTags/round_to/query.esql b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testDateTruncBucketTransformToQueryAndTags/round_to/query.esql new file mode 100644 index 0000000000000..46e5cd746c53f --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testDateTruncBucketTransformToQueryAndTags/round_to/query.esql @@ -0,0 +1,2 @@ +from all_types +| stats count(*) by x = round_to(date, "2023-10-20", "2023-10-21", "2023-10-22", "2023-10-23") diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testDateTruncBucketTransformToQueryAndTagsWithEsFilter/bucket/query.esql b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testDateTruncBucketTransformToQueryAndTagsWithEsFilter/bucket/query.esql new file mode 100644 index 0000000000000..22fca42d878fd --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testDateTruncBucketTransformToQueryAndTagsWithEsFilter/bucket/query.esql @@ -0,0 +1,2 @@ +from all_types +| stats count(*) by x = bucket(date, 1 day) diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testDateTruncBucketTransformToQueryAndTagsWithEsFilter/date_trunc/query.esql b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testDateTruncBucketTransformToQueryAndTagsWithEsFilter/date_trunc/query.esql new file mode 100644 index 0000000000000..fa1300117c2a8 --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testDateTruncBucketTransformToQueryAndTagsWithEsFilter/date_trunc/query.esql @@ -0,0 +1,2 @@ +from all_types +| stats count(*) by x = date_trunc(1 day, date) diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testDateTruncBucketTransformToQueryAndTagsWithEsFilter/round_to/query.esql b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testDateTruncBucketTransformToQueryAndTagsWithEsFilter/round_to/query.esql new file mode 100644 index 0000000000000..46e5cd746c53f --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testDateTruncBucketTransformToQueryAndTagsWithEsFilter/round_to/query.esql @@ -0,0 +1,2 @@ +from all_types +| stats count(*) by x = round_to(date, "2023-10-20", "2023-10-21", "2023-10-22", "2023-10-23") diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testDateTruncBucketTransformToQueryAndTagsWithMultipleAggregates/bucket/query.esql b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testDateTruncBucketTransformToQueryAndTagsWithMultipleAggregates/bucket/query.esql new file mode 100644 index 0000000000000..54b417415ee19 --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testDateTruncBucketTransformToQueryAndTagsWithMultipleAggregates/bucket/query.esql @@ -0,0 +1,2 @@ +from all_types +| stats sum(long), count(*) by x = bucket(date, 1 day) diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testDateTruncBucketTransformToQueryAndTagsWithMultipleAggregates/date_trunc/query.esql b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testDateTruncBucketTransformToQueryAndTagsWithMultipleAggregates/date_trunc/query.esql new file mode 100644 index 0000000000000..c9af83d6cbaac --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testDateTruncBucketTransformToQueryAndTagsWithMultipleAggregates/date_trunc/query.esql @@ -0,0 +1,2 @@ +from all_types +| stats sum(long), count(*) by x = date_trunc(1 day, date) diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testDateTruncBucketTransformToQueryAndTagsWithMultipleAggregates/round_to/query.esql b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testDateTruncBucketTransformToQueryAndTagsWithMultipleAggregates/round_to/query.esql new file mode 100644 index 0000000000000..48b94551ef462 --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testDateTruncBucketTransformToQueryAndTagsWithMultipleAggregates/round_to/query.esql @@ -0,0 +1,2 @@ +from all_types +| stats sum(long), count(*) by x = round_to(date, "2023-10-20", "2023-10-21", "2023-10-22", "2023-10-23") diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testDateTruncBucketTransformToQueryAndTagsWithOtherPushdownFunctions/bucket/date_range/query.esql b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testDateTruncBucketTransformToQueryAndTagsWithOtherPushdownFunctions/bucket/date_range/query.esql new file mode 100644 index 0000000000000..d57165bff1599 --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testDateTruncBucketTransformToQueryAndTagsWithOtherPushdownFunctions/bucket/date_range/query.esql @@ -0,0 +1,3 @@ +from all_types +| where date >= "2023-10-19" and date <= "2023-10-24" +| stats count(*) by x = bucket(date, 1 day) diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testDateTruncBucketTransformToQueryAndTagsWithOtherPushdownFunctions/bucket/keyword_equality/query.esql b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testDateTruncBucketTransformToQueryAndTagsWithOtherPushdownFunctions/bucket/keyword_equality/query.esql new file mode 100644 index 0000000000000..b6ffb3562cf48 --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testDateTruncBucketTransformToQueryAndTagsWithOtherPushdownFunctions/bucket/keyword_equality/query.esql @@ -0,0 +1,3 @@ +from all_types +| where keyword == "keyword" +| stats count(*) by x = bucket(date, 1 day) diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testDateTruncBucketTransformToQueryAndTagsWithOtherPushdownFunctions/bucket/keyword_match/query.esql b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testDateTruncBucketTransformToQueryAndTagsWithOtherPushdownFunctions/bucket/keyword_match/query.esql new file mode 100644 index 0000000000000..1b177e943af0f --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testDateTruncBucketTransformToQueryAndTagsWithOtherPushdownFunctions/bucket/keyword_match/query.esql @@ -0,0 +1,3 @@ +from all_types +| where keyword : "keyword" +| stats count(*) by x = bucket(date, 1 day) diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testDateTruncBucketTransformToQueryAndTagsWithOtherPushdownFunctions/date_trunc/date_range/query.esql b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testDateTruncBucketTransformToQueryAndTagsWithOtherPushdownFunctions/date_trunc/date_range/query.esql new file mode 100644 index 0000000000000..c6afebcab13d7 --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testDateTruncBucketTransformToQueryAndTagsWithOtherPushdownFunctions/date_trunc/date_range/query.esql @@ -0,0 +1,3 @@ +from all_types +| where date >= "2023-10-19" and date <= "2023-10-24" +| stats count(*) by x = date_trunc(1 day, date) diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testDateTruncBucketTransformToQueryAndTagsWithOtherPushdownFunctions/date_trunc/keyword_equality/query.esql b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testDateTruncBucketTransformToQueryAndTagsWithOtherPushdownFunctions/date_trunc/keyword_equality/query.esql new file mode 100644 index 0000000000000..031813404bc12 --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testDateTruncBucketTransformToQueryAndTagsWithOtherPushdownFunctions/date_trunc/keyword_equality/query.esql @@ -0,0 +1,3 @@ +from all_types +| where keyword == "keyword" +| stats count(*) by x = date_trunc(1 day, date) diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testDateTruncBucketTransformToQueryAndTagsWithOtherPushdownFunctions/date_trunc/keyword_match/query.esql b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testDateTruncBucketTransformToQueryAndTagsWithOtherPushdownFunctions/date_trunc/keyword_match/query.esql new file mode 100644 index 0000000000000..3c3cbc238870b --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testDateTruncBucketTransformToQueryAndTagsWithOtherPushdownFunctions/date_trunc/keyword_match/query.esql @@ -0,0 +1,3 @@ +from all_types +| where keyword : "keyword" +| stats count(*) by x = date_trunc(1 day, date) diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testDateTruncBucketTransformToQueryAndTagsWithOtherPushdownFunctions/round_to/date_range/query.esql b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testDateTruncBucketTransformToQueryAndTagsWithOtherPushdownFunctions/round_to/date_range/query.esql new file mode 100644 index 0000000000000..c56287a3dee3f --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testDateTruncBucketTransformToQueryAndTagsWithOtherPushdownFunctions/round_to/date_range/query.esql @@ -0,0 +1,3 @@ +from all_types +| where date >= "2023-10-19" and date <= "2023-10-24" +| stats count(*) by x = round_to(date, "2023-10-20", "2023-10-21", "2023-10-22", "2023-10-23") diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testDateTruncBucketTransformToQueryAndTagsWithOtherPushdownFunctions/round_to/keyword_equality/query.esql b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testDateTruncBucketTransformToQueryAndTagsWithOtherPushdownFunctions/round_to/keyword_equality/query.esql new file mode 100644 index 0000000000000..0e2c6e873cf48 --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testDateTruncBucketTransformToQueryAndTagsWithOtherPushdownFunctions/round_to/keyword_equality/query.esql @@ -0,0 +1,3 @@ +from all_types +| where keyword == "keyword" +| stats count(*) by x = round_to(date, "2023-10-20", "2023-10-21", "2023-10-22", "2023-10-23") diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testDateTruncBucketTransformToQueryAndTagsWithOtherPushdownFunctions/round_to/keyword_match/query.esql b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testDateTruncBucketTransformToQueryAndTagsWithOtherPushdownFunctions/round_to/keyword_match/query.esql new file mode 100644 index 0000000000000..d252b63236f6b --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testDateTruncBucketTransformToQueryAndTagsWithOtherPushdownFunctions/round_to/keyword_match/query.esql @@ -0,0 +1,3 @@ +from all_types +| where keyword : "keyword" +| stats count(*) by x = round_to(date, "2023-10-20", "2023-10-21", "2023-10-22", "2023-10-23") diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testDateTruncBucketTransformToQueryAndTagsWithWhereInsideAggregation/bucket/query.esql b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testDateTruncBucketTransformToQueryAndTagsWithWhereInsideAggregation/bucket/query.esql new file mode 100644 index 0000000000000..6309500488457 --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testDateTruncBucketTransformToQueryAndTagsWithWhereInsideAggregation/bucket/query.esql @@ -0,0 +1,2 @@ +from all_types +| stats count(*) where long > 10 by x = bucket(date, 1 day) diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testDateTruncBucketTransformToQueryAndTagsWithWhereInsideAggregation/date_trunc/query.esql b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testDateTruncBucketTransformToQueryAndTagsWithWhereInsideAggregation/date_trunc/query.esql new file mode 100644 index 0000000000000..039fd5ff287a6 --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testDateTruncBucketTransformToQueryAndTagsWithWhereInsideAggregation/date_trunc/query.esql @@ -0,0 +1,2 @@ +from all_types +| stats count(*) where long > 10 by x = date_trunc(1 day, date) diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testDateTruncBucketTransformToQueryAndTagsWithWhereInsideAggregation/round_to/query.esql b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testDateTruncBucketTransformToQueryAndTagsWithWhereInsideAggregation/round_to/query.esql new file mode 100644 index 0000000000000..33092020e833b --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testDateTruncBucketTransformToQueryAndTagsWithWhereInsideAggregation/round_to/query.esql @@ -0,0 +1,2 @@ +from all_types +| stats count(*) where long > 10 by x = round_to(date, "2023-10-20", "2023-10-21", "2023-10-22", "2023-10-23") diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testDateTruncNotTransformToQueryAndTags/date_trunc/query.esql b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testDateTruncNotTransformToQueryAndTags/date_trunc/query.esql new file mode 100644 index 0000000000000..6756737f704e2 --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testDateTruncNotTransformToQueryAndTags/date_trunc/query.esql @@ -0,0 +1,5 @@ +from all_types +| sort date +| eval x = date_trunc(1 day, date) +| keep alias_integer, date, x +| limit 5 diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testDateTruncNotTransformToQueryAndTags/round_to/query.esql b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testDateTruncNotTransformToQueryAndTags/round_to/query.esql new file mode 100644 index 0000000000000..327c15df1eb1c --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testDateTruncNotTransformToQueryAndTags/round_to/query.esql @@ -0,0 +1,5 @@ +from all_types +| sort date +| eval x = round_to(date, "2023-10-20", "2023-10-21", "2023-10-22", "2023-10-23") +| keep alias_integer, date, x +| limit 5 diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testRoundToTransformToQueryAndTags/byte/query.esql b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testRoundToTransformToQueryAndTags/byte/query.esql new file mode 100644 index 0000000000000..883ffe342e7d4 --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testRoundToTransformToQueryAndTags/byte/query.esql @@ -0,0 +1,2 @@ +from all_types +| stats count(*) by x = round_to(byte, 2,1,3,4) diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testRoundToTransformToQueryAndTags/date/query.esql b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testRoundToTransformToQueryAndTags/date/query.esql new file mode 100644 index 0000000000000..2f79776c6dda5 --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testRoundToTransformToQueryAndTags/date/query.esql @@ -0,0 +1,2 @@ +from all_types +| stats count(*) by x = round_to(date, "2023-10-20"::date,"2023-10-21"::date,"2023-10-22"::date,"2023-10-23"::date) diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testRoundToTransformToQueryAndTags/date_nanos/query.esql b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testRoundToTransformToQueryAndTags/date_nanos/query.esql new file mode 100644 index 0000000000000..ed625ca873010 --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testRoundToTransformToQueryAndTags/date_nanos/query.esql @@ -0,0 +1,2 @@ +from all_types +| stats count(*) by x = round_to(date_nanos, "2023-10-20"::date_nanos,"2023-10-21"::date_nanos,"2023-10-22"::date_nanos,"2023-10-23"::date_nanos) diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testRoundToTransformToQueryAndTags/double/query.esql b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testRoundToTransformToQueryAndTags/double/query.esql new file mode 100644 index 0000000000000..c4de6bf1e06a3 --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testRoundToTransformToQueryAndTags/double/query.esql @@ -0,0 +1,2 @@ +from all_types +| stats count(*) by x = round_to(double, 1.0,2.0,3.0,4.0) diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testRoundToTransformToQueryAndTags/float/query.esql b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testRoundToTransformToQueryAndTags/float/query.esql new file mode 100644 index 0000000000000..1d66674da19c1 --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testRoundToTransformToQueryAndTags/float/query.esql @@ -0,0 +1,2 @@ +from all_types +| stats count(*) by x = round_to(float, 3.0,2.0,1.0,4.0) diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testRoundToTransformToQueryAndTags/half_float/query.esql b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testRoundToTransformToQueryAndTags/half_float/query.esql new file mode 100644 index 0000000000000..eb1740cb34fd4 --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testRoundToTransformToQueryAndTags/half_float/query.esql @@ -0,0 +1,2 @@ +from all_types +| stats count(*) by x = round_to(half_float, 4.0,2.0,3.0,1.0) diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testRoundToTransformToQueryAndTags/integer/query.esql b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testRoundToTransformToQueryAndTags/integer/query.esql new file mode 100644 index 0000000000000..347e5c1c1f33e --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testRoundToTransformToQueryAndTags/integer/query.esql @@ -0,0 +1,2 @@ +from all_types +| stats count(*) by x = round_to(integer, 1,2,3,4) diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testRoundToTransformToQueryAndTags/long/query.esql b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testRoundToTransformToQueryAndTags/long/query.esql new file mode 100644 index 0000000000000..2af1315b103ac --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testRoundToTransformToQueryAndTags/long/query.esql @@ -0,0 +1,2 @@ +from all_types +| stats count(*) by x = round_to(long, 1697760000000,1697846400000,1697932800000,1698019200000) diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testRoundToTransformToQueryAndTags/scaled_float/query.esql b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testRoundToTransformToQueryAndTags/scaled_float/query.esql new file mode 100644 index 0000000000000..bc01ac6cabd48 --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testRoundToTransformToQueryAndTags/scaled_float/query.esql @@ -0,0 +1,2 @@ +from all_types +| stats count(*) by x = round_to(scaled_float, 4.0,3.0,2.0,1.0) diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testRoundToTransformToQueryAndTags/short/query.esql b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testRoundToTransformToQueryAndTags/short/query.esql new file mode 100644 index 0000000000000..f9618eba09919 --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testRoundToTransformToQueryAndTags/short/query.esql @@ -0,0 +1,2 @@ +from all_types +| stats count(*) by x = round_to(short, 1,3,2,4) diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testBasicTopNLateMaterialization/local_reduce_physical_optimization_data_driver b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testBasicTopNLateMaterialization/local_reduce_physical_optimization_data_driver new file mode 100644 index 0000000000000..71c01677f83a5 --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testBasicTopNLateMaterialization/local_reduce_physical_optimization_data_driver @@ -0,0 +1,4 @@ +ExchangeSinkExec[[emp_no{f}#0, hire_date{f}#1, salary{f}#2],false] +\_ProjectExec[[_doc{f}#3, hire_date{f}#1]] + \_FieldExtractExec[hire_date{f}#1]<[],[]> + \_EsQueryExec[employees], indexMode[standard], [_doc{f}#3], limit[20], sort[[FieldSort[field=hire_date{f}#1, direction=ASC, nulls=LAST]]] estimatedRowSize[24] queryBuilderAndTags [[QueryBuilderAndTags[query=null, tags=[]]]] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testBasicTopNLateMaterialization/local_reduce_planned_data_driver b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testBasicTopNLateMaterialization/local_reduce_planned_data_driver new file mode 100644 index 0000000000000..fc4d011c9a8fb --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testBasicTopNLateMaterialization/local_reduce_planned_data_driver @@ -0,0 +1,5 @@ +ExchangeSinkExec[[emp_no{f}#0, hire_date{f}#1, salary{f}#2],false] +\_FragmentExec[filter=null, estimatedRowSize=0, reducer=[], fragment=[<> +Project[[_doc{f}#3, hire_date{f}#1]] +\_TopN[[Order[hire_date{f}#1,ASC,LAST]],20[INTEGER],false] + \_EsRelation[employees][_doc{f}#3, avg_worked_seconds{f}#4, birth_date{f}#5, emp_no{f}#0, first_name{f}#6, gender{f}#7, height{f}#8, height.float{f}#9, height.half_float{f}#10, height.scaled_float{f}#11, hire_date{f}#1, is_rehired{f}#12, job_positions{f}#13, languages{f}#14, languages.byte{f}#15, languages.long{f}#16, languages.short{f}#17, last_name{f}#18, salary{f}#2, salary_change{f}#19, salary_change.int{f}#20, salary_change.keyword{f}#21, salary_change.long{f}#22, still_hired{f}#23]<>]] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testBasicTopNLateMaterialization/local_reduce_planned_reduce_driver b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testBasicTopNLateMaterialization/local_reduce_planned_reduce_driver new file mode 100644 index 0000000000000..4b4fc0c891ac1 --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testBasicTopNLateMaterialization/local_reduce_planned_reduce_driver @@ -0,0 +1,5 @@ +ExchangeSinkExec[[emp_no{f}#0, hire_date{f}#1, salary{f}#2],false] +\_ProjectExec[[emp_no{f}#0, hire_date{f}#1, salary{f}#2]] + \_FieldExtractExec[emp_no{f}#0, salary{f}#2]<[],[]> + \_TopNExec[[Order[hire_date{f}#1,ASC,LAST]],20[INTEGER],36] + \_ExchangeSourceExec[[_doc{f}#3, hire_date{f}#1],false] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testExpressionSortTopNKeepAfterSort/local_reduce_physical_optimization_data_driver b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testExpressionSortTopNKeepAfterSort/local_reduce_physical_optimization_data_driver new file mode 100644 index 0000000000000..8f49d89b830ce --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testExpressionSortTopNKeepAfterSort/local_reduce_physical_optimization_data_driver @@ -0,0 +1,6 @@ +ExchangeSinkExec[[hire_date{f}#0, $$order_by$0{r}#1],false] +\_ProjectExec[[_doc{f}#2, $$order_by$0{r}#1]] + \_TopNExec[[Order[$$order_by$0{r}#1,ASC,LAST]],20[INTEGER],36] + \_EvalExec[[SIN(height{f}#3) * 2[INTEGER] AS $$order_by$0#1]] + \_FieldExtractExec[height{f}#3]<[],[]> + \_EsQueryExec[employees], indexMode[standard], [_doc{f}#2], limit[], sort[] estimatedRowSize[20] queryBuilderAndTags [[QueryBuilderAndTags[query=null, tags=[]]]] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testExpressionSortTopNKeepAfterSort/local_reduce_planned_data_driver b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testExpressionSortTopNKeepAfterSort/local_reduce_planned_data_driver new file mode 100644 index 0000000000000..9ce3f748778c1 --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testExpressionSortTopNKeepAfterSort/local_reduce_planned_data_driver @@ -0,0 +1,6 @@ +ExchangeSinkExec[[hire_date{f}#0, $$order_by$0{r}#1],false] +\_FragmentExec[filter=null, estimatedRowSize=0, reducer=[], fragment=[<> +Project[[_doc{f}#2, $$order_by$0{r}#1]] +\_TopN[[Order[$$order_by$0{r}#1,ASC,LAST]],20[INTEGER],false] + \_Eval[[SIN(height{f}#3) * 2[INTEGER] AS $$order_by$0#1]] + \_EsRelation[employees][_doc{f}#2, avg_worked_seconds{f}#4, birth_date{f}#5, emp_no{f}#6, first_name{f}#7, gender{f}#8, height{f}#3, height.float{f}#9, height.half_float{f}#10, height.scaled_float{f}#11, hire_date{f}#0, is_rehired{f}#12, job_positions{f}#13, languages{f}#14, languages.byte{f}#15, languages.long{f}#16, languages.short{f}#17, last_name{f}#18, salary{f}#19, salary_change{f}#20, salary_change.int{f}#21, salary_change.keyword{f}#22, salary_change.long{f}#23, still_hired{f}#24]<>]] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testExpressionSortTopNKeepAfterSort/local_reduce_planned_reduce_driver b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testExpressionSortTopNKeepAfterSort/local_reduce_planned_reduce_driver new file mode 100644 index 0000000000000..d2459818c5588 --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testExpressionSortTopNKeepAfterSort/local_reduce_planned_reduce_driver @@ -0,0 +1,5 @@ +ExchangeSinkExec[[hire_date{f}#0, $$order_by$0{r}#1],false] +\_ProjectExec[[hire_date{f}#0, $$order_by$0{r}#1]] + \_FieldExtractExec[hire_date{f}#0]<[],[]> + \_TopNExec[[Order[$$order_by$0{r}#1,ASC,LAST]],20[INTEGER],36] + \_ExchangeSourceExec[[_doc{f}#2, $$order_by$0{r}#1],false] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testExpressionSortTopNKeepBeforeSort/local_reduce_physical_optimization_data_driver b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testExpressionSortTopNKeepBeforeSort/local_reduce_physical_optimization_data_driver new file mode 100644 index 0000000000000..460cbcab3451e --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testExpressionSortTopNKeepBeforeSort/local_reduce_physical_optimization_data_driver @@ -0,0 +1,6 @@ +ExchangeSinkExec[[height{f}#0, hire_date{f}#1, $$order_by$0{r}#2],false] +\_ProjectExec[[_doc{f}#3, height{f}#0, $$order_by$0{r}#2]] + \_TopNExec[[Order[$$order_by$0{r}#2,ASC,LAST]],20[INTEGER],36] + \_EvalExec[[SIN(height{f}#0) * 2[INTEGER] AS $$order_by$0#2]] + \_FieldExtractExec[height{f}#0]<[],[]> + \_EsQueryExec[employees], indexMode[standard], [_doc{f}#3], limit[], sort[] estimatedRowSize[20] queryBuilderAndTags [[QueryBuilderAndTags[query=null, tags=[]]]] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testExpressionSortTopNKeepBeforeSort/local_reduce_planned_data_driver b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testExpressionSortTopNKeepBeforeSort/local_reduce_planned_data_driver new file mode 100644 index 0000000000000..932c4834e7e80 --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testExpressionSortTopNKeepBeforeSort/local_reduce_planned_data_driver @@ -0,0 +1,6 @@ +ExchangeSinkExec[[height{f}#0, hire_date{f}#1, $$order_by$0{r}#2],false] +\_FragmentExec[filter=null, estimatedRowSize=0, reducer=[], fragment=[<> +Project[[_doc{f}#3, height{f}#0, $$order_by$0{r}#2]] +\_TopN[[Order[$$order_by$0{r}#2,ASC,LAST]],20[INTEGER],false] + \_Eval[[SIN(height{f}#0) * 2[INTEGER] AS $$order_by$0#2]] + \_EsRelation[employees][_doc{f}#3, avg_worked_seconds{f}#4, birth_date{f}#5, emp_no{f}#6, first_name{f}#7, gender{f}#8, height{f}#0, height.float{f}#9, height.half_float{f}#10, height.scaled_float{f}#11, hire_date{f}#1, is_rehired{f}#12, job_positions{f}#13, languages{f}#14, languages.byte{f}#15, languages.long{f}#16, languages.short{f}#17, last_name{f}#18, salary{f}#19, salary_change{f}#20, salary_change.int{f}#21, salary_change.keyword{f}#22, salary_change.long{f}#23, still_hired{f}#24]<>]] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testExpressionSortTopNKeepBeforeSort/local_reduce_planned_reduce_driver b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testExpressionSortTopNKeepBeforeSort/local_reduce_planned_reduce_driver new file mode 100644 index 0000000000000..88c85960c5dd2 --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testExpressionSortTopNKeepBeforeSort/local_reduce_planned_reduce_driver @@ -0,0 +1,5 @@ +ExchangeSinkExec[[height{f}#0, hire_date{f}#1, $$order_by$0{r}#2],false] +\_ProjectExec[[height{f}#0, hire_date{f}#1, $$order_by$0{r}#2]] + \_FieldExtractExec[hire_date{f}#1]<[],[]> + \_TopNExec[[Order[$$order_by$0{r}#2,ASC,LAST]],20[INTEGER],44] + \_ExchangeSourceExec[[_doc{f}#3, height{f}#0, $$order_by$0{r}#2],false] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testLookupJoinOnDataNode/local_reduce_physical_optimization_data_driver b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testLookupJoinOnDataNode/local_reduce_physical_optimization_data_driver new file mode 100644 index 0000000000000..ebbbae1cfcc6d --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testLookupJoinOnDataNode/local_reduce_physical_optimization_data_driver @@ -0,0 +1,25 @@ +ExchangeSinkExec[[avg_worked_seconds{f}#0, birth_date{f}#1, emp_no{f}#2, first_name{f}#3, gender{f}#4, height{f}#5, height.float{f}#6, height.half_float{f}#7, height.scaled_float{f}#8, hire_date{f}#9, is_rehired{f}#10, job_positions{f}#11, languages{f}#12, languages.byte{f}#13, languages.long{f}#14, languages.short{f}#15, last_name{f}#16, salary{f}#17, salary_change{f}#18, salary_change.int{f}#19, salary_change.keyword{f}#20, salary_change.long{f}#21, still_hired{f}#22, language_code{r}#23, language_name{f}#24],false] +\_ProjectExec[[_doc{f}#25, emp_no{f}#2, languages{f}#12, language_code{r}#23, language_name{f}#24]] + \_TopNExec[[Order[emp_no{f}#2,ASC,LAST]],20[INTEGER],82] + \_FieldExtractExec[emp_no{f}#2]<[],[]> + \_LookupJoinExec[[language_code{r}#23],[language_code{f}#26],[language_name{f}#24],null] + |_EvalExec[[languages{f}#12 AS language_code#23]] + | \_FieldExtractExec[languages{f}#12]<[],[]> + | \_EsQueryExec[employees], indexMode[standard], [_doc{f}#25], limit[], sort[] estimatedRowSize[66] queryBuilderAndTags [[QueryBuilderAndTags[query={ + "esql_single_value" : { + "field" : "emp_no", + "next" : { + "range" : { + "emp_no" : { + "gte" : 10091, + "lt" : 10094, + "time_zone" : "Z", + "boost" : 0.0 + } + } + }, + "source" : "emp_no >= 10091@4:9" + } +}, tags=[]]]] + \_FragmentExec[filter=null, estimatedRowSize=0, reducer=[], fragment=[<> +EsRelation[languages_lookup][LOOKUP][language_code{f}#26, language_name{f}#24]<>]] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testLookupJoinOnDataNode/local_reduce_planned_data_driver b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testLookupJoinOnDataNode/local_reduce_planned_data_driver new file mode 100644 index 0000000000000..7ff68ac134d83 --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testLookupJoinOnDataNode/local_reduce_planned_data_driver @@ -0,0 +1,9 @@ +ExchangeSinkExec[[avg_worked_seconds{f}#0, birth_date{f}#1, emp_no{f}#2, first_name{f}#3, gender{f}#4, height{f}#5, height.float{f}#6, height.half_float{f}#7, height.scaled_float{f}#8, hire_date{f}#9, is_rehired{f}#10, job_positions{f}#11, languages{f}#12, languages.byte{f}#13, languages.long{f}#14, languages.short{f}#15, last_name{f}#16, salary{f}#17, salary_change{f}#18, salary_change.int{f}#19, salary_change.keyword{f}#20, salary_change.long{f}#21, still_hired{f}#22, language_code{r}#23, language_name{f}#24],false] +\_FragmentExec[filter=null, estimatedRowSize=0, reducer=[], fragment=[<> +Project[[_doc{f}#25, emp_no{f}#2, languages{f}#12, language_code{r}#23, language_name{f}#24]] +\_TopN[[Order[emp_no{f}#2,ASC,LAST]],20[INTEGER],false] + \_Join[LEFT,[language_code{r}#23],[language_code{f}#26],null] + |_Eval[[languages{f}#12 AS language_code#23]] + | \_Filter[emp_no{f}#2 >= 10091[INTEGER] AND emp_no{f}#2 < 10094[INTEGER]] + | \_EsRelation[employees][_doc{f}#25, avg_worked_seconds{f}#0, birth_date{f}#1, emp_no{f}#2, first_name{f}#3, gender{f}#4, height{f}#5, height.float{f}#6, height.half_float{f}#7, height.scaled_float{f}#8, hire_date{f}#9, is_rehired{f}#10, job_positions{f}#11, languages{f}#12, languages.byte{f}#13, languages.long{f}#14, languages.short{f}#15, last_name{f}#16, salary{f}#17, salary_change{f}#18, salary_change.int{f}#19, salary_change.keyword{f}#20, salary_change.long{f}#21, still_hired{f}#22] + \_EsRelation[languages_lookup][LOOKUP][language_code{f}#26, language_name{f}#24]<>]] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testLookupJoinOnDataNode/local_reduce_planned_reduce_driver b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testLookupJoinOnDataNode/local_reduce_planned_reduce_driver new file mode 100644 index 0000000000000..19c98b1780f37 --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testLookupJoinOnDataNode/local_reduce_planned_reduce_driver @@ -0,0 +1,5 @@ +ExchangeSinkExec[[avg_worked_seconds{f}#0, birth_date{f}#1, emp_no{f}#2, first_name{f}#3, gender{f}#4, height{f}#5, height.float{f}#6, height.half_float{f}#7, height.scaled_float{f}#8, hire_date{f}#9, is_rehired{f}#10, job_positions{f}#11, languages{f}#12, languages.byte{f}#13, languages.long{f}#14, languages.short{f}#15, last_name{f}#16, salary{f}#17, salary_change{f}#18, salary_change.int{f}#19, salary_change.keyword{f}#20, salary_change.long{f}#21, still_hired{f}#22, language_code{r}#23, language_name{f}#24],false] +\_ProjectExec[[avg_worked_seconds{f}#0, birth_date{f}#1, emp_no{f}#2, first_name{f}#3, gender{f}#4, height{f}#5, height.float{f}#6, height.half_float{f}#7, height.scaled_float{f}#8, hire_date{f}#9, is_rehired{f}#10, job_positions{f}#11, languages{f}#12, languages.byte{f}#13, languages.long{f}#14, languages.short{f}#15, last_name{f}#16, salary{f}#17, salary_change{f}#18, salary_change.int{f}#19, salary_change.keyword{f}#20, salary_change.long{f}#21, still_hired{f}#22, language_code{r}#23, language_name{f}#24]] + \_FieldExtractExec[avg_worked_seconds{f}#0, birth_date{f}#1, first_name{f}#3, gender{f}#4, height{f}#5, height.float{f}#6, height.half_float{f}#7, height.scaled_float{f}#8, hire_date{f}#9, is_rehired{f}#10, job_positions{f}#11, languages.byte{f}#13, languages.long{f}#14, languages.short{f}#15, last_name{f}#16, salary{f}#17, salary_change{f}#18, salary_change.int{f}#19, salary_change.keyword{f}#20, salary_change.long{f}#21, still_hired{f}#22]<[],[]> + \_TopNExec[[Order[emp_no{f}#2,ASC,LAST]],20[INTEGER],430] + \_ExchangeSourceExec[[_doc{f}#25, emp_no{f}#2, languages{f}#12, language_code{r}#23, language_name{f}#24],false] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testMultipleFieldSortTopN/local_reduce_physical_optimization_data_driver b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testMultipleFieldSortTopN/local_reduce_physical_optimization_data_driver new file mode 100644 index 0000000000000..e5de0b72a7705 --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testMultipleFieldSortTopN/local_reduce_physical_optimization_data_driver @@ -0,0 +1,4 @@ +ExchangeSinkExec[[emp_no{f}#0, height{f}#1, hire_date{f}#2],false] +\_ProjectExec[[_doc{f}#3, hire_date{f}#2, height{f}#1]] + \_FieldExtractExec[hire_date{f}#2, height{f}#1]<[],[]> + \_EsQueryExec[employees], indexMode[standard], [_doc{f}#3], limit[20], sort[[FieldSort[field=hire_date{f}#2, direction=ASC, nulls=LAST], FieldSort[field=height{f}#1, direction=ASC, nulls=LAST]]] estimatedRowSize[32] queryBuilderAndTags [[QueryBuilderAndTags[query=null, tags=[]]]] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testMultipleFieldSortTopN/local_reduce_planned_data_driver b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testMultipleFieldSortTopN/local_reduce_planned_data_driver new file mode 100644 index 0000000000000..4866ac15c30c3 --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testMultipleFieldSortTopN/local_reduce_planned_data_driver @@ -0,0 +1,5 @@ +ExchangeSinkExec[[emp_no{f}#0, height{f}#1, hire_date{f}#2],false] +\_FragmentExec[filter=null, estimatedRowSize=0, reducer=[], fragment=[<> +Project[[_doc{f}#3, hire_date{f}#2, height{f}#1]] +\_TopN[[Order[hire_date{f}#2,ASC,LAST], Order[height{f}#1,ASC,LAST]],20[INTEGER],false] + \_EsRelation[employees][_doc{f}#3, avg_worked_seconds{f}#4, birth_date{f}#5, emp_no{f}#0, first_name{f}#6, gender{f}#7, height{f}#1, height.float{f}#8, height.half_float{f}#9, height.scaled_float{f}#10, hire_date{f}#2, is_rehired{f}#11, job_positions{f}#12, languages{f}#13, languages.byte{f}#14, languages.long{f}#15, languages.short{f}#16, last_name{f}#17, salary{f}#18, salary_change{f}#19, salary_change.int{f}#20, salary_change.keyword{f}#21, salary_change.long{f}#22, still_hired{f}#23]<>]] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testMultipleFieldSortTopN/local_reduce_planned_reduce_driver b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testMultipleFieldSortTopN/local_reduce_planned_reduce_driver new file mode 100644 index 0000000000000..ab96def3b448c --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testMultipleFieldSortTopN/local_reduce_planned_reduce_driver @@ -0,0 +1,5 @@ +ExchangeSinkExec[[emp_no{f}#0, height{f}#1, hire_date{f}#2],false] +\_ProjectExec[[emp_no{f}#0, height{f}#1, hire_date{f}#2]] + \_FieldExtractExec[emp_no{f}#0]<[],[]> + \_TopNExec[[Order[hire_date{f}#2,ASC,LAST], Order[height{f}#1,ASC,LAST]],20[INTEGER],40] + \_ExchangeSourceExec[[_doc{f}#3, hire_date{f}#2, height{f}#1],false] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testMultipleTopN/local_reduce_physical_optimization_data_driver b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testMultipleTopN/local_reduce_physical_optimization_data_driver new file mode 100644 index 0000000000000..71c01677f83a5 --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testMultipleTopN/local_reduce_physical_optimization_data_driver @@ -0,0 +1,4 @@ +ExchangeSinkExec[[emp_no{f}#0, hire_date{f}#1, salary{f}#2],false] +\_ProjectExec[[_doc{f}#3, hire_date{f}#1]] + \_FieldExtractExec[hire_date{f}#1]<[],[]> + \_EsQueryExec[employees], indexMode[standard], [_doc{f}#3], limit[20], sort[[FieldSort[field=hire_date{f}#1, direction=ASC, nulls=LAST]]] estimatedRowSize[24] queryBuilderAndTags [[QueryBuilderAndTags[query=null, tags=[]]]] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testMultipleTopN/local_reduce_planned_data_driver b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testMultipleTopN/local_reduce_planned_data_driver new file mode 100644 index 0000000000000..fc4d011c9a8fb --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testMultipleTopN/local_reduce_planned_data_driver @@ -0,0 +1,5 @@ +ExchangeSinkExec[[emp_no{f}#0, hire_date{f}#1, salary{f}#2],false] +\_FragmentExec[filter=null, estimatedRowSize=0, reducer=[], fragment=[<> +Project[[_doc{f}#3, hire_date{f}#1]] +\_TopN[[Order[hire_date{f}#1,ASC,LAST]],20[INTEGER],false] + \_EsRelation[employees][_doc{f}#3, avg_worked_seconds{f}#4, birth_date{f}#5, emp_no{f}#0, first_name{f}#6, gender{f}#7, height{f}#8, height.float{f}#9, height.half_float{f}#10, height.scaled_float{f}#11, hire_date{f}#1, is_rehired{f}#12, job_positions{f}#13, languages{f}#14, languages.byte{f}#15, languages.long{f}#16, languages.short{f}#17, last_name{f}#18, salary{f}#2, salary_change{f}#19, salary_change.int{f}#20, salary_change.keyword{f}#21, salary_change.long{f}#22, still_hired{f}#23]<>]] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testMultipleTopN/local_reduce_planned_reduce_driver b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testMultipleTopN/local_reduce_planned_reduce_driver new file mode 100644 index 0000000000000..4b4fc0c891ac1 --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testMultipleTopN/local_reduce_planned_reduce_driver @@ -0,0 +1,5 @@ +ExchangeSinkExec[[emp_no{f}#0, hire_date{f}#1, salary{f}#2],false] +\_ProjectExec[[emp_no{f}#0, hire_date{f}#1, salary{f}#2]] + \_FieldExtractExec[emp_no{f}#0, salary{f}#2]<[],[]> + \_TopNExec[[Order[hire_date{f}#1,ASC,LAST]],20[INTEGER],36] + \_ExchangeSourceExec[[_doc{f}#3, hire_date{f}#1],false] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testMvExpandBeforeTopN/local_reduce_physical_optimization_data_driver b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testMvExpandBeforeTopN/local_reduce_physical_optimization_data_driver new file mode 100644 index 0000000000000..f0d827b7d0c99 --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testMvExpandBeforeTopN/local_reduce_physical_optimization_data_driver @@ -0,0 +1,7 @@ +ExchangeSinkExec[[emp_no{f}#0, job_positions{r}#1, salary{f}#2],false] +\_ProjectExec[[emp_no{f}#0, job_positions{r}#1, salary{f}#2]] + \_TopNExec[[Order[salary{f}#2,ASC,LAST]],20[INTEGER],58] + \_MvExpandExec[job_positions{f}#3,job_positions{r}#1] + \_ProjectExec[[emp_no{f}#0, job_positions{f}#3, salary{f}#2]] + \_FieldExtractExec[emp_no{f}#0, job_positions{f}#3, salary{f}#2]<[],[]> + \_EsQueryExec[employees], indexMode[standard], [_doc{f}#4], limit[], sort[] estimatedRowSize[62] queryBuilderAndTags [[QueryBuilderAndTags[query=null, tags=[]]]] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testMvExpandBeforeTopN/local_reduce_physical_optimization_reduce_driver b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testMvExpandBeforeTopN/local_reduce_physical_optimization_reduce_driver new file mode 100644 index 0000000000000..a9639e399dec8 --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testMvExpandBeforeTopN/local_reduce_physical_optimization_reduce_driver @@ -0,0 +1,3 @@ +ExchangeSinkExec[[emp_no{f}#0, job_positions{r}#1, salary{f}#2],false] +\_TopNExec[[Order[salary{f}#2,ASC,LAST]],20[INTEGER],58] + \_ExchangeSourceExec[[emp_no{f}#0, job_positions{r}#1, salary{f}#2],false] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testMvExpandBeforeTopN/local_reduce_planned_data_driver b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testMvExpandBeforeTopN/local_reduce_planned_data_driver new file mode 100644 index 0000000000000..baf5e66932990 --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testMvExpandBeforeTopN/local_reduce_planned_data_driver @@ -0,0 +1,7 @@ +ExchangeSinkExec[[emp_no{f}#0, job_positions{r}#1, salary{f}#2],false] +\_FragmentExec[filter=null, estimatedRowSize=0, reducer=[], fragment=[<> +Project[[emp_no{f}#0, job_positions{r}#1, salary{f}#2]] +\_TopN[[Order[salary{f}#2,ASC,LAST]],20[INTEGER],false] + \_MvExpand[job_positions{f}#3,job_positions{r}#1] + \_Project[[emp_no{f}#0, job_positions{f}#3, salary{f}#2]] + \_EsRelation[employees][avg_worked_seconds{f}#4, birth_date{f}#5, emp_no{f}#0, first_name{f}#6, gender{f}#7, height{f}#8, height.float{f}#9, height.half_float{f}#10, height.scaled_float{f}#11, hire_date{f}#12, is_rehired{f}#13, job_positions{f}#3, languages{f}#14, languages.byte{f}#15, languages.long{f}#16, languages.short{f}#17, last_name{f}#18, salary{f}#2, salary_change{f}#19, salary_change.int{f}#20, salary_change.keyword{f}#21, salary_change.long{f}#22, still_hired{f}#23]<>]] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testMvExpandBeforeTopN/local_reduce_planned_reduce_driver b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testMvExpandBeforeTopN/local_reduce_planned_reduce_driver new file mode 100644 index 0000000000000..a9639e399dec8 --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testMvExpandBeforeTopN/local_reduce_planned_reduce_driver @@ -0,0 +1,3 @@ +ExchangeSinkExec[[emp_no{f}#0, job_positions{r}#1, salary{f}#2],false] +\_TopNExec[[Order[salary{f}#2,ASC,LAST]],20[INTEGER],58] + \_ExchangeSourceExec[[emp_no{f}#0, job_positions{r}#1, salary{f}#2],false] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testPushedDownTopN/local_reduce_physical_optimization_data_driver b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testPushedDownTopN/local_reduce_physical_optimization_data_driver new file mode 100644 index 0000000000000..cebf3f704c28d --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testPushedDownTopN/local_reduce_physical_optimization_data_driver @@ -0,0 +1,4 @@ +ExchangeSinkExec[[emp_no{f}#0, height{f}#1],false] +\_ProjectExec[[_doc{f}#2, height{f}#1]] + \_FieldExtractExec[height{f}#1]<[],[]> + \_EsQueryExec[employees], indexMode[standard], [_doc{f}#2], limit[20], sort[[FieldSort[field=height{f}#1, direction=ASC, nulls=LAST]]] estimatedRowSize[24] queryBuilderAndTags [[QueryBuilderAndTags[query=null, tags=[]]]] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testPushedDownTopN/local_reduce_planned_data_driver b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testPushedDownTopN/local_reduce_planned_data_driver new file mode 100644 index 0000000000000..b2913dbdf505b --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testPushedDownTopN/local_reduce_planned_data_driver @@ -0,0 +1,5 @@ +ExchangeSinkExec[[emp_no{f}#0, height{f}#1],false] +\_FragmentExec[filter=null, estimatedRowSize=0, reducer=[], fragment=[<> +Project[[_doc{f}#2, height{f}#1]] +\_TopN[[Order[height{f}#1,ASC,LAST]],20[INTEGER],false] + \_EsRelation[employees][_doc{f}#2, avg_worked_seconds{f}#3, birth_date{f}#4, emp_no{f}#0, first_name{f}#5, gender{f}#6, height{f}#1, height.float{f}#7, height.half_float{f}#8, height.scaled_float{f}#9, hire_date{f}#10, is_rehired{f}#11, job_positions{f}#12, languages{f}#13, languages.byte{f}#14, languages.long{f}#15, languages.short{f}#16, last_name{f}#17, salary{f}#18, salary_change{f}#19, salary_change.int{f}#20, salary_change.keyword{f}#21, salary_change.long{f}#22, still_hired{f}#23]<>]] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testPushedDownTopN/local_reduce_planned_reduce_driver b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testPushedDownTopN/local_reduce_planned_reduce_driver new file mode 100644 index 0000000000000..3425364e715c1 --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testPushedDownTopN/local_reduce_planned_reduce_driver @@ -0,0 +1,5 @@ +ExchangeSinkExec[[emp_no{f}#0, height{f}#1],false] +\_ProjectExec[[emp_no{f}#0, height{f}#1]] + \_FieldExtractExec[emp_no{f}#0]<[],[]> + \_TopNExec[[Order[height{f}#1,ASC,LAST]],20[INTEGER],32] + \_ExchangeSourceExec[[_doc{f}#2, height{f}#1],false] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testSomeFieldsNeededBeforeLateMaterialization/local_reduce_physical_optimization_data_driver b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testSomeFieldsNeededBeforeLateMaterialization/local_reduce_physical_optimization_data_driver new file mode 100644 index 0000000000000..91fa3beaa5567 --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testSomeFieldsNeededBeforeLateMaterialization/local_reduce_physical_optimization_data_driver @@ -0,0 +1,17 @@ +ExchangeSinkExec[[emp_no{f}#0, hire_date{f}#1, salary{f}#2],false] +\_ProjectExec[[_doc{f}#3, salary{f}#2, hire_date{f}#1]] + \_FieldExtractExec[salary{f}#2, hire_date{f}#1]<[],[]> + \_EsQueryExec[employees], indexMode[standard], [_doc{f}#3], limit[20], sort[[FieldSort[field=hire_date{f}#1, direction=ASC, nulls=LAST]]] estimatedRowSize[28] queryBuilderAndTags [[QueryBuilderAndTags[query={ + "esql_single_value" : { + "field" : "salary", + "next" : { + "range" : { + "salary" : { + "gt" : 10000, + "boost" : 0.0 + } + } + }, + "source" : "salary > 10000@3:9" + } +}, tags=[]]]] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testSomeFieldsNeededBeforeLateMaterialization/local_reduce_planned_data_driver b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testSomeFieldsNeededBeforeLateMaterialization/local_reduce_planned_data_driver new file mode 100644 index 0000000000000..1e90a18573c7c --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testSomeFieldsNeededBeforeLateMaterialization/local_reduce_planned_data_driver @@ -0,0 +1,6 @@ +ExchangeSinkExec[[emp_no{f}#0, hire_date{f}#1, salary{f}#2],false] +\_FragmentExec[filter=null, estimatedRowSize=0, reducer=[], fragment=[<> +Project[[_doc{f}#3, salary{f}#2, hire_date{f}#1]] +\_TopN[[Order[hire_date{f}#1,ASC,LAST]],20[INTEGER],false] + \_Filter[salary{f}#2 > 10000[INTEGER]] + \_EsRelation[employees][_doc{f}#3, avg_worked_seconds{f}#4, birth_date{f}#5, emp_no{f}#0, first_name{f}#6, gender{f}#7, height{f}#8, height.float{f}#9, height.half_float{f}#10, height.scaled_float{f}#11, hire_date{f}#1, is_rehired{f}#12, job_positions{f}#13, languages{f}#14, languages.byte{f}#15, languages.long{f}#16, languages.short{f}#17, last_name{f}#18, salary{f}#2, salary_change{f}#19, salary_change.int{f}#20, salary_change.keyword{f}#21, salary_change.long{f}#22, still_hired{f}#23]<>]] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testSomeFieldsNeededBeforeLateMaterialization/local_reduce_planned_reduce_driver b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testSomeFieldsNeededBeforeLateMaterialization/local_reduce_planned_reduce_driver new file mode 100644 index 0000000000000..178d31ccc5dc1 --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testSomeFieldsNeededBeforeLateMaterialization/local_reduce_planned_reduce_driver @@ -0,0 +1,5 @@ +ExchangeSinkExec[[emp_no{f}#0, hire_date{f}#1, salary{f}#2],false] +\_ProjectExec[[emp_no{f}#0, hire_date{f}#1, salary{f}#2]] + \_FieldExtractExec[emp_no{f}#0]<[],[]> + \_TopNExec[[Order[hire_date{f}#1,ASC,LAST]],20[INTEGER],36] + \_ExchangeSourceExec[[_doc{f}#3, salary{f}#2, hire_date{f}#1],false] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testTopNThenStats/local_reduce_physical_optimization_data_driver b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testTopNThenStats/local_reduce_physical_optimization_data_driver new file mode 100644 index 0000000000000..8dc76dd8b28df --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testTopNThenStats/local_reduce_physical_optimization_data_driver @@ -0,0 +1,4 @@ +ExchangeSinkExec[[hire_date{f}#0, salary{f}#1],false] +\_ProjectExec[[_doc{f}#2, hire_date{f}#0]] + \_FieldExtractExec[hire_date{f}#0]<[],[]> + \_EsQueryExec[employees], indexMode[standard], [_doc{f}#2], limit[20], sort[[FieldSort[field=hire_date{f}#0, direction=ASC, nulls=LAST]]] estimatedRowSize[24] queryBuilderAndTags [[QueryBuilderAndTags[query=null, tags=[]]]] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testTopNThenStats/local_reduce_planned_data_driver b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testTopNThenStats/local_reduce_planned_data_driver new file mode 100644 index 0000000000000..070d12cb17d93 --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testTopNThenStats/local_reduce_planned_data_driver @@ -0,0 +1,5 @@ +ExchangeSinkExec[[hire_date{f}#0, salary{f}#1],false] +\_FragmentExec[filter=null, estimatedRowSize=0, reducer=[], fragment=[<> +Project[[_doc{f}#2, hire_date{f}#0]] +\_TopN[[Order[hire_date{f}#0,ASC,LAST]],20[INTEGER],false] + \_EsRelation[employees][_doc{f}#2, avg_worked_seconds{f}#3, birth_date{f}#4, emp_no{f}#5, first_name{f}#6, gender{f}#7, height{f}#8, height.float{f}#9, height.half_float{f}#10, height.scaled_float{f}#11, hire_date{f}#0, is_rehired{f}#12, job_positions{f}#13, languages{f}#14, languages.byte{f}#15, languages.long{f}#16, languages.short{f}#17, last_name{f}#18, salary{f}#1, salary_change{f}#19, salary_change.int{f}#20, salary_change.keyword{f}#21, salary_change.long{f}#22, still_hired{f}#23]<>]] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testTopNThenStats/local_reduce_planned_reduce_driver b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testTopNThenStats/local_reduce_planned_reduce_driver new file mode 100644 index 0000000000000..3c81025a6c14e --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testTopNThenStats/local_reduce_planned_reduce_driver @@ -0,0 +1,5 @@ +ExchangeSinkExec[[hire_date{f}#0, salary{f}#1],false] +\_ProjectExec[[hire_date{f}#0, salary{f}#1]] + \_FieldExtractExec[salary{f}#1]<[],[]> + \_TopNExec[[Order[hire_date{f}#0,ASC,LAST]],20[INTEGER],32] + \_ExchangeSourceExec[[_doc{f}#2, hire_date{f}#0],false] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testTopNWithMissingSortField/local_reduce_physical_optimization_data_driver b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testTopNWithMissingSortField/local_reduce_physical_optimization_data_driver new file mode 100644 index 0000000000000..0280707cf7711 --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testTopNWithMissingSortField/local_reduce_physical_optimization_data_driver @@ -0,0 +1,4 @@ +ExchangeSinkExec[[emp_no{f}#0, hire_date{f}#1, salary{f}#2],false] +\_ProjectExec[[_doc{f}#3, birth_date{r}#4 AS hire_date#1]] + \_EvalExec[[null[DATETIME] AS birth_date#4]] + \_EsQueryExec[employees], indexMode[standard], [_doc{f}#3], limit[20], sort[] estimatedRowSize[12] queryBuilderAndTags [[QueryBuilderAndTags[query=null, tags=[]]]] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testTopNWithMissingSortField/local_reduce_planned_data_driver b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testTopNWithMissingSortField/local_reduce_planned_data_driver new file mode 100644 index 0000000000000..fc4d011c9a8fb --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testTopNWithMissingSortField/local_reduce_planned_data_driver @@ -0,0 +1,5 @@ +ExchangeSinkExec[[emp_no{f}#0, hire_date{f}#1, salary{f}#2],false] +\_FragmentExec[filter=null, estimatedRowSize=0, reducer=[], fragment=[<> +Project[[_doc{f}#3, hire_date{f}#1]] +\_TopN[[Order[hire_date{f}#1,ASC,LAST]],20[INTEGER],false] + \_EsRelation[employees][_doc{f}#3, avg_worked_seconds{f}#4, birth_date{f}#5, emp_no{f}#0, first_name{f}#6, gender{f}#7, height{f}#8, height.float{f}#9, height.half_float{f}#10, height.scaled_float{f}#11, hire_date{f}#1, is_rehired{f}#12, job_positions{f}#13, languages{f}#14, languages.byte{f}#15, languages.long{f}#16, languages.short{f}#17, last_name{f}#18, salary{f}#2, salary_change{f}#19, salary_change.int{f}#20, salary_change.keyword{f}#21, salary_change.long{f}#22, still_hired{f}#23]<>]] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testTopNWithMissingSortField/local_reduce_planned_reduce_driver b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testTopNWithMissingSortField/local_reduce_planned_reduce_driver new file mode 100644 index 0000000000000..4b4fc0c891ac1 --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testTopNWithMissingSortField/local_reduce_planned_reduce_driver @@ -0,0 +1,5 @@ +ExchangeSinkExec[[emp_no{f}#0, hire_date{f}#1, salary{f}#2],false] +\_ProjectExec[[emp_no{f}#0, hire_date{f}#1, salary{f}#2]] + \_FieldExtractExec[emp_no{f}#0, salary{f}#2]<[],[]> + \_TopNExec[[Order[hire_date{f}#1,ASC,LAST]],20[INTEGER],36] + \_ExchangeSourceExec[[_doc{f}#3, hire_date{f}#1],false] \ No newline at end of file From 465826c516efec7e0c7c65fe7cd10aa5350aa591 Mon Sep 17 00:00:00 2001 From: Gal Lalouche Date: Tue, 3 Feb 2026 18:38:54 +0200 Subject: [PATCH 17/25] TEMP --- .../xpack/esql/core/expression/Alias.java | 2 +- .../xpack/esql/optimizer/GoldenTestCase.java | 14 +++++------ .../load/analysis.expected | 5 ++-- .../nullify/analysis.expected | 5 ++-- ...l_reduce_physical_optimization_data_driver | 4 --- .../local_reduce_planned_data_driver | 5 ---- .../local_reduce_planned_reduce_driver | 5 ---- ...l_reduce_physical_optimization_data_driver | 6 ----- .../local_reduce_planned_data_driver | 6 ----- .../local_reduce_planned_reduce_driver | 5 ---- ...l_reduce_physical_optimization_data_driver | 6 ----- .../local_reduce_planned_data_driver | 6 ----- .../local_reduce_planned_reduce_driver | 5 ---- ...l_reduce_physical_optimization_data_driver | 25 ------------------- .../local_reduce_planned_data_driver | 9 ------- .../local_reduce_planned_reduce_driver | 5 ---- ...l_reduce_physical_optimization_data_driver | 4 --- .../local_reduce_planned_data_driver | 5 ---- .../local_reduce_planned_reduce_driver | 5 ---- ...l_reduce_physical_optimization_data_driver | 4 --- .../local_reduce_planned_data_driver | 5 ---- .../local_reduce_planned_reduce_driver | 5 ---- ...l_reduce_physical_optimization_data_driver | 7 ------ ...reduce_physical_optimization_reduce_driver | 3 --- .../local_reduce_planned_data_driver | 7 ------ .../local_reduce_planned_reduce_driver | 3 --- ...l_reduce_physical_optimization_data_driver | 4 --- .../local_reduce_planned_data_driver | 5 ---- .../local_reduce_planned_reduce_driver | 5 ---- ...l_reduce_physical_optimization_data_driver | 17 ------------- .../local_reduce_planned_data_driver | 6 ----- .../local_reduce_planned_reduce_driver | 5 ---- ...l_reduce_physical_optimization_data_driver | 4 --- .../local_reduce_planned_data_driver | 5 ---- .../local_reduce_planned_reduce_driver | 5 ---- ...l_reduce_physical_optimization_data_driver | 4 --- .../local_reduce_planned_data_driver | 5 ---- .../local_reduce_planned_reduce_driver | 5 ---- 38 files changed, 12 insertions(+), 219 deletions(-) delete mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testBasicTopNLateMaterialization/local_reduce_physical_optimization_data_driver delete mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testBasicTopNLateMaterialization/local_reduce_planned_data_driver delete mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testBasicTopNLateMaterialization/local_reduce_planned_reduce_driver delete mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testExpressionSortTopNKeepAfterSort/local_reduce_physical_optimization_data_driver delete mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testExpressionSortTopNKeepAfterSort/local_reduce_planned_data_driver delete mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testExpressionSortTopNKeepAfterSort/local_reduce_planned_reduce_driver delete mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testExpressionSortTopNKeepBeforeSort/local_reduce_physical_optimization_data_driver delete mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testExpressionSortTopNKeepBeforeSort/local_reduce_planned_data_driver delete mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testExpressionSortTopNKeepBeforeSort/local_reduce_planned_reduce_driver delete mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testLookupJoinOnDataNode/local_reduce_physical_optimization_data_driver delete mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testLookupJoinOnDataNode/local_reduce_planned_data_driver delete mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testLookupJoinOnDataNode/local_reduce_planned_reduce_driver delete mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testMultipleFieldSortTopN/local_reduce_physical_optimization_data_driver delete mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testMultipleFieldSortTopN/local_reduce_planned_data_driver delete mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testMultipleFieldSortTopN/local_reduce_planned_reduce_driver delete mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testMultipleTopN/local_reduce_physical_optimization_data_driver delete mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testMultipleTopN/local_reduce_planned_data_driver delete mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testMultipleTopN/local_reduce_planned_reduce_driver delete mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testMvExpandBeforeTopN/local_reduce_physical_optimization_data_driver delete mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testMvExpandBeforeTopN/local_reduce_physical_optimization_reduce_driver delete mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testMvExpandBeforeTopN/local_reduce_planned_data_driver delete mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testMvExpandBeforeTopN/local_reduce_planned_reduce_driver delete mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testPushedDownTopN/local_reduce_physical_optimization_data_driver delete mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testPushedDownTopN/local_reduce_planned_data_driver delete mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testPushedDownTopN/local_reduce_planned_reduce_driver delete mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testSomeFieldsNeededBeforeLateMaterialization/local_reduce_physical_optimization_data_driver delete mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testSomeFieldsNeededBeforeLateMaterialization/local_reduce_planned_data_driver delete mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testSomeFieldsNeededBeforeLateMaterialization/local_reduce_planned_reduce_driver delete mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testTopNThenStats/local_reduce_physical_optimization_data_driver delete mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testTopNThenStats/local_reduce_planned_data_driver delete mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testTopNThenStats/local_reduce_planned_reduce_driver delete mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testTopNWithMissingSortField/local_reduce_physical_optimization_data_driver delete mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testTopNWithMissingSortField/local_reduce_planned_data_driver delete mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testTopNWithMissingSortField/local_reduce_planned_reduce_driver diff --git a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/core/expression/Alias.java b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/core/expression/Alias.java index 348374f7b174e..6e8b20f5a05a7 100644 --- a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/core/expression/Alias.java +++ b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/core/expression/Alias.java @@ -143,7 +143,7 @@ public String toString() { @Override public String nodeString(NodeStringFormat format) { - return child.nodeString() + " AS " + name() + "#" + id(); + return child.nodeString(format) + " AS " + name() + "#" + id(); } /** diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/optimizer/GoldenTestCase.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/optimizer/GoldenTestCase.java index 9044b2e9918dd..387da6f8f0824 100644 --- a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/optimizer/GoldenTestCase.java +++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/optimizer/GoldenTestCase.java @@ -278,7 +278,7 @@ private List> doTests() throws IOException { // If there is no local node-reduce physical optimization, there's nothing to verify! case DISABLED -> { var foo = localOptimize(reductionPlan.dataNodePlan(), conf); - var bar = verifyOrWrite(foo, outputPath(dualFileOutput.dataNodeOutput())); + var bar = verifyOrWrite(foo, expectedOutputPath(dualFileOutput.dataNodeOutput())); result.add(Tuple.tuple(Stage.NODE_REDUCE_LOCAL_PHYSICAL_OPTIMIZATION, bar)); } case ENABLED -> { @@ -323,8 +323,8 @@ private List> addDualPlanResult( String nodeReduceName, String dataNodeName ) throws IOException { - var reduceResult = verifyOrWrite(plan.nodeReducePlan(), outputPath(nodeReduceName)); - var dataResult = verifyOrWrite(plan.dataNodePlan(), outputPath(dataNodeName)); + var reduceResult = verifyOrWrite(plan.nodeReducePlan(), expectedOutputPath(nodeReduceName)); + var dataResult = verifyOrWrite(plan.dataNodePlan(), expectedOutputPath(dataNodeName)); var result = new ArrayList>(); if (reduceResult == TestResult.FAILURE || dataResult == TestResult.FAILURE) { result.add(Tuple.tuple(stage, TestResult.FAILURE)); @@ -343,7 +343,7 @@ private List> addDualPlanResult( } private > TestResult verifyOrWrite(T plan, Stage stage) throws IOException { - return verifyOrWrite(plan, stageOutputPath(stage)); + return verifyOrWrite(plan, expectedOutputPath(stage)); } private > TestResult verifyOrWrite(T plan, Path outputFile) throws IOException { @@ -360,11 +360,11 @@ private > TestResult verifyOrWrite(T plan, Path outputFil } } - private Path stageOutputPath(Stage stage) { - return stageOutputPath(((SingleFileOutput) stage.fileOutput).output()); + private Path expectedOutputPath(Stage stage) { + return expectedOutputPath(((SingleFileOutput) stage.fileOutput).output()); } - private Path stageOutputPath(String stageName) { + private Path expectedOutputPath(String stageName) { return outputPath(stageName + ".expected"); } diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testStatsMultipleCountWhere/load/analysis.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testStatsMultipleCountWhere/load/analysis.expected index 7a9858e13cc71..a4fbd276de29c 100644 --- a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testStatsMultipleCountWhere/load/analysis.expected +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testStatsMultipleCountWhere/load/analysis.expected @@ -1,4 +1,3 @@ Limit[1000[INTEGER],false,false] -\_Aggregate[[],[FilteredExpression[COUNT(*[KEYWORD],true[BOOLEAN],PT0S[TIME_DURATION]),TOLONG(does_not_exist1{f}#0) > 0[INTEGER] OR emp_no{f}#1 -5 > 0[INTEGER] OR TOLONG(does_not_exist2{f}#2) < 100[INTEGER]] AS c1#3, FilteredExpression[COUNT(*[KEYWORD],true[BOOLEAN],PT0S[TIME_DURATION]),ISNULL(does_not_exist3{f}#4)] AS c2#5]] - \_EsRelation[employees][avg_worked_seconds{f}#6, birth_date{f}#7, emp_no{f}#8, first_name{f}#9, gender{f}#10, height{f}#11, height.float{f}#12, height.half_float{f}#13, height.scaled_float{f}#14, hire_date{f}#15, is_rehired{f}#16, job_positions{f}#17, languages{f}#18, languages.byte{f}#19, languages.long{f}#20, languages.short{f}#21, last_name{f}#22, salary{f}#23, salary_change{f}#24, salary_change.int{f}#25, salary_change.keyword{f}#26, salary_change.long{f}#27, still_hired{f}#28, does_not_exist1{f}#0, does_not_exist2{f}#2, does_not_exist3{f}#4] \ No newline at end of file +\_Aggregate[[],[FilteredExpression[COUNT(*[KEYWORD],true[BOOLEAN],PT0S[TIME_DURATION]),TOLONG(does_not_exist1{f}#0) > 0[INTEGER] OR emp_no{f}#1 > 0[INTEGER] OR TOLONG(does_not_exist2{f}#2) < 100[INTEGER]] AS c1#3, FilteredExpression[COUNT(*[KEYWORD],true[BOOLEAN],PT0S[TIME_DURATION]),ISNULL(does_not_exist3{f}#4)] AS c2#5]] + \_EsRelation[employees][avg_worked_seconds{f}#6, birth_date{f}#7, emp_no{f}#1, first_name{f}#8, gender{f}#9, height{f}#10, height.float{f}#11, height.half_float{f}#12, height.scaled_float{f}#13, hire_date{f}#14, is_rehired{f}#15, job_positions{f}#16, languages{f}#17, languages.byte{f}#18, languages.long{f}#19, languages.short{f}#20, last_name{f}#21, salary{f}#22, salary_change{f}#23, salary_change.int{f}#24, salary_change.keyword{f}#25, salary_change.long{f}#26, still_hired{f}#27, does_not_exist1{f}#0, does_not_exist2{f}#2, does_not_exist3{f}#4] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testStatsMultipleCountWhere/nullify/analysis.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testStatsMultipleCountWhere/nullify/analysis.expected index 1b1b5a8f9580e..6f8fec253f83b 100644 --- a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testStatsMultipleCountWhere/nullify/analysis.expected +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testStatsMultipleCountWhere/nullify/analysis.expected @@ -1,5 +1,4 @@ Limit[1000[INTEGER],false,false] -\_Aggregate[[],[FilteredExpression[COUNT(*[KEYWORD],true[BOOLEAN],PT0S[TIME_DURATION]),TOLONG(does_not_exist1{r}#0) > 0[INTEGER] OR emp_no{f}#1 -7 > 0[INTEGER] OR TOLONG(does_not_exist2{r}#2) < 100[INTEGER]] AS c1#3, FilteredExpression[COUNT(*[KEYWORD],true[BOOLEAN],PT0S[TIME_DURATION]),ISNULL(does_not_exist3{r}#4)] AS c2#5]] +\_Aggregate[[],[FilteredExpression[COUNT(*[KEYWORD],true[BOOLEAN],PT0S[TIME_DURATION]),TOLONG(does_not_exist1{r}#0) > 0[INTEGER] OR emp_no{f}#1 > 0[INTEGER] OR TOLONG(does_not_exist2{r}#2) < 100[INTEGER]] AS c1#3, FilteredExpression[COUNT(*[KEYWORD],true[BOOLEAN],PT0S[TIME_DURATION]),ISNULL(does_not_exist3{r}#4)] AS c2#5]] \_Eval[[null[NULL] AS does_not_exist1#0, null[NULL] AS does_not_exist2#2, null[NULL] AS does_not_exist3#4]] - \_EsRelation[employees][avg_worked_seconds{f}#6, birth_date{f}#7, emp_no{f}#8, first_name{f}#9, gender{f}#10, height{f}#11, height.float{f}#12, height.half_float{f}#13, height.scaled_float{f}#14, hire_date{f}#15, is_rehired{f}#16, job_positions{f}#17, languages{f}#18, languages.byte{f}#19, languages.long{f}#20, languages.short{f}#21, last_name{f}#22, salary{f}#23, salary_change{f}#24, salary_change.int{f}#25, salary_change.keyword{f}#26, salary_change.long{f}#27, still_hired{f}#28] \ No newline at end of file + \_EsRelation[employees][avg_worked_seconds{f}#6, birth_date{f}#7, emp_no{f}#1, first_name{f}#8, gender{f}#9, height{f}#10, height.float{f}#11, height.half_float{f}#12, height.scaled_float{f}#13, hire_date{f}#14, is_rehired{f}#15, job_positions{f}#16, languages{f}#17, languages.byte{f}#18, languages.long{f}#19, languages.short{f}#20, last_name{f}#21, salary{f}#22, salary_change{f}#23, salary_change.int{f}#24, salary_change.keyword{f}#25, salary_change.long{f}#26, still_hired{f}#27] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testBasicTopNLateMaterialization/local_reduce_physical_optimization_data_driver b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testBasicTopNLateMaterialization/local_reduce_physical_optimization_data_driver deleted file mode 100644 index 71c01677f83a5..0000000000000 --- a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testBasicTopNLateMaterialization/local_reduce_physical_optimization_data_driver +++ /dev/null @@ -1,4 +0,0 @@ -ExchangeSinkExec[[emp_no{f}#0, hire_date{f}#1, salary{f}#2],false] -\_ProjectExec[[_doc{f}#3, hire_date{f}#1]] - \_FieldExtractExec[hire_date{f}#1]<[],[]> - \_EsQueryExec[employees], indexMode[standard], [_doc{f}#3], limit[20], sort[[FieldSort[field=hire_date{f}#1, direction=ASC, nulls=LAST]]] estimatedRowSize[24] queryBuilderAndTags [[QueryBuilderAndTags[query=null, tags=[]]]] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testBasicTopNLateMaterialization/local_reduce_planned_data_driver b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testBasicTopNLateMaterialization/local_reduce_planned_data_driver deleted file mode 100644 index fc4d011c9a8fb..0000000000000 --- a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testBasicTopNLateMaterialization/local_reduce_planned_data_driver +++ /dev/null @@ -1,5 +0,0 @@ -ExchangeSinkExec[[emp_no{f}#0, hire_date{f}#1, salary{f}#2],false] -\_FragmentExec[filter=null, estimatedRowSize=0, reducer=[], fragment=[<> -Project[[_doc{f}#3, hire_date{f}#1]] -\_TopN[[Order[hire_date{f}#1,ASC,LAST]],20[INTEGER],false] - \_EsRelation[employees][_doc{f}#3, avg_worked_seconds{f}#4, birth_date{f}#5, emp_no{f}#0, first_name{f}#6, gender{f}#7, height{f}#8, height.float{f}#9, height.half_float{f}#10, height.scaled_float{f}#11, hire_date{f}#1, is_rehired{f}#12, job_positions{f}#13, languages{f}#14, languages.byte{f}#15, languages.long{f}#16, languages.short{f}#17, last_name{f}#18, salary{f}#2, salary_change{f}#19, salary_change.int{f}#20, salary_change.keyword{f}#21, salary_change.long{f}#22, still_hired{f}#23]<>]] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testBasicTopNLateMaterialization/local_reduce_planned_reduce_driver b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testBasicTopNLateMaterialization/local_reduce_planned_reduce_driver deleted file mode 100644 index 4b4fc0c891ac1..0000000000000 --- a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testBasicTopNLateMaterialization/local_reduce_planned_reduce_driver +++ /dev/null @@ -1,5 +0,0 @@ -ExchangeSinkExec[[emp_no{f}#0, hire_date{f}#1, salary{f}#2],false] -\_ProjectExec[[emp_no{f}#0, hire_date{f}#1, salary{f}#2]] - \_FieldExtractExec[emp_no{f}#0, salary{f}#2]<[],[]> - \_TopNExec[[Order[hire_date{f}#1,ASC,LAST]],20[INTEGER],36] - \_ExchangeSourceExec[[_doc{f}#3, hire_date{f}#1],false] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testExpressionSortTopNKeepAfterSort/local_reduce_physical_optimization_data_driver b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testExpressionSortTopNKeepAfterSort/local_reduce_physical_optimization_data_driver deleted file mode 100644 index 8f49d89b830ce..0000000000000 --- a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testExpressionSortTopNKeepAfterSort/local_reduce_physical_optimization_data_driver +++ /dev/null @@ -1,6 +0,0 @@ -ExchangeSinkExec[[hire_date{f}#0, $$order_by$0{r}#1],false] -\_ProjectExec[[_doc{f}#2, $$order_by$0{r}#1]] - \_TopNExec[[Order[$$order_by$0{r}#1,ASC,LAST]],20[INTEGER],36] - \_EvalExec[[SIN(height{f}#3) * 2[INTEGER] AS $$order_by$0#1]] - \_FieldExtractExec[height{f}#3]<[],[]> - \_EsQueryExec[employees], indexMode[standard], [_doc{f}#2], limit[], sort[] estimatedRowSize[20] queryBuilderAndTags [[QueryBuilderAndTags[query=null, tags=[]]]] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testExpressionSortTopNKeepAfterSort/local_reduce_planned_data_driver b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testExpressionSortTopNKeepAfterSort/local_reduce_planned_data_driver deleted file mode 100644 index 9ce3f748778c1..0000000000000 --- a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testExpressionSortTopNKeepAfterSort/local_reduce_planned_data_driver +++ /dev/null @@ -1,6 +0,0 @@ -ExchangeSinkExec[[hire_date{f}#0, $$order_by$0{r}#1],false] -\_FragmentExec[filter=null, estimatedRowSize=0, reducer=[], fragment=[<> -Project[[_doc{f}#2, $$order_by$0{r}#1]] -\_TopN[[Order[$$order_by$0{r}#1,ASC,LAST]],20[INTEGER],false] - \_Eval[[SIN(height{f}#3) * 2[INTEGER] AS $$order_by$0#1]] - \_EsRelation[employees][_doc{f}#2, avg_worked_seconds{f}#4, birth_date{f}#5, emp_no{f}#6, first_name{f}#7, gender{f}#8, height{f}#3, height.float{f}#9, height.half_float{f}#10, height.scaled_float{f}#11, hire_date{f}#0, is_rehired{f}#12, job_positions{f}#13, languages{f}#14, languages.byte{f}#15, languages.long{f}#16, languages.short{f}#17, last_name{f}#18, salary{f}#19, salary_change{f}#20, salary_change.int{f}#21, salary_change.keyword{f}#22, salary_change.long{f}#23, still_hired{f}#24]<>]] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testExpressionSortTopNKeepAfterSort/local_reduce_planned_reduce_driver b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testExpressionSortTopNKeepAfterSort/local_reduce_planned_reduce_driver deleted file mode 100644 index d2459818c5588..0000000000000 --- a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testExpressionSortTopNKeepAfterSort/local_reduce_planned_reduce_driver +++ /dev/null @@ -1,5 +0,0 @@ -ExchangeSinkExec[[hire_date{f}#0, $$order_by$0{r}#1],false] -\_ProjectExec[[hire_date{f}#0, $$order_by$0{r}#1]] - \_FieldExtractExec[hire_date{f}#0]<[],[]> - \_TopNExec[[Order[$$order_by$0{r}#1,ASC,LAST]],20[INTEGER],36] - \_ExchangeSourceExec[[_doc{f}#2, $$order_by$0{r}#1],false] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testExpressionSortTopNKeepBeforeSort/local_reduce_physical_optimization_data_driver b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testExpressionSortTopNKeepBeforeSort/local_reduce_physical_optimization_data_driver deleted file mode 100644 index 460cbcab3451e..0000000000000 --- a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testExpressionSortTopNKeepBeforeSort/local_reduce_physical_optimization_data_driver +++ /dev/null @@ -1,6 +0,0 @@ -ExchangeSinkExec[[height{f}#0, hire_date{f}#1, $$order_by$0{r}#2],false] -\_ProjectExec[[_doc{f}#3, height{f}#0, $$order_by$0{r}#2]] - \_TopNExec[[Order[$$order_by$0{r}#2,ASC,LAST]],20[INTEGER],36] - \_EvalExec[[SIN(height{f}#0) * 2[INTEGER] AS $$order_by$0#2]] - \_FieldExtractExec[height{f}#0]<[],[]> - \_EsQueryExec[employees], indexMode[standard], [_doc{f}#3], limit[], sort[] estimatedRowSize[20] queryBuilderAndTags [[QueryBuilderAndTags[query=null, tags=[]]]] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testExpressionSortTopNKeepBeforeSort/local_reduce_planned_data_driver b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testExpressionSortTopNKeepBeforeSort/local_reduce_planned_data_driver deleted file mode 100644 index 932c4834e7e80..0000000000000 --- a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testExpressionSortTopNKeepBeforeSort/local_reduce_planned_data_driver +++ /dev/null @@ -1,6 +0,0 @@ -ExchangeSinkExec[[height{f}#0, hire_date{f}#1, $$order_by$0{r}#2],false] -\_FragmentExec[filter=null, estimatedRowSize=0, reducer=[], fragment=[<> -Project[[_doc{f}#3, height{f}#0, $$order_by$0{r}#2]] -\_TopN[[Order[$$order_by$0{r}#2,ASC,LAST]],20[INTEGER],false] - \_Eval[[SIN(height{f}#0) * 2[INTEGER] AS $$order_by$0#2]] - \_EsRelation[employees][_doc{f}#3, avg_worked_seconds{f}#4, birth_date{f}#5, emp_no{f}#6, first_name{f}#7, gender{f}#8, height{f}#0, height.float{f}#9, height.half_float{f}#10, height.scaled_float{f}#11, hire_date{f}#1, is_rehired{f}#12, job_positions{f}#13, languages{f}#14, languages.byte{f}#15, languages.long{f}#16, languages.short{f}#17, last_name{f}#18, salary{f}#19, salary_change{f}#20, salary_change.int{f}#21, salary_change.keyword{f}#22, salary_change.long{f}#23, still_hired{f}#24]<>]] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testExpressionSortTopNKeepBeforeSort/local_reduce_planned_reduce_driver b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testExpressionSortTopNKeepBeforeSort/local_reduce_planned_reduce_driver deleted file mode 100644 index 88c85960c5dd2..0000000000000 --- a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testExpressionSortTopNKeepBeforeSort/local_reduce_planned_reduce_driver +++ /dev/null @@ -1,5 +0,0 @@ -ExchangeSinkExec[[height{f}#0, hire_date{f}#1, $$order_by$0{r}#2],false] -\_ProjectExec[[height{f}#0, hire_date{f}#1, $$order_by$0{r}#2]] - \_FieldExtractExec[hire_date{f}#1]<[],[]> - \_TopNExec[[Order[$$order_by$0{r}#2,ASC,LAST]],20[INTEGER],44] - \_ExchangeSourceExec[[_doc{f}#3, height{f}#0, $$order_by$0{r}#2],false] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testLookupJoinOnDataNode/local_reduce_physical_optimization_data_driver b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testLookupJoinOnDataNode/local_reduce_physical_optimization_data_driver deleted file mode 100644 index ebbbae1cfcc6d..0000000000000 --- a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testLookupJoinOnDataNode/local_reduce_physical_optimization_data_driver +++ /dev/null @@ -1,25 +0,0 @@ -ExchangeSinkExec[[avg_worked_seconds{f}#0, birth_date{f}#1, emp_no{f}#2, first_name{f}#3, gender{f}#4, height{f}#5, height.float{f}#6, height.half_float{f}#7, height.scaled_float{f}#8, hire_date{f}#9, is_rehired{f}#10, job_positions{f}#11, languages{f}#12, languages.byte{f}#13, languages.long{f}#14, languages.short{f}#15, last_name{f}#16, salary{f}#17, salary_change{f}#18, salary_change.int{f}#19, salary_change.keyword{f}#20, salary_change.long{f}#21, still_hired{f}#22, language_code{r}#23, language_name{f}#24],false] -\_ProjectExec[[_doc{f}#25, emp_no{f}#2, languages{f}#12, language_code{r}#23, language_name{f}#24]] - \_TopNExec[[Order[emp_no{f}#2,ASC,LAST]],20[INTEGER],82] - \_FieldExtractExec[emp_no{f}#2]<[],[]> - \_LookupJoinExec[[language_code{r}#23],[language_code{f}#26],[language_name{f}#24],null] - |_EvalExec[[languages{f}#12 AS language_code#23]] - | \_FieldExtractExec[languages{f}#12]<[],[]> - | \_EsQueryExec[employees], indexMode[standard], [_doc{f}#25], limit[], sort[] estimatedRowSize[66] queryBuilderAndTags [[QueryBuilderAndTags[query={ - "esql_single_value" : { - "field" : "emp_no", - "next" : { - "range" : { - "emp_no" : { - "gte" : 10091, - "lt" : 10094, - "time_zone" : "Z", - "boost" : 0.0 - } - } - }, - "source" : "emp_no >= 10091@4:9" - } -}, tags=[]]]] - \_FragmentExec[filter=null, estimatedRowSize=0, reducer=[], fragment=[<> -EsRelation[languages_lookup][LOOKUP][language_code{f}#26, language_name{f}#24]<>]] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testLookupJoinOnDataNode/local_reduce_planned_data_driver b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testLookupJoinOnDataNode/local_reduce_planned_data_driver deleted file mode 100644 index 7ff68ac134d83..0000000000000 --- a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testLookupJoinOnDataNode/local_reduce_planned_data_driver +++ /dev/null @@ -1,9 +0,0 @@ -ExchangeSinkExec[[avg_worked_seconds{f}#0, birth_date{f}#1, emp_no{f}#2, first_name{f}#3, gender{f}#4, height{f}#5, height.float{f}#6, height.half_float{f}#7, height.scaled_float{f}#8, hire_date{f}#9, is_rehired{f}#10, job_positions{f}#11, languages{f}#12, languages.byte{f}#13, languages.long{f}#14, languages.short{f}#15, last_name{f}#16, salary{f}#17, salary_change{f}#18, salary_change.int{f}#19, salary_change.keyword{f}#20, salary_change.long{f}#21, still_hired{f}#22, language_code{r}#23, language_name{f}#24],false] -\_FragmentExec[filter=null, estimatedRowSize=0, reducer=[], fragment=[<> -Project[[_doc{f}#25, emp_no{f}#2, languages{f}#12, language_code{r}#23, language_name{f}#24]] -\_TopN[[Order[emp_no{f}#2,ASC,LAST]],20[INTEGER],false] - \_Join[LEFT,[language_code{r}#23],[language_code{f}#26],null] - |_Eval[[languages{f}#12 AS language_code#23]] - | \_Filter[emp_no{f}#2 >= 10091[INTEGER] AND emp_no{f}#2 < 10094[INTEGER]] - | \_EsRelation[employees][_doc{f}#25, avg_worked_seconds{f}#0, birth_date{f}#1, emp_no{f}#2, first_name{f}#3, gender{f}#4, height{f}#5, height.float{f}#6, height.half_float{f}#7, height.scaled_float{f}#8, hire_date{f}#9, is_rehired{f}#10, job_positions{f}#11, languages{f}#12, languages.byte{f}#13, languages.long{f}#14, languages.short{f}#15, last_name{f}#16, salary{f}#17, salary_change{f}#18, salary_change.int{f}#19, salary_change.keyword{f}#20, salary_change.long{f}#21, still_hired{f}#22] - \_EsRelation[languages_lookup][LOOKUP][language_code{f}#26, language_name{f}#24]<>]] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testLookupJoinOnDataNode/local_reduce_planned_reduce_driver b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testLookupJoinOnDataNode/local_reduce_planned_reduce_driver deleted file mode 100644 index 19c98b1780f37..0000000000000 --- a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testLookupJoinOnDataNode/local_reduce_planned_reduce_driver +++ /dev/null @@ -1,5 +0,0 @@ -ExchangeSinkExec[[avg_worked_seconds{f}#0, birth_date{f}#1, emp_no{f}#2, first_name{f}#3, gender{f}#4, height{f}#5, height.float{f}#6, height.half_float{f}#7, height.scaled_float{f}#8, hire_date{f}#9, is_rehired{f}#10, job_positions{f}#11, languages{f}#12, languages.byte{f}#13, languages.long{f}#14, languages.short{f}#15, last_name{f}#16, salary{f}#17, salary_change{f}#18, salary_change.int{f}#19, salary_change.keyword{f}#20, salary_change.long{f}#21, still_hired{f}#22, language_code{r}#23, language_name{f}#24],false] -\_ProjectExec[[avg_worked_seconds{f}#0, birth_date{f}#1, emp_no{f}#2, first_name{f}#3, gender{f}#4, height{f}#5, height.float{f}#6, height.half_float{f}#7, height.scaled_float{f}#8, hire_date{f}#9, is_rehired{f}#10, job_positions{f}#11, languages{f}#12, languages.byte{f}#13, languages.long{f}#14, languages.short{f}#15, last_name{f}#16, salary{f}#17, salary_change{f}#18, salary_change.int{f}#19, salary_change.keyword{f}#20, salary_change.long{f}#21, still_hired{f}#22, language_code{r}#23, language_name{f}#24]] - \_FieldExtractExec[avg_worked_seconds{f}#0, birth_date{f}#1, first_name{f}#3, gender{f}#4, height{f}#5, height.float{f}#6, height.half_float{f}#7, height.scaled_float{f}#8, hire_date{f}#9, is_rehired{f}#10, job_positions{f}#11, languages.byte{f}#13, languages.long{f}#14, languages.short{f}#15, last_name{f}#16, salary{f}#17, salary_change{f}#18, salary_change.int{f}#19, salary_change.keyword{f}#20, salary_change.long{f}#21, still_hired{f}#22]<[],[]> - \_TopNExec[[Order[emp_no{f}#2,ASC,LAST]],20[INTEGER],430] - \_ExchangeSourceExec[[_doc{f}#25, emp_no{f}#2, languages{f}#12, language_code{r}#23, language_name{f}#24],false] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testMultipleFieldSortTopN/local_reduce_physical_optimization_data_driver b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testMultipleFieldSortTopN/local_reduce_physical_optimization_data_driver deleted file mode 100644 index e5de0b72a7705..0000000000000 --- a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testMultipleFieldSortTopN/local_reduce_physical_optimization_data_driver +++ /dev/null @@ -1,4 +0,0 @@ -ExchangeSinkExec[[emp_no{f}#0, height{f}#1, hire_date{f}#2],false] -\_ProjectExec[[_doc{f}#3, hire_date{f}#2, height{f}#1]] - \_FieldExtractExec[hire_date{f}#2, height{f}#1]<[],[]> - \_EsQueryExec[employees], indexMode[standard], [_doc{f}#3], limit[20], sort[[FieldSort[field=hire_date{f}#2, direction=ASC, nulls=LAST], FieldSort[field=height{f}#1, direction=ASC, nulls=LAST]]] estimatedRowSize[32] queryBuilderAndTags [[QueryBuilderAndTags[query=null, tags=[]]]] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testMultipleFieldSortTopN/local_reduce_planned_data_driver b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testMultipleFieldSortTopN/local_reduce_planned_data_driver deleted file mode 100644 index 4866ac15c30c3..0000000000000 --- a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testMultipleFieldSortTopN/local_reduce_planned_data_driver +++ /dev/null @@ -1,5 +0,0 @@ -ExchangeSinkExec[[emp_no{f}#0, height{f}#1, hire_date{f}#2],false] -\_FragmentExec[filter=null, estimatedRowSize=0, reducer=[], fragment=[<> -Project[[_doc{f}#3, hire_date{f}#2, height{f}#1]] -\_TopN[[Order[hire_date{f}#2,ASC,LAST], Order[height{f}#1,ASC,LAST]],20[INTEGER],false] - \_EsRelation[employees][_doc{f}#3, avg_worked_seconds{f}#4, birth_date{f}#5, emp_no{f}#0, first_name{f}#6, gender{f}#7, height{f}#1, height.float{f}#8, height.half_float{f}#9, height.scaled_float{f}#10, hire_date{f}#2, is_rehired{f}#11, job_positions{f}#12, languages{f}#13, languages.byte{f}#14, languages.long{f}#15, languages.short{f}#16, last_name{f}#17, salary{f}#18, salary_change{f}#19, salary_change.int{f}#20, salary_change.keyword{f}#21, salary_change.long{f}#22, still_hired{f}#23]<>]] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testMultipleFieldSortTopN/local_reduce_planned_reduce_driver b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testMultipleFieldSortTopN/local_reduce_planned_reduce_driver deleted file mode 100644 index ab96def3b448c..0000000000000 --- a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testMultipleFieldSortTopN/local_reduce_planned_reduce_driver +++ /dev/null @@ -1,5 +0,0 @@ -ExchangeSinkExec[[emp_no{f}#0, height{f}#1, hire_date{f}#2],false] -\_ProjectExec[[emp_no{f}#0, height{f}#1, hire_date{f}#2]] - \_FieldExtractExec[emp_no{f}#0]<[],[]> - \_TopNExec[[Order[hire_date{f}#2,ASC,LAST], Order[height{f}#1,ASC,LAST]],20[INTEGER],40] - \_ExchangeSourceExec[[_doc{f}#3, hire_date{f}#2, height{f}#1],false] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testMultipleTopN/local_reduce_physical_optimization_data_driver b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testMultipleTopN/local_reduce_physical_optimization_data_driver deleted file mode 100644 index 71c01677f83a5..0000000000000 --- a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testMultipleTopN/local_reduce_physical_optimization_data_driver +++ /dev/null @@ -1,4 +0,0 @@ -ExchangeSinkExec[[emp_no{f}#0, hire_date{f}#1, salary{f}#2],false] -\_ProjectExec[[_doc{f}#3, hire_date{f}#1]] - \_FieldExtractExec[hire_date{f}#1]<[],[]> - \_EsQueryExec[employees], indexMode[standard], [_doc{f}#3], limit[20], sort[[FieldSort[field=hire_date{f}#1, direction=ASC, nulls=LAST]]] estimatedRowSize[24] queryBuilderAndTags [[QueryBuilderAndTags[query=null, tags=[]]]] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testMultipleTopN/local_reduce_planned_data_driver b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testMultipleTopN/local_reduce_planned_data_driver deleted file mode 100644 index fc4d011c9a8fb..0000000000000 --- a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testMultipleTopN/local_reduce_planned_data_driver +++ /dev/null @@ -1,5 +0,0 @@ -ExchangeSinkExec[[emp_no{f}#0, hire_date{f}#1, salary{f}#2],false] -\_FragmentExec[filter=null, estimatedRowSize=0, reducer=[], fragment=[<> -Project[[_doc{f}#3, hire_date{f}#1]] -\_TopN[[Order[hire_date{f}#1,ASC,LAST]],20[INTEGER],false] - \_EsRelation[employees][_doc{f}#3, avg_worked_seconds{f}#4, birth_date{f}#5, emp_no{f}#0, first_name{f}#6, gender{f}#7, height{f}#8, height.float{f}#9, height.half_float{f}#10, height.scaled_float{f}#11, hire_date{f}#1, is_rehired{f}#12, job_positions{f}#13, languages{f}#14, languages.byte{f}#15, languages.long{f}#16, languages.short{f}#17, last_name{f}#18, salary{f}#2, salary_change{f}#19, salary_change.int{f}#20, salary_change.keyword{f}#21, salary_change.long{f}#22, still_hired{f}#23]<>]] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testMultipleTopN/local_reduce_planned_reduce_driver b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testMultipleTopN/local_reduce_planned_reduce_driver deleted file mode 100644 index 4b4fc0c891ac1..0000000000000 --- a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testMultipleTopN/local_reduce_planned_reduce_driver +++ /dev/null @@ -1,5 +0,0 @@ -ExchangeSinkExec[[emp_no{f}#0, hire_date{f}#1, salary{f}#2],false] -\_ProjectExec[[emp_no{f}#0, hire_date{f}#1, salary{f}#2]] - \_FieldExtractExec[emp_no{f}#0, salary{f}#2]<[],[]> - \_TopNExec[[Order[hire_date{f}#1,ASC,LAST]],20[INTEGER],36] - \_ExchangeSourceExec[[_doc{f}#3, hire_date{f}#1],false] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testMvExpandBeforeTopN/local_reduce_physical_optimization_data_driver b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testMvExpandBeforeTopN/local_reduce_physical_optimization_data_driver deleted file mode 100644 index f0d827b7d0c99..0000000000000 --- a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testMvExpandBeforeTopN/local_reduce_physical_optimization_data_driver +++ /dev/null @@ -1,7 +0,0 @@ -ExchangeSinkExec[[emp_no{f}#0, job_positions{r}#1, salary{f}#2],false] -\_ProjectExec[[emp_no{f}#0, job_positions{r}#1, salary{f}#2]] - \_TopNExec[[Order[salary{f}#2,ASC,LAST]],20[INTEGER],58] - \_MvExpandExec[job_positions{f}#3,job_positions{r}#1] - \_ProjectExec[[emp_no{f}#0, job_positions{f}#3, salary{f}#2]] - \_FieldExtractExec[emp_no{f}#0, job_positions{f}#3, salary{f}#2]<[],[]> - \_EsQueryExec[employees], indexMode[standard], [_doc{f}#4], limit[], sort[] estimatedRowSize[62] queryBuilderAndTags [[QueryBuilderAndTags[query=null, tags=[]]]] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testMvExpandBeforeTopN/local_reduce_physical_optimization_reduce_driver b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testMvExpandBeforeTopN/local_reduce_physical_optimization_reduce_driver deleted file mode 100644 index a9639e399dec8..0000000000000 --- a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testMvExpandBeforeTopN/local_reduce_physical_optimization_reduce_driver +++ /dev/null @@ -1,3 +0,0 @@ -ExchangeSinkExec[[emp_no{f}#0, job_positions{r}#1, salary{f}#2],false] -\_TopNExec[[Order[salary{f}#2,ASC,LAST]],20[INTEGER],58] - \_ExchangeSourceExec[[emp_no{f}#0, job_positions{r}#1, salary{f}#2],false] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testMvExpandBeforeTopN/local_reduce_planned_data_driver b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testMvExpandBeforeTopN/local_reduce_planned_data_driver deleted file mode 100644 index baf5e66932990..0000000000000 --- a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testMvExpandBeforeTopN/local_reduce_planned_data_driver +++ /dev/null @@ -1,7 +0,0 @@ -ExchangeSinkExec[[emp_no{f}#0, job_positions{r}#1, salary{f}#2],false] -\_FragmentExec[filter=null, estimatedRowSize=0, reducer=[], fragment=[<> -Project[[emp_no{f}#0, job_positions{r}#1, salary{f}#2]] -\_TopN[[Order[salary{f}#2,ASC,LAST]],20[INTEGER],false] - \_MvExpand[job_positions{f}#3,job_positions{r}#1] - \_Project[[emp_no{f}#0, job_positions{f}#3, salary{f}#2]] - \_EsRelation[employees][avg_worked_seconds{f}#4, birth_date{f}#5, emp_no{f}#0, first_name{f}#6, gender{f}#7, height{f}#8, height.float{f}#9, height.half_float{f}#10, height.scaled_float{f}#11, hire_date{f}#12, is_rehired{f}#13, job_positions{f}#3, languages{f}#14, languages.byte{f}#15, languages.long{f}#16, languages.short{f}#17, last_name{f}#18, salary{f}#2, salary_change{f}#19, salary_change.int{f}#20, salary_change.keyword{f}#21, salary_change.long{f}#22, still_hired{f}#23]<>]] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testMvExpandBeforeTopN/local_reduce_planned_reduce_driver b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testMvExpandBeforeTopN/local_reduce_planned_reduce_driver deleted file mode 100644 index a9639e399dec8..0000000000000 --- a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testMvExpandBeforeTopN/local_reduce_planned_reduce_driver +++ /dev/null @@ -1,3 +0,0 @@ -ExchangeSinkExec[[emp_no{f}#0, job_positions{r}#1, salary{f}#2],false] -\_TopNExec[[Order[salary{f}#2,ASC,LAST]],20[INTEGER],58] - \_ExchangeSourceExec[[emp_no{f}#0, job_positions{r}#1, salary{f}#2],false] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testPushedDownTopN/local_reduce_physical_optimization_data_driver b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testPushedDownTopN/local_reduce_physical_optimization_data_driver deleted file mode 100644 index cebf3f704c28d..0000000000000 --- a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testPushedDownTopN/local_reduce_physical_optimization_data_driver +++ /dev/null @@ -1,4 +0,0 @@ -ExchangeSinkExec[[emp_no{f}#0, height{f}#1],false] -\_ProjectExec[[_doc{f}#2, height{f}#1]] - \_FieldExtractExec[height{f}#1]<[],[]> - \_EsQueryExec[employees], indexMode[standard], [_doc{f}#2], limit[20], sort[[FieldSort[field=height{f}#1, direction=ASC, nulls=LAST]]] estimatedRowSize[24] queryBuilderAndTags [[QueryBuilderAndTags[query=null, tags=[]]]] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testPushedDownTopN/local_reduce_planned_data_driver b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testPushedDownTopN/local_reduce_planned_data_driver deleted file mode 100644 index b2913dbdf505b..0000000000000 --- a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testPushedDownTopN/local_reduce_planned_data_driver +++ /dev/null @@ -1,5 +0,0 @@ -ExchangeSinkExec[[emp_no{f}#0, height{f}#1],false] -\_FragmentExec[filter=null, estimatedRowSize=0, reducer=[], fragment=[<> -Project[[_doc{f}#2, height{f}#1]] -\_TopN[[Order[height{f}#1,ASC,LAST]],20[INTEGER],false] - \_EsRelation[employees][_doc{f}#2, avg_worked_seconds{f}#3, birth_date{f}#4, emp_no{f}#0, first_name{f}#5, gender{f}#6, height{f}#1, height.float{f}#7, height.half_float{f}#8, height.scaled_float{f}#9, hire_date{f}#10, is_rehired{f}#11, job_positions{f}#12, languages{f}#13, languages.byte{f}#14, languages.long{f}#15, languages.short{f}#16, last_name{f}#17, salary{f}#18, salary_change{f}#19, salary_change.int{f}#20, salary_change.keyword{f}#21, salary_change.long{f}#22, still_hired{f}#23]<>]] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testPushedDownTopN/local_reduce_planned_reduce_driver b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testPushedDownTopN/local_reduce_planned_reduce_driver deleted file mode 100644 index 3425364e715c1..0000000000000 --- a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testPushedDownTopN/local_reduce_planned_reduce_driver +++ /dev/null @@ -1,5 +0,0 @@ -ExchangeSinkExec[[emp_no{f}#0, height{f}#1],false] -\_ProjectExec[[emp_no{f}#0, height{f}#1]] - \_FieldExtractExec[emp_no{f}#0]<[],[]> - \_TopNExec[[Order[height{f}#1,ASC,LAST]],20[INTEGER],32] - \_ExchangeSourceExec[[_doc{f}#2, height{f}#1],false] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testSomeFieldsNeededBeforeLateMaterialization/local_reduce_physical_optimization_data_driver b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testSomeFieldsNeededBeforeLateMaterialization/local_reduce_physical_optimization_data_driver deleted file mode 100644 index 91fa3beaa5567..0000000000000 --- a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testSomeFieldsNeededBeforeLateMaterialization/local_reduce_physical_optimization_data_driver +++ /dev/null @@ -1,17 +0,0 @@ -ExchangeSinkExec[[emp_no{f}#0, hire_date{f}#1, salary{f}#2],false] -\_ProjectExec[[_doc{f}#3, salary{f}#2, hire_date{f}#1]] - \_FieldExtractExec[salary{f}#2, hire_date{f}#1]<[],[]> - \_EsQueryExec[employees], indexMode[standard], [_doc{f}#3], limit[20], sort[[FieldSort[field=hire_date{f}#1, direction=ASC, nulls=LAST]]] estimatedRowSize[28] queryBuilderAndTags [[QueryBuilderAndTags[query={ - "esql_single_value" : { - "field" : "salary", - "next" : { - "range" : { - "salary" : { - "gt" : 10000, - "boost" : 0.0 - } - } - }, - "source" : "salary > 10000@3:9" - } -}, tags=[]]]] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testSomeFieldsNeededBeforeLateMaterialization/local_reduce_planned_data_driver b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testSomeFieldsNeededBeforeLateMaterialization/local_reduce_planned_data_driver deleted file mode 100644 index 1e90a18573c7c..0000000000000 --- a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testSomeFieldsNeededBeforeLateMaterialization/local_reduce_planned_data_driver +++ /dev/null @@ -1,6 +0,0 @@ -ExchangeSinkExec[[emp_no{f}#0, hire_date{f}#1, salary{f}#2],false] -\_FragmentExec[filter=null, estimatedRowSize=0, reducer=[], fragment=[<> -Project[[_doc{f}#3, salary{f}#2, hire_date{f}#1]] -\_TopN[[Order[hire_date{f}#1,ASC,LAST]],20[INTEGER],false] - \_Filter[salary{f}#2 > 10000[INTEGER]] - \_EsRelation[employees][_doc{f}#3, avg_worked_seconds{f}#4, birth_date{f}#5, emp_no{f}#0, first_name{f}#6, gender{f}#7, height{f}#8, height.float{f}#9, height.half_float{f}#10, height.scaled_float{f}#11, hire_date{f}#1, is_rehired{f}#12, job_positions{f}#13, languages{f}#14, languages.byte{f}#15, languages.long{f}#16, languages.short{f}#17, last_name{f}#18, salary{f}#2, salary_change{f}#19, salary_change.int{f}#20, salary_change.keyword{f}#21, salary_change.long{f}#22, still_hired{f}#23]<>]] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testSomeFieldsNeededBeforeLateMaterialization/local_reduce_planned_reduce_driver b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testSomeFieldsNeededBeforeLateMaterialization/local_reduce_planned_reduce_driver deleted file mode 100644 index 178d31ccc5dc1..0000000000000 --- a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testSomeFieldsNeededBeforeLateMaterialization/local_reduce_planned_reduce_driver +++ /dev/null @@ -1,5 +0,0 @@ -ExchangeSinkExec[[emp_no{f}#0, hire_date{f}#1, salary{f}#2],false] -\_ProjectExec[[emp_no{f}#0, hire_date{f}#1, salary{f}#2]] - \_FieldExtractExec[emp_no{f}#0]<[],[]> - \_TopNExec[[Order[hire_date{f}#1,ASC,LAST]],20[INTEGER],36] - \_ExchangeSourceExec[[_doc{f}#3, salary{f}#2, hire_date{f}#1],false] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testTopNThenStats/local_reduce_physical_optimization_data_driver b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testTopNThenStats/local_reduce_physical_optimization_data_driver deleted file mode 100644 index 8dc76dd8b28df..0000000000000 --- a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testTopNThenStats/local_reduce_physical_optimization_data_driver +++ /dev/null @@ -1,4 +0,0 @@ -ExchangeSinkExec[[hire_date{f}#0, salary{f}#1],false] -\_ProjectExec[[_doc{f}#2, hire_date{f}#0]] - \_FieldExtractExec[hire_date{f}#0]<[],[]> - \_EsQueryExec[employees], indexMode[standard], [_doc{f}#2], limit[20], sort[[FieldSort[field=hire_date{f}#0, direction=ASC, nulls=LAST]]] estimatedRowSize[24] queryBuilderAndTags [[QueryBuilderAndTags[query=null, tags=[]]]] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testTopNThenStats/local_reduce_planned_data_driver b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testTopNThenStats/local_reduce_planned_data_driver deleted file mode 100644 index 070d12cb17d93..0000000000000 --- a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testTopNThenStats/local_reduce_planned_data_driver +++ /dev/null @@ -1,5 +0,0 @@ -ExchangeSinkExec[[hire_date{f}#0, salary{f}#1],false] -\_FragmentExec[filter=null, estimatedRowSize=0, reducer=[], fragment=[<> -Project[[_doc{f}#2, hire_date{f}#0]] -\_TopN[[Order[hire_date{f}#0,ASC,LAST]],20[INTEGER],false] - \_EsRelation[employees][_doc{f}#2, avg_worked_seconds{f}#3, birth_date{f}#4, emp_no{f}#5, first_name{f}#6, gender{f}#7, height{f}#8, height.float{f}#9, height.half_float{f}#10, height.scaled_float{f}#11, hire_date{f}#0, is_rehired{f}#12, job_positions{f}#13, languages{f}#14, languages.byte{f}#15, languages.long{f}#16, languages.short{f}#17, last_name{f}#18, salary{f}#1, salary_change{f}#19, salary_change.int{f}#20, salary_change.keyword{f}#21, salary_change.long{f}#22, still_hired{f}#23]<>]] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testTopNThenStats/local_reduce_planned_reduce_driver b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testTopNThenStats/local_reduce_planned_reduce_driver deleted file mode 100644 index 3c81025a6c14e..0000000000000 --- a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testTopNThenStats/local_reduce_planned_reduce_driver +++ /dev/null @@ -1,5 +0,0 @@ -ExchangeSinkExec[[hire_date{f}#0, salary{f}#1],false] -\_ProjectExec[[hire_date{f}#0, salary{f}#1]] - \_FieldExtractExec[salary{f}#1]<[],[]> - \_TopNExec[[Order[hire_date{f}#0,ASC,LAST]],20[INTEGER],32] - \_ExchangeSourceExec[[_doc{f}#2, hire_date{f}#0],false] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testTopNWithMissingSortField/local_reduce_physical_optimization_data_driver b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testTopNWithMissingSortField/local_reduce_physical_optimization_data_driver deleted file mode 100644 index 0280707cf7711..0000000000000 --- a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testTopNWithMissingSortField/local_reduce_physical_optimization_data_driver +++ /dev/null @@ -1,4 +0,0 @@ -ExchangeSinkExec[[emp_no{f}#0, hire_date{f}#1, salary{f}#2],false] -\_ProjectExec[[_doc{f}#3, birth_date{r}#4 AS hire_date#1]] - \_EvalExec[[null[DATETIME] AS birth_date#4]] - \_EsQueryExec[employees], indexMode[standard], [_doc{f}#3], limit[20], sort[] estimatedRowSize[12] queryBuilderAndTags [[QueryBuilderAndTags[query=null, tags=[]]]] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testTopNWithMissingSortField/local_reduce_planned_data_driver b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testTopNWithMissingSortField/local_reduce_planned_data_driver deleted file mode 100644 index fc4d011c9a8fb..0000000000000 --- a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testTopNWithMissingSortField/local_reduce_planned_data_driver +++ /dev/null @@ -1,5 +0,0 @@ -ExchangeSinkExec[[emp_no{f}#0, hire_date{f}#1, salary{f}#2],false] -\_FragmentExec[filter=null, estimatedRowSize=0, reducer=[], fragment=[<> -Project[[_doc{f}#3, hire_date{f}#1]] -\_TopN[[Order[hire_date{f}#1,ASC,LAST]],20[INTEGER],false] - \_EsRelation[employees][_doc{f}#3, avg_worked_seconds{f}#4, birth_date{f}#5, emp_no{f}#0, first_name{f}#6, gender{f}#7, height{f}#8, height.float{f}#9, height.half_float{f}#10, height.scaled_float{f}#11, hire_date{f}#1, is_rehired{f}#12, job_positions{f}#13, languages{f}#14, languages.byte{f}#15, languages.long{f}#16, languages.short{f}#17, last_name{f}#18, salary{f}#2, salary_change{f}#19, salary_change.int{f}#20, salary_change.keyword{f}#21, salary_change.long{f}#22, still_hired{f}#23]<>]] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testTopNWithMissingSortField/local_reduce_planned_reduce_driver b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testTopNWithMissingSortField/local_reduce_planned_reduce_driver deleted file mode 100644 index 4b4fc0c891ac1..0000000000000 --- a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testTopNWithMissingSortField/local_reduce_planned_reduce_driver +++ /dev/null @@ -1,5 +0,0 @@ -ExchangeSinkExec[[emp_no{f}#0, hire_date{f}#1, salary{f}#2],false] -\_ProjectExec[[emp_no{f}#0, hire_date{f}#1, salary{f}#2]] - \_FieldExtractExec[emp_no{f}#0, salary{f}#2]<[],[]> - \_TopNExec[[Order[hire_date{f}#1,ASC,LAST]],20[INTEGER],36] - \_ExchangeSourceExec[[_doc{f}#3, hire_date{f}#1],false] \ No newline at end of file From 4c8ae6353663a75e9e3c6893a5267bd8e3d36f94 Mon Sep 17 00:00:00 2001 From: Gal Lalouche Date: Tue, 3 Feb 2026 21:16:52 +0200 Subject: [PATCH 18/25] Added more tests --- .../analysis/AnalyzerUnmappedGoldenTests.java | 110 +++++++++++++++++- .../testCoalesce/load/analysis.expected | 4 + .../testCoalesce/load/query.esql | 3 + .../testCoalesce/nullify/analysis.expected | 5 + .../testCoalesce/nullify/query.esql | 3 + .../testFork/load/analysis.expected | 13 +++ .../testFork/load/query.esql | 3 + .../testFork/nullify/analysis.expected | 14 +++ .../testFork/nullify/query.esql | 3 + .../testForkWithEval/load/analysis.expected | 14 +++ .../testForkWithEval/load/query.esql | 3 + .../nullify/analysis.expected | 15 +++ .../testForkWithEval/nullify/query.esql | 3 + .../testForkWithSort/load/analysis.expected | 19 +++ .../testForkWithSort/load/query.esql | 4 + .../nullify/analysis.expected | 21 ++++ .../testForkWithSort/nullify/query.esql | 4 + .../testForkWithStats/load/analysis.expected | 15 +++ .../testForkWithStats/load/query.esql | 4 + .../nullify/analysis.expected | 16 +++ .../testForkWithStats/nullify/query.esql | 4 + .../testLookupJoin/load/analysis.expected | 5 + .../testLookupJoin/load/query.esql | 3 + .../testLookupJoin/nullify/analysis.expected | 6 + .../testLookupJoin/nullify/query.esql | 3 + .../load/analysis.expected | 6 + .../testLookupJoinWithEval/load/query.esql | 4 + .../nullify/analysis.expected | 7 ++ .../testLookupJoinWithEval/nullify/query.esql | 4 + .../load/analysis.expected | 6 + .../testLookupJoinWithFilter/load/query.esql | 4 + .../nullify/analysis.expected | 7 ++ .../nullify/query.esql | 4 + .../testSubquery/load/analysis.expected | 11 ++ .../testSubquery/load/query.esql | 2 + .../testSubquery/nullify/analysis.expected | 12 ++ .../testSubquery/nullify/query.esql | 2 + .../load/analysis.expected | 11 ++ .../load/query.esql | 3 + .../nullify/analysis.expected | 12 ++ .../nullify/query.esql | 3 + .../load/analysis.expected | 11 ++ .../testSubqueryKeepUnmapped/load/query.esql | 2 + .../nullify/analysis.expected | 12 ++ .../nullify/query.esql | 2 + .../load/analysis.expected | 21 ++++ .../load/query.esql | 5 + .../nullify/analysis.expected | 23 ++++ .../nullify/query.esql | 5 + .../load/analysis.expected | 11 ++ .../testSubqueryWithStats/load/query.esql | 2 + .../nullify/analysis.expected | 12 ++ .../testSubqueryWithStats/nullify/query.esql | 2 + .../testTBucket/load/analysis.expected | 4 + .../testTBucket/load/query.esql | 3 + .../testTBucket/nullify/analysis.expected | 5 + .../testTBucket/nullify/query.esql | 3 + .../load/analysis.expected | 3 + .../load/query.esql | 2 + .../nullify/analysis.expected | 4 + .../nullify/query.esql | 2 + .../load/analysis.expected | 3 + .../load/query.esql | 2 + .../nullify/analysis.expected | 4 + .../nullify/query.esql | 2 + .../load/analysis.expected | 3 + .../load/query.esql | 2 + .../nullify/analysis.expected | 4 + .../nullify/query.esql | 2 + .../load/analysis.expected | 4 + .../testTimeSeriesAvgOverTime/load/query.esql | 3 + .../nullify/analysis.expected | 5 + .../nullify/query.esql | 3 + .../load/analysis.expected | 4 + .../load/query.esql | 3 + .../nullify/analysis.expected | 5 + .../nullify/query.esql | 3 + .../load/analysis.expected | 3 + .../load/query.esql | 2 + .../nullify/analysis.expected | 4 + .../nullify/query.esql | 2 + .../load/analysis.expected | 3 + .../load/query.esql | 2 + .../nullify/analysis.expected | 4 + .../nullify/query.esql | 2 + .../load/analysis.expected | 4 + .../testTimeSeriesMaxOverTime/load/query.esql | 3 + .../nullify/analysis.expected | 5 + .../nullify/query.esql | 3 + .../testTimeSeriesRate/load/analysis.expected | 4 + .../testTimeSeriesRate/load/query.esql | 3 + .../nullify/analysis.expected | 5 + .../testTimeSeriesRate/nullify/query.esql | 3 + .../nullify/analysis.expected | 4 + .../nullify/query.esql | 2 + .../nullify/query.esql | 2 + 96 files changed, 638 insertions(+), 3 deletions(-) create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testCoalesce/load/analysis.expected create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testCoalesce/load/query.esql create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testCoalesce/nullify/analysis.expected create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testCoalesce/nullify/query.esql create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testFork/load/analysis.expected create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testFork/load/query.esql create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testFork/nullify/analysis.expected create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testFork/nullify/query.esql create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testForkWithEval/load/analysis.expected create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testForkWithEval/load/query.esql create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testForkWithEval/nullify/analysis.expected create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testForkWithEval/nullify/query.esql create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testForkWithSort/load/analysis.expected create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testForkWithSort/load/query.esql create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testForkWithSort/nullify/analysis.expected create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testForkWithSort/nullify/query.esql create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testForkWithStats/load/analysis.expected create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testForkWithStats/load/query.esql create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testForkWithStats/nullify/analysis.expected create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testForkWithStats/nullify/query.esql create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testLookupJoin/load/analysis.expected create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testLookupJoin/load/query.esql create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testLookupJoin/nullify/analysis.expected create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testLookupJoin/nullify/query.esql create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testLookupJoinWithEval/load/analysis.expected create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testLookupJoinWithEval/load/query.esql create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testLookupJoinWithEval/nullify/analysis.expected create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testLookupJoinWithEval/nullify/query.esql create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testLookupJoinWithFilter/load/analysis.expected create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testLookupJoinWithFilter/load/query.esql create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testLookupJoinWithFilter/nullify/analysis.expected create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testLookupJoinWithFilter/nullify/query.esql create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testSubquery/load/analysis.expected create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testSubquery/load/query.esql create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testSubquery/nullify/analysis.expected create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testSubquery/nullify/query.esql create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testSubqueryKeepMultipleUnmapped/load/analysis.expected create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testSubqueryKeepMultipleUnmapped/load/query.esql create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testSubqueryKeepMultipleUnmapped/nullify/analysis.expected create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testSubqueryKeepMultipleUnmapped/nullify/query.esql create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testSubqueryKeepUnmapped/load/analysis.expected create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testSubqueryKeepUnmapped/load/query.esql create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testSubqueryKeepUnmapped/nullify/analysis.expected create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testSubqueryKeepUnmapped/nullify/query.esql create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testSubqueryWithLookupJoin/load/analysis.expected create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testSubqueryWithLookupJoin/load/query.esql create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testSubqueryWithLookupJoin/nullify/analysis.expected create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testSubqueryWithLookupJoin/nullify/query.esql create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testSubqueryWithStats/load/analysis.expected create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testSubqueryWithStats/load/query.esql create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testSubqueryWithStats/nullify/analysis.expected create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testSubqueryWithStats/nullify/query.esql create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testTBucket/load/analysis.expected create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testTBucket/load/query.esql create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testTBucket/nullify/analysis.expected create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testTBucket/nullify/query.esql create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testTBucketAggregateUnmapped/load/analysis.expected create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testTBucketAggregateUnmapped/load/query.esql create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testTBucketAggregateUnmapped/nullify/analysis.expected create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testTBucketAggregateUnmapped/nullify/query.esql create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testTBucketGroupByUnmapped/load/analysis.expected create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testTBucketGroupByUnmapped/load/query.esql create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testTBucketGroupByUnmapped/nullify/analysis.expected create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testTBucketGroupByUnmapped/nullify/query.esql create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testTBucketWithUnmappedField/load/analysis.expected create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testTBucketWithUnmappedField/load/query.esql create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testTBucketWithUnmappedField/nullify/analysis.expected create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testTBucketWithUnmappedField/nullify/query.esql create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testTimeSeriesAvgOverTime/load/analysis.expected create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testTimeSeriesAvgOverTime/load/query.esql create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testTimeSeriesAvgOverTime/nullify/analysis.expected create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testTimeSeriesAvgOverTime/nullify/query.esql create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testTimeSeriesEvalUnmapped/load/analysis.expected create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testTimeSeriesEvalUnmapped/load/query.esql create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testTimeSeriesEvalUnmapped/nullify/analysis.expected create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testTimeSeriesEvalUnmapped/nullify/query.esql create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testTimeSeriesFirstOverTimeUnmapped/load/analysis.expected create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testTimeSeriesFirstOverTimeUnmapped/load/query.esql create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testTimeSeriesFirstOverTimeUnmapped/nullify/analysis.expected create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testTimeSeriesFirstOverTimeUnmapped/nullify/query.esql create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testTimeSeriesKeepUnmapped/load/analysis.expected create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testTimeSeriesKeepUnmapped/load/query.esql create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testTimeSeriesKeepUnmapped/nullify/analysis.expected create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testTimeSeriesKeepUnmapped/nullify/query.esql create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testTimeSeriesMaxOverTime/load/analysis.expected create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testTimeSeriesMaxOverTime/load/query.esql create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testTimeSeriesMaxOverTime/nullify/analysis.expected create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testTimeSeriesMaxOverTime/nullify/query.esql create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testTimeSeriesRate/load/analysis.expected create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testTimeSeriesRate/load/query.esql create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testTimeSeriesRate/nullify/analysis.expected create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testTimeSeriesRate/nullify/query.esql create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testTimeSeriesRateUnmapped/nullify/analysis.expected create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testTimeSeriesRateUnmapped/nullify/query.esql create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testTimeSeriesRateWithUnmappedGroupBy/nullify/query.esql diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/analysis/AnalyzerUnmappedGoldenTests.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/analysis/AnalyzerUnmappedGoldenTests.java index e1de3ba5bf151..ce64011cdcb6c 100644 --- a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/analysis/AnalyzerUnmappedGoldenTests.java +++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/analysis/AnalyzerUnmappedGoldenTests.java @@ -263,6 +263,106 @@ public void testMvExpand() throws Exception { """); } + public void testLookupJoin() throws Exception { + runTests(""" + FROM employees + | EVAL language_code = does_not_exist::INTEGER + | LOOKUP JOIN languages_lookup ON language_code + """); + } + + public void testLookupJoinWithFilter() throws Exception { + runTests(""" + FROM employees + | EVAL language_code = languages + | LOOKUP JOIN languages_lookup ON language_code + | WHERE does_not_exist::LONG > 0 + """); + } + + public void testSubqueryKeepUnmapped() throws Exception { + runTests(""" + FROM employees, (FROM languages | KEEP language_code, does_not_exist) + | KEEP emp_no, language_code, does_not_exist + """); + } + + public void testSubqueryWithStats() throws Exception { + runTests(""" + FROM employees, (FROM sample_data | STATS max_ts = MAX(@timestamp) BY does_not_exist) + | KEEP emp_no, max_ts, does_not_exist + """); + } + + public void testSubqueryKeepMultipleUnmapped() throws Exception { + runTests(""" + FROM employees, + (FROM languages | KEEP language_code, unmapped1, unmapped2) + | KEEP emp_no, language_code, unmapped1, unmapped2 + """); + } + + public void testFork() throws Exception { + runTests(""" + FROM employees + | FORK (WHERE does_not_exist::LONG > 0) + (WHERE emp_no > 0) + """); + } + + public void testForkWithEval() throws Exception { + runTests(""" + FROM employees + | FORK (EVAL x = does_not_exist::DOUBLE + 1) + (EVAL y = emp_no + 1) + """); + } + + public void testForkWithStats() throws Exception { + runTests(""" + FROM employees + | FORK (STATS c = COUNT(*) BY does_not_exist) + (STATS d = AVG(salary::DOUBLE)) + | SORT does_not_exist + """); + } + + public void testCoalesce() throws Exception { + runTests(""" + FROM employees + | EVAL x = COALESCE(does_not_exist::LONG, emp_no, 0) + | KEEP emp_no, x + """); + } + + public void testTBucketGroupByUnmapped() throws Exception { + runTests(""" + FROM sample_data + | STATS c = COUNT(*) BY tbucket(1 hour), does_not_exist + """); + } + + public void testTBucketAggregateUnmapped() throws Exception { + runTests(""" + FROM sample_data + | STATS s = SUM(does_not_exist::DOUBLE), c = COUNT(*) BY tbucket(1 day) + """); + } + + public void testTimeSeriesRateUnmapped() throws Exception { + runTestsNullifyOnly(""" + TS k8s + | STATS r = RATE(does_not_exist) BY tbucket(1 hour) + """); + } + + public void testTimeSeriesFirstOverTimeUnmapped() throws Exception { + runTests(""" + TS k8s + | STATS f = FIRST_OVER_TIME(does_not_exist::DOUBLE) BY tbucket(1 hour) + """); + } + @Override protected java.util.List filteredWarnings() { return withDefaultLimitWarning(super.filteredWarnings()); @@ -277,11 +377,15 @@ private static String setUnmappedLoad(String query) { } private void runTests(String query) { - if (EsqlCapabilities.Cap.OPTIONAL_FIELDS_NULLIFY_TECH_PREVIEW.isEnabled()) { - builder(setUnmappedNullify(query)).nestedPath("nullify").stages(STAGES).run(); - } + runTestsNullifyOnly(query); if (EsqlCapabilities.Cap.OPTIONAL_FIELDS.isEnabled()) { builder(setUnmappedLoad(query)).nestedPath("load").stages(STAGES).run(); } } + + private void runTestsNullifyOnly(String query) { + if (EsqlCapabilities.Cap.OPTIONAL_FIELDS_NULLIFY_TECH_PREVIEW.isEnabled()) { + builder(setUnmappedNullify(query)).nestedPath("nullify").stages(STAGES).run(); + } + } } diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testCoalesce/load/analysis.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testCoalesce/load/analysis.expected new file mode 100644 index 0000000000000..d3111b5b4cda6 --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testCoalesce/load/analysis.expected @@ -0,0 +1,4 @@ +Limit[1000[INTEGER],false,false] +\_Project[[emp_no{f}#0, x{r}#1]] + \_Eval[[COALESCE(TOLONG(does_not_exist{f}#2),TOLONG(emp_no{f}#0),TOLONG(0[INTEGER])) AS x#1]] + \_EsRelation[employees][avg_worked_seconds{f}#3, birth_date{f}#4, emp_no{f}#0, first_name{f}#5, gender{f}#6, height{f}#7, height.float{f}#8, height.half_float{f}#9, height.scaled_float{f}#10, hire_date{f}#11, is_rehired{f}#12, job_positions{f}#13, languages{f}#14, languages.byte{f}#15, languages.long{f}#16, languages.short{f}#17, last_name{f}#18, salary{f}#19, salary_change{f}#20, salary_change.int{f}#21, salary_change.keyword{f}#22, salary_change.long{f}#23, still_hired{f}#24, does_not_exist{f}#2, x{f}#25] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testCoalesce/load/query.esql b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testCoalesce/load/query.esql new file mode 100644 index 0000000000000..fffcba043eaeb --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testCoalesce/load/query.esql @@ -0,0 +1,3 @@ +SET unmapped_fields="load"; FROM employees +| EVAL x = COALESCE(does_not_exist::LONG, emp_no, 0) +| KEEP emp_no, x diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testCoalesce/nullify/analysis.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testCoalesce/nullify/analysis.expected new file mode 100644 index 0000000000000..5cccb49a752cc --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testCoalesce/nullify/analysis.expected @@ -0,0 +1,5 @@ +Limit[1000[INTEGER],false,false] +\_Project[[emp_no{f}#0, x{r}#1]] + \_Eval[[COALESCE(TOLONG(does_not_exist{r}#2),TOLONG(emp_no{f}#0),TOLONG(0[INTEGER])) AS x#1]] + \_Eval[[null[NULL] AS does_not_exist#2, null[NULL] AS x#3]] + \_EsRelation[employees][avg_worked_seconds{f}#4, birth_date{f}#5, emp_no{f}#0, first_name{f}#6, gender{f}#7, height{f}#8, height.float{f}#9, height.half_float{f}#10, height.scaled_float{f}#11, hire_date{f}#12, is_rehired{f}#13, job_positions{f}#14, languages{f}#15, languages.byte{f}#16, languages.long{f}#17, languages.short{f}#18, last_name{f}#19, salary{f}#20, salary_change{f}#21, salary_change.int{f}#22, salary_change.keyword{f}#23, salary_change.long{f}#24, still_hired{f}#25] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testCoalesce/nullify/query.esql b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testCoalesce/nullify/query.esql new file mode 100644 index 0000000000000..7de1ffe56d169 --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testCoalesce/nullify/query.esql @@ -0,0 +1,3 @@ +SET unmapped_fields="nullify"; FROM employees +| EVAL x = COALESCE(does_not_exist::LONG, emp_no, 0) +| KEEP emp_no, x diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testFork/load/analysis.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testFork/load/analysis.expected new file mode 100644 index 0000000000000..8c02caed8fa2b --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testFork/load/analysis.expected @@ -0,0 +1,13 @@ +Limit[1000[INTEGER],false,false] +\_Fork[[avg_worked_seconds{r}#0, birth_date{r}#1, emp_no{r}#2, first_name{r}#3, gender{r}#4, height{r}#5, height.float{r}#6, height.half_float{r}#7, height.scaled_float{r}#8, hire_date{r}#9, is_rehired{r}#10, job_positions{r}#11, languages{r}#12, languages.byte{r}#13, languages.long{r}#14, languages.short{r}#15, last_name{r}#16, salary{r}#17, salary_change{r}#18, salary_change.int{r}#19, salary_change.keyword{r}#20, salary_change.long{r}#21, still_hired{r}#22, does_not_exist{r}#23, _fork{r}#24]] + |_Limit[1000[INTEGER],false,false] + | \_Project[[avg_worked_seconds{f}#25, birth_date{f}#26, emp_no{f}#27, first_name{f}#28, gender{f}#29, height{f}#30, height.float{f}#31, height.half_float{f}#32, height.scaled_float{f}#33, hire_date{f}#34, is_rehired{f}#35, job_positions{f}#36, languages{f}#37, languages.byte{f}#38, languages.long{f}#39, languages.short{f}#40, last_name{f}#41, salary{f}#42, salary_change{f}#43, salary_change.int{f}#44, salary_change.keyword{f}#45, salary_change.long{f}#46, still_hired{f}#47, does_not_exist{f}#48, _fork{r}#49]] + | \_Eval[[fork1[KEYWORD] AS _fork#49]] + | \_Filter[TOLONG(does_not_exist{f}#48) > 0[INTEGER]] + | \_EsRelation[employees][avg_worked_seconds{f}#25, birth_date{f}#26, emp_no{f}#27, first_name{f}#28, gender{f}#29, height{f}#30, height.float{f}#31, height.half_float{f}#32, height.scaled_float{f}#33, hire_date{f}#34, is_rehired{f}#35, job_positions{f}#36, languages{f}#37, languages.byte{f}#38, languages.long{f}#39, languages.short{f}#40, last_name{f}#41, salary{f}#42, salary_change{f}#43, salary_change.int{f}#44, salary_change.keyword{f}#45, salary_change.long{f}#46, still_hired{f}#47, does_not_exist{f}#48] + \_Limit[1000[INTEGER],false,false] + \_Project[[avg_worked_seconds{f}#50, birth_date{f}#51, emp_no{f}#52, first_name{f}#53, gender{f}#54, height{f}#55, height.float{f}#56, height.half_float{f}#57, height.scaled_float{f}#58, hire_date{f}#59, is_rehired{f}#60, job_positions{f}#61, languages{f}#62, languages.byte{f}#63, languages.long{f}#64, languages.short{f}#65, last_name{f}#66, salary{f}#67, salary_change{f}#68, salary_change.int{f}#69, salary_change.keyword{f}#70, salary_change.long{f}#71, still_hired{f}#72, does_not_exist{r}#73, _fork{r}#49]] + \_Eval[[null[KEYWORD] AS does_not_exist#73]] + \_Eval[[fork2[KEYWORD] AS _fork#49]] + \_Filter[emp_no{f}#52 > 0[INTEGER]] + \_EsRelation[employees][avg_worked_seconds{f}#50, birth_date{f}#51, emp_no{f}#52, first_name{f}#53, gender{f}#54, height{f}#55, height.float{f}#56, height.half_float{f}#57, height.scaled_float{f}#58, hire_date{f}#59, is_rehired{f}#60, job_positions{f}#61, languages{f}#62, languages.byte{f}#63, languages.long{f}#64, languages.short{f}#65, last_name{f}#66, salary{f}#67, salary_change{f}#68, salary_change.int{f}#69, salary_change.keyword{f}#70, salary_change.long{f}#71, still_hired{f}#72] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testFork/load/query.esql b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testFork/load/query.esql new file mode 100644 index 0000000000000..1b2a31d2f6afd --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testFork/load/query.esql @@ -0,0 +1,3 @@ +SET unmapped_fields="load"; FROM employees +| FORK (WHERE does_not_exist::LONG > 0) + (WHERE emp_no > 0) diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testFork/nullify/analysis.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testFork/nullify/analysis.expected new file mode 100644 index 0000000000000..126b23315f762 --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testFork/nullify/analysis.expected @@ -0,0 +1,14 @@ +Limit[1000[INTEGER],false,false] +\_Fork[[avg_worked_seconds{r}#0, birth_date{r}#1, emp_no{r}#2, first_name{r}#3, gender{r}#4, height{r}#5, height.float{r}#6, height.half_float{r}#7, height.scaled_float{r}#8, hire_date{r}#9, is_rehired{r}#10, job_positions{r}#11, languages{r}#12, languages.byte{r}#13, languages.long{r}#14, languages.short{r}#15, last_name{r}#16, salary{r}#17, salary_change{r}#18, salary_change.int{r}#19, salary_change.keyword{r}#20, salary_change.long{r}#21, still_hired{r}#22, does_not_exist{r}#23, _fork{r}#24]] + |_Limit[1000[INTEGER],false,false] + | \_Project[[avg_worked_seconds{f}#25, birth_date{f}#26, emp_no{f}#27, first_name{f}#28, gender{f}#29, height{f}#30, height.float{f}#31, height.half_float{f}#32, height.scaled_float{f}#33, hire_date{f}#34, is_rehired{f}#35, job_positions{f}#36, languages{f}#37, languages.byte{f}#38, languages.long{f}#39, languages.short{f}#40, last_name{f}#41, salary{f}#42, salary_change{f}#43, salary_change.int{f}#44, salary_change.keyword{f}#45, salary_change.long{f}#46, still_hired{f}#47, does_not_exist{r}#48, _fork{r}#49]] + | \_Eval[[fork1[KEYWORD] AS _fork#49]] + | \_Filter[TOLONG(does_not_exist{r}#48) > 0[INTEGER]] + | \_Eval[[null[NULL] AS does_not_exist#48]] + | \_EsRelation[employees][avg_worked_seconds{f}#25, birth_date{f}#26, emp_no{f}#27, first_name{f}#28, gender{f}#29, height{f}#30, height.float{f}#31, height.half_float{f}#32, height.scaled_float{f}#33, hire_date{f}#34, is_rehired{f}#35, job_positions{f}#36, languages{f}#37, languages.byte{f}#38, languages.long{f}#39, languages.short{f}#40, last_name{f}#41, salary{f}#42, salary_change{f}#43, salary_change.int{f}#44, salary_change.keyword{f}#45, salary_change.long{f}#46, still_hired{f}#47] + \_Limit[1000[INTEGER],false,false] + \_Project[[avg_worked_seconds{f}#50, birth_date{f}#51, emp_no{f}#52, first_name{f}#53, gender{f}#54, height{f}#55, height.float{f}#56, height.half_float{f}#57, height.scaled_float{f}#58, hire_date{f}#59, is_rehired{f}#60, job_positions{f}#61, languages{f}#62, languages.byte{f}#63, languages.long{f}#64, languages.short{f}#65, last_name{f}#66, salary{f}#67, salary_change{f}#68, salary_change.int{f}#69, salary_change.keyword{f}#70, salary_change.long{f}#71, still_hired{f}#72, does_not_exist{r}#73, _fork{r}#49]] + \_Eval[[null[NULL] AS does_not_exist#73]] + \_Eval[[fork2[KEYWORD] AS _fork#49]] + \_Filter[emp_no{f}#52 > 0[INTEGER]] + \_EsRelation[employees][avg_worked_seconds{f}#50, birth_date{f}#51, emp_no{f}#52, first_name{f}#53, gender{f}#54, height{f}#55, height.float{f}#56, height.half_float{f}#57, height.scaled_float{f}#58, hire_date{f}#59, is_rehired{f}#60, job_positions{f}#61, languages{f}#62, languages.byte{f}#63, languages.long{f}#64, languages.short{f}#65, last_name{f}#66, salary{f}#67, salary_change{f}#68, salary_change.int{f}#69, salary_change.keyword{f}#70, salary_change.long{f}#71, still_hired{f}#72] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testFork/nullify/query.esql b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testFork/nullify/query.esql new file mode 100644 index 0000000000000..f52a0ffff2847 --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testFork/nullify/query.esql @@ -0,0 +1,3 @@ +SET unmapped_fields="nullify"; FROM employees +| FORK (WHERE does_not_exist::LONG > 0) + (WHERE emp_no > 0) diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testForkWithEval/load/analysis.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testForkWithEval/load/analysis.expected new file mode 100644 index 0000000000000..96d5b43c3eb3b --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testForkWithEval/load/analysis.expected @@ -0,0 +1,14 @@ +Limit[1000[INTEGER],false,false] +\_Fork[[avg_worked_seconds{r}#0, birth_date{r}#1, emp_no{r}#2, first_name{r}#3, gender{r}#4, height{r}#5, height.float{r}#6, height.half_float{r}#7, height.scaled_float{r}#8, hire_date{r}#9, is_rehired{r}#10, job_positions{r}#11, languages{r}#12, languages.byte{r}#13, languages.long{r}#14, languages.short{r}#15, last_name{r}#16, salary{r}#17, salary_change{r}#18, salary_change.int{r}#19, salary_change.keyword{r}#20, salary_change.long{r}#21, still_hired{r}#22, does_not_exist{r}#23, x{r}#24, _fork{r}#25, y{r}#26]] + |_Limit[1000[INTEGER],false,false] + | \_Project[[avg_worked_seconds{f}#27, birth_date{f}#28, emp_no{f}#29, first_name{f}#30, gender{f}#31, height{f}#32, height.float{f}#33, height.half_float{f}#34, height.scaled_float{f}#35, hire_date{f}#36, is_rehired{f}#37, job_positions{f}#38, languages{f}#39, languages.byte{f}#40, languages.long{f}#41, languages.short{f}#42, last_name{f}#43, salary{f}#44, salary_change{f}#45, salary_change.int{f}#46, salary_change.keyword{f}#47, salary_change.long{f}#48, still_hired{f}#49, does_not_exist{f}#50, x{r}#51, _fork{r}#52, y{r}#53]] + | \_Eval[[null[INTEGER] AS y#53]] + | \_Eval[[fork1[KEYWORD] AS _fork#52]] + | \_Eval[[TODOUBLE(does_not_exist{f}#50) + 1[INTEGER] AS x#51]] + | \_EsRelation[employees][avg_worked_seconds{f}#27, birth_date{f}#28, emp_no{f}#29, first_name{f}#30, gender{f}#31, height{f}#32, height.float{f}#33, height.half_float{f}#34, height.scaled_float{f}#35, hire_date{f}#36, is_rehired{f}#37, job_positions{f}#38, languages{f}#39, languages.byte{f}#40, languages.long{f}#41, languages.short{f}#42, last_name{f}#43, salary{f}#44, salary_change{f}#45, salary_change.int{f}#46, salary_change.keyword{f}#47, salary_change.long{f}#48, still_hired{f}#49, does_not_exist{f}#50] + \_Limit[1000[INTEGER],false,false] + \_Project[[avg_worked_seconds{f}#54, birth_date{f}#55, emp_no{f}#56, first_name{f}#57, gender{f}#58, height{f}#59, height.float{f}#60, height.half_float{f}#61, height.scaled_float{f}#62, hire_date{f}#63, is_rehired{f}#64, job_positions{f}#65, languages{f}#66, languages.byte{f}#67, languages.long{f}#68, languages.short{f}#69, last_name{f}#70, salary{f}#71, salary_change{f}#72, salary_change.int{f}#73, salary_change.keyword{f}#74, salary_change.long{f}#75, still_hired{f}#76, does_not_exist{r}#77, x{r}#78, _fork{r}#52, y{r}#79]] + \_Eval[[null[KEYWORD] AS does_not_exist#77, null[DOUBLE] AS x#78]] + \_Eval[[fork2[KEYWORD] AS _fork#52]] + \_Eval[[emp_no{f}#56 + 1[INTEGER] AS y#79]] + \_EsRelation[employees][avg_worked_seconds{f}#54, birth_date{f}#55, emp_no{f}#56, first_name{f}#57, gender{f}#58, height{f}#59, height.float{f}#60, height.half_float{f}#61, height.scaled_float{f}#62, hire_date{f}#63, is_rehired{f}#64, job_positions{f}#65, languages{f}#66, languages.byte{f}#67, languages.long{f}#68, languages.short{f}#69, last_name{f}#70, salary{f}#71, salary_change{f}#72, salary_change.int{f}#73, salary_change.keyword{f}#74, salary_change.long{f}#75, still_hired{f}#76] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testForkWithEval/load/query.esql b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testForkWithEval/load/query.esql new file mode 100644 index 0000000000000..f007f2dec96ca --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testForkWithEval/load/query.esql @@ -0,0 +1,3 @@ +SET unmapped_fields="load"; FROM employees +| FORK (EVAL x = does_not_exist::DOUBLE + 1) + (EVAL y = emp_no + 1) diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testForkWithEval/nullify/analysis.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testForkWithEval/nullify/analysis.expected new file mode 100644 index 0000000000000..745bf77c8febb --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testForkWithEval/nullify/analysis.expected @@ -0,0 +1,15 @@ +Limit[1000[INTEGER],false,false] +\_Fork[[avg_worked_seconds{r}#0, birth_date{r}#1, emp_no{r}#2, first_name{r}#3, gender{r}#4, height{r}#5, height.float{r}#6, height.half_float{r}#7, height.scaled_float{r}#8, hire_date{r}#9, is_rehired{r}#10, job_positions{r}#11, languages{r}#12, languages.byte{r}#13, languages.long{r}#14, languages.short{r}#15, last_name{r}#16, salary{r}#17, salary_change{r}#18, salary_change.int{r}#19, salary_change.keyword{r}#20, salary_change.long{r}#21, still_hired{r}#22, does_not_exist{r}#23, x{r}#24, _fork{r}#25, y{r}#26]] + |_Limit[1000[INTEGER],false,false] + | \_Project[[avg_worked_seconds{f}#27, birth_date{f}#28, emp_no{f}#29, first_name{f}#30, gender{f}#31, height{f}#32, height.float{f}#33, height.half_float{f}#34, height.scaled_float{f}#35, hire_date{f}#36, is_rehired{f}#37, job_positions{f}#38, languages{f}#39, languages.byte{f}#40, languages.long{f}#41, languages.short{f}#42, last_name{f}#43, salary{f}#44, salary_change{f}#45, salary_change.int{f}#46, salary_change.keyword{f}#47, salary_change.long{f}#48, still_hired{f}#49, does_not_exist{r}#50, x{r}#51, _fork{r}#52, y{r}#53]] + | \_Eval[[null[INTEGER] AS y#53]] + | \_Eval[[fork1[KEYWORD] AS _fork#52]] + | \_Eval[[TODOUBLE(does_not_exist{r}#50) + 1[INTEGER] AS x#51]] + | \_Eval[[null[NULL] AS does_not_exist#50]] + | \_EsRelation[employees][avg_worked_seconds{f}#27, birth_date{f}#28, emp_no{f}#29, first_name{f}#30, gender{f}#31, height{f}#32, height.float{f}#33, height.half_float{f}#34, height.scaled_float{f}#35, hire_date{f}#36, is_rehired{f}#37, job_positions{f}#38, languages{f}#39, languages.byte{f}#40, languages.long{f}#41, languages.short{f}#42, last_name{f}#43, salary{f}#44, salary_change{f}#45, salary_change.int{f}#46, salary_change.keyword{f}#47, salary_change.long{f}#48, still_hired{f}#49] + \_Limit[1000[INTEGER],false,false] + \_Project[[avg_worked_seconds{f}#54, birth_date{f}#55, emp_no{f}#56, first_name{f}#57, gender{f}#58, height{f}#59, height.float{f}#60, height.half_float{f}#61, height.scaled_float{f}#62, hire_date{f}#63, is_rehired{f}#64, job_positions{f}#65, languages{f}#66, languages.byte{f}#67, languages.long{f}#68, languages.short{f}#69, last_name{f}#70, salary{f}#71, salary_change{f}#72, salary_change.int{f}#73, salary_change.keyword{f}#74, salary_change.long{f}#75, still_hired{f}#76, does_not_exist{r}#77, x{r}#78, _fork{r}#52, y{r}#79]] + \_Eval[[null[NULL] AS does_not_exist#77, null[DOUBLE] AS x#78]] + \_Eval[[fork2[KEYWORD] AS _fork#52]] + \_Eval[[emp_no{f}#56 + 1[INTEGER] AS y#79]] + \_EsRelation[employees][avg_worked_seconds{f}#54, birth_date{f}#55, emp_no{f}#56, first_name{f}#57, gender{f}#58, height{f}#59, height.float{f}#60, height.half_float{f}#61, height.scaled_float{f}#62, hire_date{f}#63, is_rehired{f}#64, job_positions{f}#65, languages{f}#66, languages.byte{f}#67, languages.long{f}#68, languages.short{f}#69, last_name{f}#70, salary{f}#71, salary_change{f}#72, salary_change.int{f}#73, salary_change.keyword{f}#74, salary_change.long{f}#75, still_hired{f}#76] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testForkWithEval/nullify/query.esql b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testForkWithEval/nullify/query.esql new file mode 100644 index 0000000000000..70e809476f257 --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testForkWithEval/nullify/query.esql @@ -0,0 +1,3 @@ +SET unmapped_fields="nullify"; FROM employees +| FORK (EVAL x = does_not_exist::DOUBLE + 1) + (EVAL y = emp_no + 1) diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testForkWithSort/load/analysis.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testForkWithSort/load/analysis.expected new file mode 100644 index 0000000000000..466d405f796e8 --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testForkWithSort/load/analysis.expected @@ -0,0 +1,19 @@ +Limit[10000[INTEGER],false,false] +\_Fork[[avg_worked_seconds{r}#0, birth_date{r}#1, emp_no{r}#2, first_name{r}#3, gender{r}#4, height{r}#5, height.float{r}#6, height.half_float{r}#7, height.scaled_float{r}#8, hire_date{r}#9, is_rehired{r}#10, job_positions{r}#11, languages{r}#12, languages.byte{r}#13, languages.long{r}#14, languages.short{r}#15, last_name{r}#16, salary{r}#17, salary_change{r}#18, salary_change.int{r}#19, salary_change.keyword{r}#20, salary_change.long{r}#21, still_hired{r}#22, does_not_exist1{r}#23, does_not_exist2{r}#24, _fork{r}#25, does_not_exist3{r}#26, xyz{r}#27]] + |_Limit[10000[INTEGER],false,false] + | \_Project[[avg_worked_seconds{f}#28, birth_date{f}#29, emp_no{f}#30, first_name{f}#31, gender{f}#32, height{f}#33, height.float{f}#34, height.half_float{f}#35, height.scaled_float{f}#36, hire_date{f}#37, is_rehired{f}#38, job_positions{f}#39, languages{f}#40, languages.byte{f}#41, languages.long{f}#42, languages.short{f}#43, last_name{f}#44, salary{f}#45, salary_change{f}#46, salary_change.int{f}#47, salary_change.keyword{f}#48, salary_change.long{f}#49, still_hired{f}#50, does_not_exist1{f}#51, does_not_exist2{f}#52, _fork{r}#53, does_not_exist3{r}#54, xyz{r}#55]] + | \_Eval[[null[KEYWORD] AS does_not_exist3#54, null[KEYWORD] AS xyz#55]] + | \_Eval[[fork1[KEYWORD] AS _fork#53]] + | \_Limit[7[INTEGER],false,false] + | \_OrderBy[[Order[does_not_exist2{f}#52,ASC,LAST]]] + | \_Filter[emp_no{f}#30 > 3[INTEGER]] + | \_Filter[TOLONG(does_not_exist1{f}#51) > 5[INTEGER]] + | \_EsRelation[employees][avg_worked_seconds{f}#28, birth_date{f}#29, emp_no{f}#30, first_name{f}#31, gender{f}#32, height{f}#33, height.float{f}#34, height.half_float{f}#35, height.scaled_float{f}#36, hire_date{f}#37, is_rehired{f}#38, job_positions{f}#39, languages{f}#40, languages.byte{f}#41, languages.long{f}#42, languages.short{f}#43, last_name{f}#44, salary{f}#45, salary_change{f}#46, salary_change.int{f}#47, salary_change.keyword{f}#48, salary_change.long{f}#49, still_hired{f}#50, does_not_exist1{f}#51, does_not_exist2{f}#52] + \_Limit[1000[INTEGER],false,false] + \_Project[[avg_worked_seconds{f}#56, birth_date{f}#57, emp_no{f}#58, first_name{f}#59, gender{f}#60, height{f}#61, height.float{f}#62, height.half_float{f}#63, height.scaled_float{f}#64, hire_date{f}#65, is_rehired{f}#66, job_positions{f}#67, languages{f}#68, languages.byte{f}#69, languages.long{f}#70, languages.short{f}#71, last_name{f}#72, salary{f}#73, salary_change{f}#74, salary_change.int{f}#75, salary_change.keyword{f}#76, salary_change.long{f}#77, still_hired{f}#78, does_not_exist1{f}#79, does_not_exist2{r}#80, _fork{r}#53, does_not_exist3{f}#81, xyz{r}#82]] + \_Eval[[null[KEYWORD] AS does_not_exist2#80]] + \_Eval[[fork2[KEYWORD] AS _fork#53]] + \_Eval[[TOSTRING(does_not_exist3{f}#81) AS xyz#82]] + \_Filter[emp_no{f}#58 > 2[INTEGER]] + \_Filter[TOLONG(does_not_exist1{f}#79) > 5[INTEGER]] + \_EsRelation[employees][avg_worked_seconds{f}#56, birth_date{f}#57, emp_no{f}#58, first_name{f}#59, gender{f}#60, height{f}#61, height.float{f}#62, height.half_float{f}#63, height.scaled_float{f}#64, hire_date{f}#65, is_rehired{f}#66, job_positions{f}#67, languages{f}#68, languages.byte{f}#69, languages.long{f}#70, languages.short{f}#71, last_name{f}#72, salary{f}#73, salary_change{f}#74, salary_change.int{f}#75, salary_change.keyword{f}#76, salary_change.long{f}#77, still_hired{f}#78, does_not_exist1{f}#79, does_not_exist3{f}#81] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testForkWithSort/load/query.esql b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testForkWithSort/load/query.esql new file mode 100644 index 0000000000000..27269779f68d7 --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testForkWithSort/load/query.esql @@ -0,0 +1,4 @@ +SET unmapped_fields="load"; FROM employees +| WHERE does_not_exist1::LONG > 5 +| FORK (WHERE emp_no > 3 | SORT does_not_exist2 | LIMIT 7) + (WHERE emp_no > 2 | EVAL xyz = does_not_exist3::KEYWORD) diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testForkWithSort/nullify/analysis.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testForkWithSort/nullify/analysis.expected new file mode 100644 index 0000000000000..99494fb1c5fff --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testForkWithSort/nullify/analysis.expected @@ -0,0 +1,21 @@ +Limit[10000[INTEGER],false,false] +\_Fork[[avg_worked_seconds{r}#0, birth_date{r}#1, emp_no{r}#2, first_name{r}#3, gender{r}#4, height{r}#5, height.float{r}#6, height.half_float{r}#7, height.scaled_float{r}#8, hire_date{r}#9, is_rehired{r}#10, job_positions{r}#11, languages{r}#12, languages.byte{r}#13, languages.long{r}#14, languages.short{r}#15, last_name{r}#16, salary{r}#17, salary_change{r}#18, salary_change.int{r}#19, salary_change.keyword{r}#20, salary_change.long{r}#21, still_hired{r}#22, does_not_exist1{r}#23, does_not_exist2{r}#24, _fork{r}#25, does_not_exist3{r}#26, xyz{r}#27]] + |_Limit[10000[INTEGER],false,false] + | \_Project[[avg_worked_seconds{f}#28, birth_date{f}#29, emp_no{f}#30, first_name{f}#31, gender{f}#32, height{f}#33, height.float{f}#34, height.half_float{f}#35, height.scaled_float{f}#36, hire_date{f}#37, is_rehired{f}#38, job_positions{f}#39, languages{f}#40, languages.byte{f}#41, languages.long{f}#42, languages.short{f}#43, last_name{f}#44, salary{f}#45, salary_change{f}#46, salary_change.int{f}#47, salary_change.keyword{f}#48, salary_change.long{f}#49, still_hired{f}#50, does_not_exist1{r}#51, does_not_exist2{r}#52, _fork{r}#53, does_not_exist3{r}#54, xyz{r}#55]] + | \_Eval[[null[NULL] AS does_not_exist3#54, null[KEYWORD] AS xyz#55]] + | \_Eval[[fork1[KEYWORD] AS _fork#53]] + | \_Limit[7[INTEGER],false,false] + | \_OrderBy[[Order[does_not_exist2{r}#52,ASC,LAST]]] + | \_Filter[emp_no{f}#30 > 3[INTEGER]] + | \_Filter[TOLONG(does_not_exist1{r}#51) > 5[INTEGER]] + | \_Eval[[null[NULL] AS does_not_exist1#51, null[NULL] AS does_not_exist2#52]] + | \_EsRelation[employees][avg_worked_seconds{f}#28, birth_date{f}#29, emp_no{f}#30, first_name{f}#31, gender{f}#32, height{f}#33, height.float{f}#34, height.half_float{f}#35, height.scaled_float{f}#36, hire_date{f}#37, is_rehired{f}#38, job_positions{f}#39, languages{f}#40, languages.byte{f}#41, languages.long{f}#42, languages.short{f}#43, last_name{f}#44, salary{f}#45, salary_change{f}#46, salary_change.int{f}#47, salary_change.keyword{f}#48, salary_change.long{f}#49, still_hired{f}#50] + \_Limit[1000[INTEGER],false,false] + \_Project[[avg_worked_seconds{f}#56, birth_date{f}#57, emp_no{f}#58, first_name{f}#59, gender{f}#60, height{f}#61, height.float{f}#62, height.half_float{f}#63, height.scaled_float{f}#64, hire_date{f}#65, is_rehired{f}#66, job_positions{f}#67, languages{f}#68, languages.byte{f}#69, languages.long{f}#70, languages.short{f}#71, last_name{f}#72, salary{f}#73, salary_change{f}#74, salary_change.int{f}#75, salary_change.keyword{f}#76, salary_change.long{f}#77, still_hired{f}#78, does_not_exist1{r}#79, does_not_exist2{r}#80, _fork{r}#53, does_not_exist3{r}#81, xyz{r}#82]] + \_Eval[[null[NULL] AS does_not_exist2#80]] + \_Eval[[fork2[KEYWORD] AS _fork#53]] + \_Eval[[TOSTRING(does_not_exist3{r}#81) AS xyz#82]] + \_Filter[emp_no{f}#58 > 2[INTEGER]] + \_Filter[TOLONG(does_not_exist1{r}#79) > 5[INTEGER]] + \_Eval[[null[NULL] AS does_not_exist1#79, null[NULL] AS does_not_exist3#81]] + \_EsRelation[employees][avg_worked_seconds{f}#56, birth_date{f}#57, emp_no{f}#58, first_name{f}#59, gender{f}#60, height{f}#61, height.float{f}#62, height.half_float{f}#63, height.scaled_float{f}#64, hire_date{f}#65, is_rehired{f}#66, job_positions{f}#67, languages{f}#68, languages.byte{f}#69, languages.long{f}#70, languages.short{f}#71, last_name{f}#72, salary{f}#73, salary_change{f}#74, salary_change.int{f}#75, salary_change.keyword{f}#76, salary_change.long{f}#77, still_hired{f}#78] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testForkWithSort/nullify/query.esql b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testForkWithSort/nullify/query.esql new file mode 100644 index 0000000000000..c843b72d7d898 --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testForkWithSort/nullify/query.esql @@ -0,0 +1,4 @@ +SET unmapped_fields="nullify"; FROM employees +| WHERE does_not_exist1::LONG > 5 +| FORK (WHERE emp_no > 3 | SORT does_not_exist2 | LIMIT 7) + (WHERE emp_no > 2 | EVAL xyz = does_not_exist3::KEYWORD) diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testForkWithStats/load/analysis.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testForkWithStats/load/analysis.expected new file mode 100644 index 0000000000000..179c4819647d5 --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testForkWithStats/load/analysis.expected @@ -0,0 +1,15 @@ +Limit[1000[INTEGER],false,false] +\_OrderBy[[Order[does_not_exist{r}#0,ASC,LAST]]] + \_Fork[[c{r}#1, does_not_exist{r}#0, _fork{r}#2, d{r}#3]] + |_Limit[1000[INTEGER],false,false] + | \_Project[[c{r}#4, does_not_exist{f}#5, _fork{r}#6, d{r}#7]] + | \_Eval[[null[DOUBLE] AS d#7]] + | \_Eval[[fork1[KEYWORD] AS _fork#6]] + | \_Aggregate[[does_not_exist{f}#5],[COUNT(*[KEYWORD],true[BOOLEAN],PT0S[TIME_DURATION]) AS c#4, does_not_exist{f}#5]] + | \_EsRelation[employees][avg_worked_seconds{f}#8, birth_date{f}#9, emp_no{f}#10, first_name{f}#11, gender{f}#12, height{f}#13, height.float{f}#14, height.half_float{f}#15, height.scaled_float{f}#16, hire_date{f}#17, is_rehired{f}#18, job_positions{f}#19, languages{f}#20, languages.byte{f}#21, languages.long{f}#22, languages.short{f}#23, last_name{f}#24, salary{f}#25, salary_change{f}#26, salary_change.int{f}#27, salary_change.keyword{f}#28, salary_change.long{f}#29, still_hired{f}#30, does_not_exist{f}#5] + \_Limit[1000[INTEGER],false,false] + \_Project[[c{r}#31, does_not_exist{r}#32, _fork{r}#6, d{r}#33]] + \_Eval[[null[LONG] AS c#31, null[KEYWORD] AS does_not_exist#32]] + \_Eval[[fork2[KEYWORD] AS _fork#6]] + \_Aggregate[[],[AVG(TODOUBLE(salary{f}#34),true[BOOLEAN],PT0S[TIME_DURATION],compensated[KEYWORD]) AS d#33]] + \_EsRelation[employees][avg_worked_seconds{f}#35, birth_date{f}#36, emp_no{f}#37, first_name{f}#38, gender{f}#39, height{f}#40, height.float{f}#41, height.half_float{f}#42, height.scaled_float{f}#43, hire_date{f}#44, is_rehired{f}#45, job_positions{f}#46, languages{f}#47, languages.byte{f}#48, languages.long{f}#49, languages.short{f}#50, last_name{f}#51, salary{f}#34, salary_change{f}#52, salary_change.int{f}#53, salary_change.keyword{f}#54, salary_change.long{f}#55, still_hired{f}#56] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testForkWithStats/load/query.esql b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testForkWithStats/load/query.esql new file mode 100644 index 0000000000000..3a52496cdfc84 --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testForkWithStats/load/query.esql @@ -0,0 +1,4 @@ +SET unmapped_fields="load"; FROM employees +| FORK (STATS c = COUNT(*) BY does_not_exist) + (STATS d = AVG(salary::DOUBLE)) +| SORT does_not_exist diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testForkWithStats/nullify/analysis.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testForkWithStats/nullify/analysis.expected new file mode 100644 index 0000000000000..0905fb72ef867 --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testForkWithStats/nullify/analysis.expected @@ -0,0 +1,16 @@ +Limit[1000[INTEGER],false,false] +\_OrderBy[[Order[does_not_exist{r}#0,ASC,LAST]]] + \_Fork[[c{r}#1, does_not_exist{r}#0, _fork{r}#2, d{r}#3]] + |_Limit[1000[INTEGER],false,false] + | \_Project[[c{r}#4, does_not_exist{r}#5, _fork{r}#6, d{r}#7]] + | \_Eval[[null[DOUBLE] AS d#7]] + | \_Eval[[fork1[KEYWORD] AS _fork#6]] + | \_Aggregate[[does_not_exist{r}#5],[COUNT(*[KEYWORD],true[BOOLEAN],PT0S[TIME_DURATION]) AS c#4, does_not_exist{r}#5]] + | \_Eval[[null[NULL] AS does_not_exist#5]] + | \_EsRelation[employees][avg_worked_seconds{f}#8, birth_date{f}#9, emp_no{f}#10, first_name{f}#11, gender{f}#12, height{f}#13, height.float{f}#14, height.half_float{f}#15, height.scaled_float{f}#16, hire_date{f}#17, is_rehired{f}#18, job_positions{f}#19, languages{f}#20, languages.byte{f}#21, languages.long{f}#22, languages.short{f}#23, last_name{f}#24, salary{f}#25, salary_change{f}#26, salary_change.int{f}#27, salary_change.keyword{f}#28, salary_change.long{f}#29, still_hired{f}#30] + \_Limit[1000[INTEGER],false,false] + \_Project[[c{r}#31, does_not_exist{r}#32, _fork{r}#6, d{r}#33]] + \_Eval[[null[LONG] AS c#31, null[NULL] AS does_not_exist#32]] + \_Eval[[fork2[KEYWORD] AS _fork#6]] + \_Aggregate[[],[AVG(TODOUBLE(salary{f}#34),true[BOOLEAN],PT0S[TIME_DURATION],compensated[KEYWORD]) AS d#33]] + \_EsRelation[employees][avg_worked_seconds{f}#35, birth_date{f}#36, emp_no{f}#37, first_name{f}#38, gender{f}#39, height{f}#40, height.float{f}#41, height.half_float{f}#42, height.scaled_float{f}#43, hire_date{f}#44, is_rehired{f}#45, job_positions{f}#46, languages{f}#47, languages.byte{f}#48, languages.long{f}#49, languages.short{f}#50, last_name{f}#51, salary{f}#34, salary_change{f}#52, salary_change.int{f}#53, salary_change.keyword{f}#54, salary_change.long{f}#55, still_hired{f}#56] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testForkWithStats/nullify/query.esql b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testForkWithStats/nullify/query.esql new file mode 100644 index 0000000000000..e6d155e05a41b --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testForkWithStats/nullify/query.esql @@ -0,0 +1,4 @@ +SET unmapped_fields="nullify"; FROM employees +| FORK (STATS c = COUNT(*) BY does_not_exist) + (STATS d = AVG(salary::DOUBLE)) +| SORT does_not_exist diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testLookupJoin/load/analysis.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testLookupJoin/load/analysis.expected new file mode 100644 index 0000000000000..f57fe6df9c0a7 --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testLookupJoin/load/analysis.expected @@ -0,0 +1,5 @@ +Limit[1000[INTEGER],false,false] +\_LookupJoin[LEFT,[language_code{r}#0],[language_code{f}#1],false,null] + |_Eval[[TOINTEGER(does_not_exist{f}#2) AS language_code#0]] + | \_EsRelation[employees][avg_worked_seconds{f}#3, birth_date{f}#4, emp_no{f}#5, first_name{f}#6, gender{f}#7, height{f}#8, height.float{f}#9, height.half_float{f}#10, height.scaled_float{f}#11, hire_date{f}#12, is_rehired{f}#13, job_positions{f}#14, languages{f}#15, languages.byte{f}#16, languages.long{f}#17, languages.short{f}#18, last_name{f}#19, salary{f}#20, salary_change{f}#21, salary_change.int{f}#22, salary_change.keyword{f}#23, salary_change.long{f}#24, still_hired{f}#25, does_not_exist{f}#2] + \_EsRelation[languages_lookup][LOOKUP][language_code{f}#1, language_name{f}#26] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testLookupJoin/load/query.esql b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testLookupJoin/load/query.esql new file mode 100644 index 0000000000000..4297a1b213923 --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testLookupJoin/load/query.esql @@ -0,0 +1,3 @@ +SET unmapped_fields="load"; FROM employees +| EVAL language_code = does_not_exist::INTEGER +| LOOKUP JOIN languages_lookup ON language_code diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testLookupJoin/nullify/analysis.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testLookupJoin/nullify/analysis.expected new file mode 100644 index 0000000000000..8a2b4eaf82e13 --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testLookupJoin/nullify/analysis.expected @@ -0,0 +1,6 @@ +Limit[1000[INTEGER],false,false] +\_LookupJoin[LEFT,[language_code{r}#0],[language_code{f}#1],false,null] + |_Eval[[TOINTEGER(does_not_exist{r}#2) AS language_code#0]] + | \_Eval[[null[NULL] AS does_not_exist#2]] + | \_EsRelation[employees][avg_worked_seconds{f}#3, birth_date{f}#4, emp_no{f}#5, first_name{f}#6, gender{f}#7, height{f}#8, height.float{f}#9, height.half_float{f}#10, height.scaled_float{f}#11, hire_date{f}#12, is_rehired{f}#13, job_positions{f}#14, languages{f}#15, languages.byte{f}#16, languages.long{f}#17, languages.short{f}#18, last_name{f}#19, salary{f}#20, salary_change{f}#21, salary_change.int{f}#22, salary_change.keyword{f}#23, salary_change.long{f}#24, still_hired{f}#25] + \_EsRelation[languages_lookup][LOOKUP][language_code{f}#1, language_name{f}#26] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testLookupJoin/nullify/query.esql b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testLookupJoin/nullify/query.esql new file mode 100644 index 0000000000000..e0f372f5ca05b --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testLookupJoin/nullify/query.esql @@ -0,0 +1,3 @@ +SET unmapped_fields="nullify"; FROM employees +| EVAL language_code = does_not_exist::INTEGER +| LOOKUP JOIN languages_lookup ON language_code diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testLookupJoinWithEval/load/analysis.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testLookupJoinWithEval/load/analysis.expected new file mode 100644 index 0000000000000..3feb294dd5dc4 --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testLookupJoinWithEval/load/analysis.expected @@ -0,0 +1,6 @@ +Limit[1000[INTEGER],false,false] +\_Eval[[TODOUBLE(does_not_exist{f}#0) + 1[INTEGER] AS x#1]] + \_LookupJoin[LEFT,[language_code{r}#2],[language_code{f}#3],false,null] + |_Eval[[languages{f}#4 AS language_code#2]] + | \_EsRelation[employees][avg_worked_seconds{f}#5, birth_date{f}#6, emp_no{f}#7, first_name{f}#8, gender{f}#9, height{f}#10, height.float{f}#11, height.half_float{f}#12, height.scaled_float{f}#13, hire_date{f}#14, is_rehired{f}#15, job_positions{f}#16, languages{f}#4, languages.byte{f}#17, languages.long{f}#18, languages.short{f}#19, last_name{f}#20, salary{f}#21, salary_change{f}#22, salary_change.int{f}#23, salary_change.keyword{f}#24, salary_change.long{f}#25, still_hired{f}#26, does_not_exist{f}#0] + \_EsRelation[languages_lookup][LOOKUP][language_code{f}#3, language_name{f}#27] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testLookupJoinWithEval/load/query.esql b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testLookupJoinWithEval/load/query.esql new file mode 100644 index 0000000000000..787070f352209 --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testLookupJoinWithEval/load/query.esql @@ -0,0 +1,4 @@ +SET unmapped_fields="load"; FROM employees +| EVAL language_code = languages +| LOOKUP JOIN languages_lookup ON language_code +| EVAL x = does_not_exist::DOUBLE + 1 diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testLookupJoinWithEval/nullify/analysis.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testLookupJoinWithEval/nullify/analysis.expected new file mode 100644 index 0000000000000..de08464ba34a8 --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testLookupJoinWithEval/nullify/analysis.expected @@ -0,0 +1,7 @@ +Limit[1000[INTEGER],false,false] +\_Eval[[TODOUBLE(does_not_exist{r}#0) + 1[INTEGER] AS x#1]] + \_LookupJoin[LEFT,[language_code{r}#2],[language_code{f}#3],false,null] + |_Eval[[languages{f}#4 AS language_code#2, null[NULL] AS does_not_exist#5]] + | \_EsRelation[employees][avg_worked_seconds{f}#6, birth_date{f}#7, emp_no{f}#8, first_name{f}#9, gender{f}#10, height{f}#11, height.float{f}#12, height.half_float{f}#13, height.scaled_float{f}#14, hire_date{f}#15, is_rehired{f}#16, job_positions{f}#17, languages{f}#4, languages.byte{f}#18, languages.long{f}#19, languages.short{f}#20, last_name{f}#21, salary{f}#22, salary_change{f}#23, salary_change.int{f}#24, salary_change.keyword{f}#25, salary_change.long{f}#26, still_hired{f}#27] + \_Eval[[null[NULL] AS does_not_exist#0]] + \_EsRelation[languages_lookup][LOOKUP][language_code{f}#3, language_name{f}#28] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testLookupJoinWithEval/nullify/query.esql b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testLookupJoinWithEval/nullify/query.esql new file mode 100644 index 0000000000000..ba5f12db31aa2 --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testLookupJoinWithEval/nullify/query.esql @@ -0,0 +1,4 @@ +SET unmapped_fields="nullify"; FROM employees +| EVAL language_code = languages +| LOOKUP JOIN languages_lookup ON language_code +| EVAL x = does_not_exist::DOUBLE + 1 diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testLookupJoinWithFilter/load/analysis.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testLookupJoinWithFilter/load/analysis.expected new file mode 100644 index 0000000000000..0e429b6f7e085 --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testLookupJoinWithFilter/load/analysis.expected @@ -0,0 +1,6 @@ +Limit[1000[INTEGER],false,false] +\_Filter[TOLONG(does_not_exist{f}#0) > 0[INTEGER]] + \_LookupJoin[LEFT,[language_code{r}#1],[language_code{f}#2],false,null] + |_Eval[[languages{f}#3 AS language_code#1]] + | \_EsRelation[employees][avg_worked_seconds{f}#4, birth_date{f}#5, emp_no{f}#6, first_name{f}#7, gender{f}#8, height{f}#9, height.float{f}#10, height.half_float{f}#11, height.scaled_float{f}#12, hire_date{f}#13, is_rehired{f}#14, job_positions{f}#15, languages{f}#3, languages.byte{f}#16, languages.long{f}#17, languages.short{f}#18, last_name{f}#19, salary{f}#20, salary_change{f}#21, salary_change.int{f}#22, salary_change.keyword{f}#23, salary_change.long{f}#24, still_hired{f}#25, does_not_exist{f}#0] + \_EsRelation[languages_lookup][LOOKUP][language_code{f}#2, language_name{f}#26] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testLookupJoinWithFilter/load/query.esql b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testLookupJoinWithFilter/load/query.esql new file mode 100644 index 0000000000000..face9633033a7 --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testLookupJoinWithFilter/load/query.esql @@ -0,0 +1,4 @@ +SET unmapped_fields="load"; FROM employees +| EVAL language_code = languages +| LOOKUP JOIN languages_lookup ON language_code +| WHERE does_not_exist::LONG > 0 diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testLookupJoinWithFilter/nullify/analysis.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testLookupJoinWithFilter/nullify/analysis.expected new file mode 100644 index 0000000000000..204ffb0063c39 --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testLookupJoinWithFilter/nullify/analysis.expected @@ -0,0 +1,7 @@ +Limit[1000[INTEGER],false,false] +\_Filter[TOLONG(does_not_exist{r}#0) > 0[INTEGER]] + \_LookupJoin[LEFT,[language_code{r}#1],[language_code{f}#2],false,null] + |_Eval[[languages{f}#3 AS language_code#1, null[NULL] AS does_not_exist#4]] + | \_EsRelation[employees][avg_worked_seconds{f}#5, birth_date{f}#6, emp_no{f}#7, first_name{f}#8, gender{f}#9, height{f}#10, height.float{f}#11, height.half_float{f}#12, height.scaled_float{f}#13, hire_date{f}#14, is_rehired{f}#15, job_positions{f}#16, languages{f}#3, languages.byte{f}#17, languages.long{f}#18, languages.short{f}#19, last_name{f}#20, salary{f}#21, salary_change{f}#22, salary_change.int{f}#23, salary_change.keyword{f}#24, salary_change.long{f}#25, still_hired{f}#26] + \_Eval[[null[NULL] AS does_not_exist#0]] + \_EsRelation[languages_lookup][LOOKUP][language_code{f}#2, language_name{f}#27] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testLookupJoinWithFilter/nullify/query.esql b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testLookupJoinWithFilter/nullify/query.esql new file mode 100644 index 0000000000000..891443074f97b --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testLookupJoinWithFilter/nullify/query.esql @@ -0,0 +1,4 @@ +SET unmapped_fields="nullify"; FROM employees +| EVAL language_code = languages +| LOOKUP JOIN languages_lookup ON language_code +| WHERE does_not_exist::LONG > 0 diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testSubquery/load/analysis.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testSubquery/load/analysis.expected new file mode 100644 index 0000000000000..190b386040c51 --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testSubquery/load/analysis.expected @@ -0,0 +1,11 @@ +Limit[1000[INTEGER],false,false] +\_Project[[emp_no{r}#0, language_code{r}#1]] + \_UnionAll[[avg_worked_seconds{r}#2, birth_date{r}#3, emp_no{r}#0, first_name{r}#4, gender{r}#5, height{r}#6, height.float{r}#7, height.half_float{r}#8, height.scaled_float{r}#9, hire_date{r}#10, is_rehired{r}#11, job_positions{r}#12, languages{r}#13, languages.byte{r}#14, languages.long{r}#15, languages.short{r}#16, last_name{r}#17, salary{r}#18, salary_change{r}#19, salary_change.int{r}#20, salary_change.keyword{r}#21, salary_change.long{r}#22, still_hired{r}#23, language_code{r}#1, language_name{r}#24, does_not_exist{r}#25]] + |_Project[[avg_worked_seconds{f}#26, birth_date{f}#27, emp_no{f}#28, first_name{f}#29, gender{f}#30, height{f}#31, height.float{f}#32, height.half_float{f}#33, height.scaled_float{f}#34, hire_date{f}#35, is_rehired{f}#36, job_positions{f}#37, languages{f}#38, languages.byte{f}#39, languages.long{f}#40, languages.short{f}#41, last_name{f}#42, salary{f}#43, salary_change{f}#44, salary_change.int{f}#45, salary_change.keyword{f}#46, salary_change.long{f}#47, still_hired{f}#48, language_code{r}#49, language_name{r}#50, does_not_exist{r}#51]] + | \_Eval[[null[INTEGER] AS language_code#49, null[KEYWORD] AS language_name#50, null[KEYWORD] AS does_not_exist#51]] + | \_EsRelation[employees][avg_worked_seconds{f}#26, birth_date{f}#27, emp_no{f}#28, first_name{f}#29, gender{f}#30, height{f}#31, height.float{f}#32, height.half_float{f}#33, height.scaled_float{f}#34, hire_date{f}#35, is_rehired{f}#36, job_positions{f}#37, languages{f}#38, languages.byte{f}#39, languages.long{f}#40, languages.short{f}#41, last_name{f}#42, salary{f}#43, salary_change{f}#44, salary_change.int{f}#45, salary_change.keyword{f}#46, salary_change.long{f}#47, still_hired{f}#48] + \_Project[[avg_worked_seconds{r}#52, birth_date{r}#53, emp_no{r}#54, first_name{r}#55, gender{r}#56, height{r}#57, height.float{r}#58, height.half_float{r}#59, height.scaled_float{r}#60, hire_date{r}#61, is_rehired{r}#62, job_positions{r}#63, languages{r}#64, languages.byte{r}#65, languages.long{r}#66, languages.short{r}#67, last_name{r}#68, salary{r}#69, salary_change{r}#70, salary_change.int{r}#71, salary_change.keyword{r}#72, salary_change.long{r}#73, still_hired{r}#74, language_code{f}#75, language_name{f}#76, does_not_exist{f}#77]] + \_Eval[[null[LONG] AS avg_worked_seconds#52, null[DATETIME] AS birth_date#53, null[INTEGER] AS emp_no#54, null[KEYWORD] AS first_name#55, null[KEYWORD] AS gender#56, null[DOUBLE] AS height#57, null[DOUBLE] AS height.float#58, null[DOUBLE] AS height.half_float#59, null[DOUBLE] AS height.scaled_float#60, null[DATETIME] AS hire_date#61, null[BOOLEAN] AS is_rehired#62, null[KEYWORD] AS job_positions#63, null[INTEGER] AS languages#64, null[INTEGER] AS languages.byte#65, null[LONG] AS languages.long#66, null[INTEGER] AS languages.short#67, null[KEYWORD] AS last_name#68, null[INTEGER] AS salary#69, null[DOUBLE] AS salary_change#70, null[INTEGER] AS salary_change.int#71, null[KEYWORD] AS salary_change.keyword#72, null[LONG] AS salary_change.long#73, null[BOOLEAN] AS still_hired#74]] + \_Subquery[] + \_Filter[TOLONG(does_not_exist{f}#77) > 0[INTEGER]] + \_EsRelation[languages][language_code{f}#75, language_name{f}#76, does_not_exist{f}#77] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testSubquery/load/query.esql b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testSubquery/load/query.esql new file mode 100644 index 0000000000000..f6110cf298e18 --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testSubquery/load/query.esql @@ -0,0 +1,2 @@ +SET unmapped_fields="load"; FROM employees, (FROM languages | WHERE does_not_exist::LONG > 0) +| KEEP emp_no, language_code diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testSubquery/nullify/analysis.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testSubquery/nullify/analysis.expected new file mode 100644 index 0000000000000..755aed8c8303b --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testSubquery/nullify/analysis.expected @@ -0,0 +1,12 @@ +Limit[1000[INTEGER],false,false] +\_Project[[emp_no{r}#0, language_code{r}#1]] + \_UnionAll[[avg_worked_seconds{r}#2, birth_date{r}#3, emp_no{r}#0, first_name{r}#4, gender{r}#5, height{r}#6, height.float{r}#7, height.half_float{r}#8, height.scaled_float{r}#9, hire_date{r}#10, is_rehired{r}#11, job_positions{r}#12, languages{r}#13, languages.byte{r}#14, languages.long{r}#15, languages.short{r}#16, last_name{r}#17, salary{r}#18, salary_change{r}#19, salary_change.int{r}#20, salary_change.keyword{r}#21, salary_change.long{r}#22, still_hired{r}#23, language_code{r}#1, language_name{r}#24, does_not_exist{r}#25]] + |_Project[[avg_worked_seconds{f}#26, birth_date{f}#27, emp_no{f}#28, first_name{f}#29, gender{f}#30, height{f}#31, height.float{f}#32, height.half_float{f}#33, height.scaled_float{f}#34, hire_date{f}#35, is_rehired{f}#36, job_positions{f}#37, languages{f}#38, languages.byte{f}#39, languages.long{f}#40, languages.short{f}#41, last_name{f}#42, salary{f}#43, salary_change{f}#44, salary_change.int{f}#45, salary_change.keyword{f}#46, salary_change.long{f}#47, still_hired{f}#48, language_code{r}#49, language_name{r}#50, does_not_exist{r}#51]] + | \_Eval[[null[INTEGER] AS language_code#49, null[KEYWORD] AS language_name#50, null[NULL] AS does_not_exist#51]] + | \_EsRelation[employees][avg_worked_seconds{f}#26, birth_date{f}#27, emp_no{f}#28, first_name{f}#29, gender{f}#30, height{f}#31, height.float{f}#32, height.half_float{f}#33, height.scaled_float{f}#34, hire_date{f}#35, is_rehired{f}#36, job_positions{f}#37, languages{f}#38, languages.byte{f}#39, languages.long{f}#40, languages.short{f}#41, last_name{f}#42, salary{f}#43, salary_change{f}#44, salary_change.int{f}#45, salary_change.keyword{f}#46, salary_change.long{f}#47, still_hired{f}#48] + \_Project[[avg_worked_seconds{r}#52, birth_date{r}#53, emp_no{r}#54, first_name{r}#55, gender{r}#56, height{r}#57, height.float{r}#58, height.half_float{r}#59, height.scaled_float{r}#60, hire_date{r}#61, is_rehired{r}#62, job_positions{r}#63, languages{r}#64, languages.byte{r}#65, languages.long{r}#66, languages.short{r}#67, last_name{r}#68, salary{r}#69, salary_change{r}#70, salary_change.int{r}#71, salary_change.keyword{r}#72, salary_change.long{r}#73, still_hired{r}#74, language_code{f}#75, language_name{f}#76, does_not_exist{r}#77]] + \_Eval[[null[LONG] AS avg_worked_seconds#52, null[DATETIME] AS birth_date#53, null[INTEGER] AS emp_no#54, null[KEYWORD] AS first_name#55, null[KEYWORD] AS gender#56, null[DOUBLE] AS height#57, null[DOUBLE] AS height.float#58, null[DOUBLE] AS height.half_float#59, null[DOUBLE] AS height.scaled_float#60, null[DATETIME] AS hire_date#61, null[BOOLEAN] AS is_rehired#62, null[KEYWORD] AS job_positions#63, null[INTEGER] AS languages#64, null[INTEGER] AS languages.byte#65, null[LONG] AS languages.long#66, null[INTEGER] AS languages.short#67, null[KEYWORD] AS last_name#68, null[INTEGER] AS salary#69, null[DOUBLE] AS salary_change#70, null[INTEGER] AS salary_change.int#71, null[KEYWORD] AS salary_change.keyword#72, null[LONG] AS salary_change.long#73, null[BOOLEAN] AS still_hired#74]] + \_Subquery[] + \_Filter[TOLONG(does_not_exist{r}#77) > 0[INTEGER]] + \_Eval[[null[NULL] AS does_not_exist#77]] + \_EsRelation[languages][language_code{f}#75, language_name{f}#76] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testSubquery/nullify/query.esql b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testSubquery/nullify/query.esql new file mode 100644 index 0000000000000..6bd3350834a49 --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testSubquery/nullify/query.esql @@ -0,0 +1,2 @@ +SET unmapped_fields="nullify"; FROM employees, (FROM languages | WHERE does_not_exist::LONG > 0) +| KEEP emp_no, language_code diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testSubqueryKeepMultipleUnmapped/load/analysis.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testSubqueryKeepMultipleUnmapped/load/analysis.expected new file mode 100644 index 0000000000000..d6b8d29c43430 --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testSubqueryKeepMultipleUnmapped/load/analysis.expected @@ -0,0 +1,11 @@ +Limit[1000[INTEGER],false,false] +\_Project[[emp_no{r}#0, language_code{r}#1, unmapped1{r}#2, unmapped2{r}#3]] + \_UnionAll[[avg_worked_seconds{r}#4, birth_date{r}#5, emp_no{r}#0, first_name{r}#6, gender{r}#7, height{r}#8, height.float{r}#9, height.half_float{r}#10, height.scaled_float{r}#11, hire_date{r}#12, is_rehired{r}#13, job_positions{r}#14, languages{r}#15, languages.byte{r}#16, languages.long{r}#17, languages.short{r}#18, last_name{r}#19, salary{r}#20, salary_change{r}#21, salary_change.int{r}#22, salary_change.keyword{r}#23, salary_change.long{r}#24, still_hired{r}#25, language_code{r}#1, unmapped1{r}#2, unmapped2{r}#3]] + |_Project[[avg_worked_seconds{f}#26, birth_date{f}#27, emp_no{f}#28, first_name{f}#29, gender{f}#30, height{f}#31, height.float{f}#32, height.half_float{f}#33, height.scaled_float{f}#34, hire_date{f}#35, is_rehired{f}#36, job_positions{f}#37, languages{f}#38, languages.byte{f}#39, languages.long{f}#40, languages.short{f}#41, last_name{f}#42, salary{f}#43, salary_change{f}#44, salary_change.int{f}#45, salary_change.keyword{f}#46, salary_change.long{f}#47, still_hired{f}#48, language_code{r}#49, unmapped1{r}#50, unmapped2{r}#51]] + | \_Eval[[null[INTEGER] AS language_code#49, null[KEYWORD] AS unmapped1#50, null[KEYWORD] AS unmapped2#51]] + | \_EsRelation[employees][avg_worked_seconds{f}#26, birth_date{f}#27, emp_no{f}#28, first_name{f}#29, gender{f}#30, height{f}#31, height.float{f}#32, height.half_float{f}#33, height.scaled_float{f}#34, hire_date{f}#35, is_rehired{f}#36, job_positions{f}#37, languages{f}#38, languages.byte{f}#39, languages.long{f}#40, languages.short{f}#41, last_name{f}#42, salary{f}#43, salary_change{f}#44, salary_change.int{f}#45, salary_change.keyword{f}#46, salary_change.long{f}#47, still_hired{f}#48] + \_Project[[avg_worked_seconds{r}#52, birth_date{r}#53, emp_no{r}#54, first_name{r}#55, gender{r}#56, height{r}#57, height.float{r}#58, height.half_float{r}#59, height.scaled_float{r}#60, hire_date{r}#61, is_rehired{r}#62, job_positions{r}#63, languages{r}#64, languages.byte{r}#65, languages.long{r}#66, languages.short{r}#67, last_name{r}#68, salary{r}#69, salary_change{r}#70, salary_change.int{r}#71, salary_change.keyword{r}#72, salary_change.long{r}#73, still_hired{r}#74, language_code{f}#75, unmapped1{f}#76, unmapped2{f}#77]] + \_Eval[[null[LONG] AS avg_worked_seconds#52, null[DATETIME] AS birth_date#53, null[INTEGER] AS emp_no#54, null[KEYWORD] AS first_name#55, null[KEYWORD] AS gender#56, null[DOUBLE] AS height#57, null[DOUBLE] AS height.float#58, null[DOUBLE] AS height.half_float#59, null[DOUBLE] AS height.scaled_float#60, null[DATETIME] AS hire_date#61, null[BOOLEAN] AS is_rehired#62, null[KEYWORD] AS job_positions#63, null[INTEGER] AS languages#64, null[INTEGER] AS languages.byte#65, null[LONG] AS languages.long#66, null[INTEGER] AS languages.short#67, null[KEYWORD] AS last_name#68, null[INTEGER] AS salary#69, null[DOUBLE] AS salary_change#70, null[INTEGER] AS salary_change.int#71, null[KEYWORD] AS salary_change.keyword#72, null[LONG] AS salary_change.long#73, null[BOOLEAN] AS still_hired#74]] + \_Subquery[] + \_Project[[language_code{f}#75, unmapped1{f}#76, unmapped2{f}#77]] + \_EsRelation[languages][language_code{f}#75, language_name{f}#78, unmapped1{f}#76, unmapped2{f}#77] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testSubqueryKeepMultipleUnmapped/load/query.esql b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testSubqueryKeepMultipleUnmapped/load/query.esql new file mode 100644 index 0000000000000..f48daedc4ab1d --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testSubqueryKeepMultipleUnmapped/load/query.esql @@ -0,0 +1,3 @@ +SET unmapped_fields="load"; FROM employees, + (FROM languages | KEEP language_code, unmapped1, unmapped2) +| KEEP emp_no, language_code, unmapped1, unmapped2 diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testSubqueryKeepMultipleUnmapped/nullify/analysis.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testSubqueryKeepMultipleUnmapped/nullify/analysis.expected new file mode 100644 index 0000000000000..5edcc387fc727 --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testSubqueryKeepMultipleUnmapped/nullify/analysis.expected @@ -0,0 +1,12 @@ +Limit[1000[INTEGER],false,false] +\_Project[[emp_no{r}#0, language_code{r}#1, unmapped1{r}#2, unmapped2{r}#3]] + \_UnionAll[[avg_worked_seconds{r}#4, birth_date{r}#5, emp_no{r}#0, first_name{r}#6, gender{r}#7, height{r}#8, height.float{r}#9, height.half_float{r}#10, height.scaled_float{r}#11, hire_date{r}#12, is_rehired{r}#13, job_positions{r}#14, languages{r}#15, languages.byte{r}#16, languages.long{r}#17, languages.short{r}#18, last_name{r}#19, salary{r}#20, salary_change{r}#21, salary_change.int{r}#22, salary_change.keyword{r}#23, salary_change.long{r}#24, still_hired{r}#25, language_code{r}#1, unmapped1{r}#2, unmapped2{r}#3]] + |_Project[[avg_worked_seconds{f}#26, birth_date{f}#27, emp_no{f}#28, first_name{f}#29, gender{f}#30, height{f}#31, height.float{f}#32, height.half_float{f}#33, height.scaled_float{f}#34, hire_date{f}#35, is_rehired{f}#36, job_positions{f}#37, languages{f}#38, languages.byte{f}#39, languages.long{f}#40, languages.short{f}#41, last_name{f}#42, salary{f}#43, salary_change{f}#44, salary_change.int{f}#45, salary_change.keyword{f}#46, salary_change.long{f}#47, still_hired{f}#48, language_code{r}#49, unmapped1{r}#50, unmapped2{r}#51]] + | \_Eval[[null[INTEGER] AS language_code#49, null[NULL] AS unmapped1#50, null[NULL] AS unmapped2#51]] + | \_EsRelation[employees][avg_worked_seconds{f}#26, birth_date{f}#27, emp_no{f}#28, first_name{f}#29, gender{f}#30, height{f}#31, height.float{f}#32, height.half_float{f}#33, height.scaled_float{f}#34, hire_date{f}#35, is_rehired{f}#36, job_positions{f}#37, languages{f}#38, languages.byte{f}#39, languages.long{f}#40, languages.short{f}#41, last_name{f}#42, salary{f}#43, salary_change{f}#44, salary_change.int{f}#45, salary_change.keyword{f}#46, salary_change.long{f}#47, still_hired{f}#48] + \_Project[[avg_worked_seconds{r}#52, birth_date{r}#53, emp_no{r}#54, first_name{r}#55, gender{r}#56, height{r}#57, height.float{r}#58, height.half_float{r}#59, height.scaled_float{r}#60, hire_date{r}#61, is_rehired{r}#62, job_positions{r}#63, languages{r}#64, languages.byte{r}#65, languages.long{r}#66, languages.short{r}#67, last_name{r}#68, salary{r}#69, salary_change{r}#70, salary_change.int{r}#71, salary_change.keyword{r}#72, salary_change.long{r}#73, still_hired{r}#74, language_code{f}#75, unmapped1{r}#76, unmapped2{r}#77]] + \_Eval[[null[LONG] AS avg_worked_seconds#52, null[DATETIME] AS birth_date#53, null[INTEGER] AS emp_no#54, null[KEYWORD] AS first_name#55, null[KEYWORD] AS gender#56, null[DOUBLE] AS height#57, null[DOUBLE] AS height.float#58, null[DOUBLE] AS height.half_float#59, null[DOUBLE] AS height.scaled_float#60, null[DATETIME] AS hire_date#61, null[BOOLEAN] AS is_rehired#62, null[KEYWORD] AS job_positions#63, null[INTEGER] AS languages#64, null[INTEGER] AS languages.byte#65, null[LONG] AS languages.long#66, null[INTEGER] AS languages.short#67, null[KEYWORD] AS last_name#68, null[INTEGER] AS salary#69, null[DOUBLE] AS salary_change#70, null[INTEGER] AS salary_change.int#71, null[KEYWORD] AS salary_change.keyword#72, null[LONG] AS salary_change.long#73, null[BOOLEAN] AS still_hired#74]] + \_Subquery[] + \_Project[[language_code{f}#75, unmapped1{r}#76, unmapped2{r}#77]] + \_Eval[[null[NULL] AS unmapped1#76, null[NULL] AS unmapped2#77]] + \_EsRelation[languages][language_code{f}#75, language_name{f}#78] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testSubqueryKeepMultipleUnmapped/nullify/query.esql b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testSubqueryKeepMultipleUnmapped/nullify/query.esql new file mode 100644 index 0000000000000..eed7eb85db071 --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testSubqueryKeepMultipleUnmapped/nullify/query.esql @@ -0,0 +1,3 @@ +SET unmapped_fields="nullify"; FROM employees, + (FROM languages | KEEP language_code, unmapped1, unmapped2) +| KEEP emp_no, language_code, unmapped1, unmapped2 diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testSubqueryKeepUnmapped/load/analysis.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testSubqueryKeepUnmapped/load/analysis.expected new file mode 100644 index 0000000000000..0f0fb589b8c87 --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testSubqueryKeepUnmapped/load/analysis.expected @@ -0,0 +1,11 @@ +Limit[1000[INTEGER],false,false] +\_Project[[emp_no{r}#0, language_code{r}#1, does_not_exist{r}#2]] + \_UnionAll[[avg_worked_seconds{r}#3, birth_date{r}#4, emp_no{r}#0, first_name{r}#5, gender{r}#6, height{r}#7, height.float{r}#8, height.half_float{r}#9, height.scaled_float{r}#10, hire_date{r}#11, is_rehired{r}#12, job_positions{r}#13, languages{r}#14, languages.byte{r}#15, languages.long{r}#16, languages.short{r}#17, last_name{r}#18, salary{r}#19, salary_change{r}#20, salary_change.int{r}#21, salary_change.keyword{r}#22, salary_change.long{r}#23, still_hired{r}#24, language_code{r}#1, does_not_exist{r}#2]] + |_Project[[avg_worked_seconds{f}#25, birth_date{f}#26, emp_no{f}#27, first_name{f}#28, gender{f}#29, height{f}#30, height.float{f}#31, height.half_float{f}#32, height.scaled_float{f}#33, hire_date{f}#34, is_rehired{f}#35, job_positions{f}#36, languages{f}#37, languages.byte{f}#38, languages.long{f}#39, languages.short{f}#40, last_name{f}#41, salary{f}#42, salary_change{f}#43, salary_change.int{f}#44, salary_change.keyword{f}#45, salary_change.long{f}#46, still_hired{f}#47, language_code{r}#48, does_not_exist{r}#49]] + | \_Eval[[null[INTEGER] AS language_code#48, null[KEYWORD] AS does_not_exist#49]] + | \_EsRelation[employees][avg_worked_seconds{f}#25, birth_date{f}#26, emp_no{f}#27, first_name{f}#28, gender{f}#29, height{f}#30, height.float{f}#31, height.half_float{f}#32, height.scaled_float{f}#33, hire_date{f}#34, is_rehired{f}#35, job_positions{f}#36, languages{f}#37, languages.byte{f}#38, languages.long{f}#39, languages.short{f}#40, last_name{f}#41, salary{f}#42, salary_change{f}#43, salary_change.int{f}#44, salary_change.keyword{f}#45, salary_change.long{f}#46, still_hired{f}#47] + \_Project[[avg_worked_seconds{r}#50, birth_date{r}#51, emp_no{r}#52, first_name{r}#53, gender{r}#54, height{r}#55, height.float{r}#56, height.half_float{r}#57, height.scaled_float{r}#58, hire_date{r}#59, is_rehired{r}#60, job_positions{r}#61, languages{r}#62, languages.byte{r}#63, languages.long{r}#64, languages.short{r}#65, last_name{r}#66, salary{r}#67, salary_change{r}#68, salary_change.int{r}#69, salary_change.keyword{r}#70, salary_change.long{r}#71, still_hired{r}#72, language_code{f}#73, does_not_exist{f}#74]] + \_Eval[[null[LONG] AS avg_worked_seconds#50, null[DATETIME] AS birth_date#51, null[INTEGER] AS emp_no#52, null[KEYWORD] AS first_name#53, null[KEYWORD] AS gender#54, null[DOUBLE] AS height#55, null[DOUBLE] AS height.float#56, null[DOUBLE] AS height.half_float#57, null[DOUBLE] AS height.scaled_float#58, null[DATETIME] AS hire_date#59, null[BOOLEAN] AS is_rehired#60, null[KEYWORD] AS job_positions#61, null[INTEGER] AS languages#62, null[INTEGER] AS languages.byte#63, null[LONG] AS languages.long#64, null[INTEGER] AS languages.short#65, null[KEYWORD] AS last_name#66, null[INTEGER] AS salary#67, null[DOUBLE] AS salary_change#68, null[INTEGER] AS salary_change.int#69, null[KEYWORD] AS salary_change.keyword#70, null[LONG] AS salary_change.long#71, null[BOOLEAN] AS still_hired#72]] + \_Subquery[] + \_Project[[language_code{f}#73, does_not_exist{f}#74]] + \_EsRelation[languages][language_code{f}#73, language_name{f}#75, does_not_exist{f}#74] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testSubqueryKeepUnmapped/load/query.esql b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testSubqueryKeepUnmapped/load/query.esql new file mode 100644 index 0000000000000..de7a454b426f7 --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testSubqueryKeepUnmapped/load/query.esql @@ -0,0 +1,2 @@ +SET unmapped_fields="load"; FROM employees, (FROM languages | KEEP language_code, does_not_exist) +| KEEP emp_no, language_code, does_not_exist diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testSubqueryKeepUnmapped/nullify/analysis.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testSubqueryKeepUnmapped/nullify/analysis.expected new file mode 100644 index 0000000000000..37e20fe2c90c4 --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testSubqueryKeepUnmapped/nullify/analysis.expected @@ -0,0 +1,12 @@ +Limit[1000[INTEGER],false,false] +\_Project[[emp_no{r}#0, language_code{r}#1, does_not_exist{r}#2]] + \_UnionAll[[avg_worked_seconds{r}#3, birth_date{r}#4, emp_no{r}#0, first_name{r}#5, gender{r}#6, height{r}#7, height.float{r}#8, height.half_float{r}#9, height.scaled_float{r}#10, hire_date{r}#11, is_rehired{r}#12, job_positions{r}#13, languages{r}#14, languages.byte{r}#15, languages.long{r}#16, languages.short{r}#17, last_name{r}#18, salary{r}#19, salary_change{r}#20, salary_change.int{r}#21, salary_change.keyword{r}#22, salary_change.long{r}#23, still_hired{r}#24, language_code{r}#1, does_not_exist{r}#2]] + |_Project[[avg_worked_seconds{f}#25, birth_date{f}#26, emp_no{f}#27, first_name{f}#28, gender{f}#29, height{f}#30, height.float{f}#31, height.half_float{f}#32, height.scaled_float{f}#33, hire_date{f}#34, is_rehired{f}#35, job_positions{f}#36, languages{f}#37, languages.byte{f}#38, languages.long{f}#39, languages.short{f}#40, last_name{f}#41, salary{f}#42, salary_change{f}#43, salary_change.int{f}#44, salary_change.keyword{f}#45, salary_change.long{f}#46, still_hired{f}#47, language_code{r}#48, does_not_exist{r}#49]] + | \_Eval[[null[INTEGER] AS language_code#48, null[NULL] AS does_not_exist#49]] + | \_EsRelation[employees][avg_worked_seconds{f}#25, birth_date{f}#26, emp_no{f}#27, first_name{f}#28, gender{f}#29, height{f}#30, height.float{f}#31, height.half_float{f}#32, height.scaled_float{f}#33, hire_date{f}#34, is_rehired{f}#35, job_positions{f}#36, languages{f}#37, languages.byte{f}#38, languages.long{f}#39, languages.short{f}#40, last_name{f}#41, salary{f}#42, salary_change{f}#43, salary_change.int{f}#44, salary_change.keyword{f}#45, salary_change.long{f}#46, still_hired{f}#47] + \_Project[[avg_worked_seconds{r}#50, birth_date{r}#51, emp_no{r}#52, first_name{r}#53, gender{r}#54, height{r}#55, height.float{r}#56, height.half_float{r}#57, height.scaled_float{r}#58, hire_date{r}#59, is_rehired{r}#60, job_positions{r}#61, languages{r}#62, languages.byte{r}#63, languages.long{r}#64, languages.short{r}#65, last_name{r}#66, salary{r}#67, salary_change{r}#68, salary_change.int{r}#69, salary_change.keyword{r}#70, salary_change.long{r}#71, still_hired{r}#72, language_code{f}#73, does_not_exist{r}#74]] + \_Eval[[null[LONG] AS avg_worked_seconds#50, null[DATETIME] AS birth_date#51, null[INTEGER] AS emp_no#52, null[KEYWORD] AS first_name#53, null[KEYWORD] AS gender#54, null[DOUBLE] AS height#55, null[DOUBLE] AS height.float#56, null[DOUBLE] AS height.half_float#57, null[DOUBLE] AS height.scaled_float#58, null[DATETIME] AS hire_date#59, null[BOOLEAN] AS is_rehired#60, null[KEYWORD] AS job_positions#61, null[INTEGER] AS languages#62, null[INTEGER] AS languages.byte#63, null[LONG] AS languages.long#64, null[INTEGER] AS languages.short#65, null[KEYWORD] AS last_name#66, null[INTEGER] AS salary#67, null[DOUBLE] AS salary_change#68, null[INTEGER] AS salary_change.int#69, null[KEYWORD] AS salary_change.keyword#70, null[LONG] AS salary_change.long#71, null[BOOLEAN] AS still_hired#72]] + \_Subquery[] + \_Project[[language_code{f}#73, does_not_exist{r}#74]] + \_Eval[[null[NULL] AS does_not_exist#74]] + \_EsRelation[languages][language_code{f}#73, language_name{f}#75] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testSubqueryKeepUnmapped/nullify/query.esql b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testSubqueryKeepUnmapped/nullify/query.esql new file mode 100644 index 0000000000000..8aa4d0fd116ce --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testSubqueryKeepUnmapped/nullify/query.esql @@ -0,0 +1,2 @@ +SET unmapped_fields="nullify"; FROM employees, (FROM languages | KEEP language_code, does_not_exist) +| KEEP emp_no, language_code, does_not_exist diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testSubqueryWithLookupJoin/load/analysis.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testSubqueryWithLookupJoin/load/analysis.expected new file mode 100644 index 0000000000000..c66e2c8319dba --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testSubqueryWithLookupJoin/load/analysis.expected @@ -0,0 +1,21 @@ +Limit[1000[INTEGER],false,false] +\_Project[[emp_no{r}#0, language_code{r}#1]] + \_Filter[$$does_not_exist$converted_to$long{r$}#2 > 0[INTEGER]] + \_UnionAll[[avg_worked_seconds{r}#3, birth_date{r}#4, emp_no{r}#0, first_name{r}#5, gender{r}#6, height{r}#7, height.float{r}#8, height.half_float{r}#9, height.scaled_float{r}#10, hire_date{r}#11, is_rehired{r}#12, job_positions{r}#13, languages{r}#14, languages.byte{r}#15, languages.long{r}#16, languages.short{r}#17, last_name{r}#18, salary{r}#19, salary_change{r}#20, salary_change.int{r}#21, salary_change.keyword{r}#22, salary_change.long{r}#23, still_hired{r}#24, language_code{r}#1, language_name{r}#25, does_not_exist{r}#26, $$does_not_exist$converted_to$long{r$}#2]] + |_Project[[avg_worked_seconds{f}#27, birth_date{f}#28, emp_no{f}#29, first_name{f}#30, gender{f}#31, height{f}#32, height.float{f}#33, height.half_float{f}#34, height.scaled_float{f}#35, hire_date{f}#36, is_rehired{f}#37, job_positions{f}#38, languages{f}#39, languages.byte{f}#40, languages.long{f}#41, languages.short{f}#42, last_name{f}#43, salary{f}#44, salary_change{f}#45, salary_change.int{f}#46, salary_change.keyword{f}#47, salary_change.long{f}#48, still_hired{f}#49, language_code{r}#50, language_name{r}#51, does_not_exist{f}#52, $$does_not_exist$converted_to$long{r$}#53]] + | \_Eval[[TOLONG(does_not_exist{f}#52) AS $$does_not_exist$converted_to$long#53]] + | \_Eval[[null[INTEGER] AS language_code#50, null[KEYWORD] AS language_name#51]] + | \_EsRelation[employees][avg_worked_seconds{f}#27, birth_date{f}#28, emp_no{f}#29, first_name{f}#30, gender{f}#31, height{f}#32, height.float{f}#33, height.half_float{f}#34, height.scaled_float{f}#35, hire_date{f}#36, is_rehired{f}#37, job_positions{f}#38, languages{f}#39, languages.byte{f}#40, languages.long{f}#41, languages.short{f}#42, last_name{f}#43, salary{f}#44, salary_change{f}#45, salary_change.int{f}#46, salary_change.keyword{f}#47, salary_change.long{f}#48, still_hired{f}#49, does_not_exist{f}#52] + |_Project[[avg_worked_seconds{r}#54, birth_date{r}#55, emp_no{r}#56, first_name{r}#57, gender{r}#58, height{r}#59, height.float{r}#60, height.half_float{r}#61, height.scaled_float{r}#62, hire_date{r}#63, is_rehired{r}#64, job_positions{r}#65, languages{r}#66, languages.byte{r}#67, languages.long{r}#68, languages.short{r}#69, last_name{r}#70, salary{r}#71, salary_change{r}#72, salary_change.int{r}#73, salary_change.keyword{r}#74, salary_change.long{r}#75, still_hired{r}#76, language_code{f}#77, language_name{f}#78, does_not_exist{f}#79, $$does_not_exist$converted_to$long{r$}#80]] + | \_Eval[[TOLONG(does_not_exist{f}#79) AS $$does_not_exist$converted_to$long#80]] + | \_Eval[[null[LONG] AS avg_worked_seconds#54, null[DATETIME] AS birth_date#55, null[INTEGER] AS emp_no#56, null[KEYWORD] AS first_name#57, null[KEYWORD] AS gender#58, null[DOUBLE] AS height#59, null[DOUBLE] AS height.float#60, null[DOUBLE] AS height.half_float#61, null[DOUBLE] AS height.scaled_float#62, null[DATETIME] AS hire_date#63, null[BOOLEAN] AS is_rehired#64, null[KEYWORD] AS job_positions#65, null[INTEGER] AS languages#66, null[INTEGER] AS languages.byte#67, null[LONG] AS languages.long#68, null[INTEGER] AS languages.short#69, null[KEYWORD] AS last_name#70, null[INTEGER] AS salary#71, null[DOUBLE] AS salary_change#72, null[INTEGER] AS salary_change.int#73, null[KEYWORD] AS salary_change.keyword#74, null[LONG] AS salary_change.long#75, null[BOOLEAN] AS still_hired#76]] + | \_Subquery[] + | \_Filter[language_code{f}#77 > 0[INTEGER]] + | \_EsRelation[languages][language_code{f}#77, language_name{f}#78, does_not_exist{f}#79] + \_Project[[avg_worked_seconds{f}#81, birth_date{f}#82, emp_no{f}#83, first_name{f}#84, gender{f}#85, height{f}#86, height.float{f}#87, height.half_float{f}#88, height.scaled_float{f}#89, hire_date{f}#90, is_rehired{f}#91, job_positions{f}#92, languages{f}#93, languages.byte{f}#94, languages.long{f}#95, languages.short{f}#96, last_name{f}#97, salary{f}#98, salary_change{f}#99, salary_change.int{f}#100, salary_change.keyword{f}#101, salary_change.long{f}#102, still_hired{f}#103, language_code{r}#104, language_name{f}#105, does_not_exist{f}#106, $$does_not_exist$converted_to$long{r$}#107]] + \_Eval[[TOLONG(does_not_exist{f}#106) AS $$does_not_exist$converted_to$long#107]] + \_Subquery[] + \_LookupJoin[LEFT,[language_code{r}#104],[language_code{f}#108],false,null] + |_Eval[[languages{f}#93 AS language_code#104]] + | \_EsRelation[employees][avg_worked_seconds{f}#81, birth_date{f}#82, emp_no{f}#83, first_name{f}#84, gender{f}#85, height{f}#86, height.float{f}#87, height.half_float{f}#88, height.scaled_float{f}#89, hire_date{f}#90, is_rehired{f}#91, job_positions{f}#92, languages{f}#93, languages.byte{f}#94, languages.long{f}#95, languages.short{f}#96, last_name{f}#97, salary{f}#98, salary_change{f}#99, salary_change.int{f}#100, salary_change.keyword{f}#101, salary_change.long{f}#102, still_hired{f}#103, does_not_exist{f}#106] + \_EsRelation[languages_lookup][LOOKUP][language_code{f}#108, language_name{f}#105] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testSubqueryWithLookupJoin/load/query.esql b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testSubqueryWithLookupJoin/load/query.esql new file mode 100644 index 0000000000000..9e1ecb142ea61 --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testSubqueryWithLookupJoin/load/query.esql @@ -0,0 +1,5 @@ +SET unmapped_fields="load"; FROM employees, + (FROM languages | WHERE language_code > 0), + (FROM employees | EVAL language_code = languages | LOOKUP JOIN languages_lookup ON language_code) +| WHERE does_not_exist::LONG > 0 +| KEEP emp_no, language_code diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testSubqueryWithLookupJoin/nullify/analysis.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testSubqueryWithLookupJoin/nullify/analysis.expected new file mode 100644 index 0000000000000..88494026b12bd --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testSubqueryWithLookupJoin/nullify/analysis.expected @@ -0,0 +1,23 @@ +Limit[1000[INTEGER],false,false] +\_Project[[emp_no{r}#0, language_code{r}#1]] + \_Filter[$$does_not_exist$converted_to$long{r$}#2 > 0[INTEGER]] + \_UnionAll[[avg_worked_seconds{r}#3, birth_date{r}#4, emp_no{r}#0, first_name{r}#5, gender{r}#6, height{r}#7, height.float{r}#8, height.half_float{r}#9, height.scaled_float{r}#10, hire_date{r}#11, is_rehired{r}#12, job_positions{r}#13, languages{r}#14, languages.byte{r}#15, languages.long{r}#16, languages.short{r}#17, last_name{r}#18, salary{r}#19, salary_change{r}#20, salary_change.int{r}#21, salary_change.keyword{r}#22, salary_change.long{r}#23, still_hired{r}#24, language_code{r}#1, language_name{r}#25, does_not_exist{r}#26, $$does_not_exist$converted_to$long{r$}#2]] + |_Project[[avg_worked_seconds{f}#27, birth_date{f}#28, emp_no{f}#29, first_name{f}#30, gender{f}#31, height{f}#32, height.float{f}#33, height.half_float{f}#34, height.scaled_float{f}#35, hire_date{f}#36, is_rehired{f}#37, job_positions{f}#38, languages{f}#39, languages.byte{f}#40, languages.long{f}#41, languages.short{f}#42, last_name{f}#43, salary{f}#44, salary_change{f}#45, salary_change.int{f}#46, salary_change.keyword{f}#47, salary_change.long{f}#48, still_hired{f}#49, language_code{r}#50, language_name{r}#51, does_not_exist{r}#52, $$does_not_exist$converted_to$long{r$}#53]] + | \_Eval[[TOLONG(does_not_exist{r}#52) AS $$does_not_exist$converted_to$long#53]] + | \_Eval[[null[INTEGER] AS language_code#50, null[KEYWORD] AS language_name#51, null[NULL] AS does_not_exist#52]] + | \_EsRelation[employees][avg_worked_seconds{f}#27, birth_date{f}#28, emp_no{f}#29, first_name{f}#30, gender{f}#31, height{f}#32, height.float{f}#33, height.half_float{f}#34, height.scaled_float{f}#35, hire_date{f}#36, is_rehired{f}#37, job_positions{f}#38, languages{f}#39, languages.byte{f}#40, languages.long{f}#41, languages.short{f}#42, last_name{f}#43, salary{f}#44, salary_change{f}#45, salary_change.int{f}#46, salary_change.keyword{f}#47, salary_change.long{f}#48, still_hired{f}#49] + |_Project[[avg_worked_seconds{r}#54, birth_date{r}#55, emp_no{r}#56, first_name{r}#57, gender{r}#58, height{r}#59, height.float{r}#60, height.half_float{r}#61, height.scaled_float{r}#62, hire_date{r}#63, is_rehired{r}#64, job_positions{r}#65, languages{r}#66, languages.byte{r}#67, languages.long{r}#68, languages.short{r}#69, last_name{r}#70, salary{r}#71, salary_change{r}#72, salary_change.int{r}#73, salary_change.keyword{r}#74, salary_change.long{r}#75, still_hired{r}#76, language_code{f}#77, language_name{f}#78, does_not_exist{r}#79, $$does_not_exist$converted_to$long{r$}#80]] + | \_Eval[[TOLONG(does_not_exist{r}#79) AS $$does_not_exist$converted_to$long#80]] + | \_Eval[[null[LONG] AS avg_worked_seconds#54, null[DATETIME] AS birth_date#55, null[INTEGER] AS emp_no#56, null[KEYWORD] AS first_name#57, null[KEYWORD] AS gender#58, null[DOUBLE] AS height#59, null[DOUBLE] AS height.float#60, null[DOUBLE] AS height.half_float#61, null[DOUBLE] AS height.scaled_float#62, null[DATETIME] AS hire_date#63, null[BOOLEAN] AS is_rehired#64, null[KEYWORD] AS job_positions#65, null[INTEGER] AS languages#66, null[INTEGER] AS languages.byte#67, null[LONG] AS languages.long#68, null[INTEGER] AS languages.short#69, null[KEYWORD] AS last_name#70, null[INTEGER] AS salary#71, null[DOUBLE] AS salary_change#72, null[INTEGER] AS salary_change.int#73, null[KEYWORD] AS salary_change.keyword#74, null[LONG] AS salary_change.long#75, null[BOOLEAN] AS still_hired#76]] + | \_Subquery[] + | \_Filter[language_code{f}#77 > 0[INTEGER]] + | \_Eval[[null[NULL] AS does_not_exist#79]] + | \_EsRelation[languages][language_code{f}#77, language_name{f}#78] + \_Project[[avg_worked_seconds{f}#81, birth_date{f}#82, emp_no{f}#83, first_name{f}#84, gender{f}#85, height{f}#86, height.float{f}#87, height.half_float{f}#88, height.scaled_float{f}#89, hire_date{f}#90, is_rehired{f}#91, job_positions{f}#92, languages{f}#93, languages.byte{f}#94, languages.long{f}#95, languages.short{f}#96, last_name{f}#97, salary{f}#98, salary_change{f}#99, salary_change.int{f}#100, salary_change.keyword{f}#101, salary_change.long{f}#102, still_hired{f}#103, language_code{r}#104, language_name{f}#105, does_not_exist{r}#106, $$does_not_exist$converted_to$long{r$}#107]] + \_Eval[[TOLONG(does_not_exist{r}#106) AS $$does_not_exist$converted_to$long#107]] + \_Subquery[] + \_LookupJoin[LEFT,[language_code{r}#104],[language_code{f}#108],false,null] + |_Eval[[languages{f}#93 AS language_code#104, null[NULL] AS does_not_exist#109]] + | \_EsRelation[employees][avg_worked_seconds{f}#81, birth_date{f}#82, emp_no{f}#83, first_name{f}#84, gender{f}#85, height{f}#86, height.float{f}#87, height.half_float{f}#88, height.scaled_float{f}#89, hire_date{f}#90, is_rehired{f}#91, job_positions{f}#92, languages{f}#93, languages.byte{f}#94, languages.long{f}#95, languages.short{f}#96, last_name{f}#97, salary{f}#98, salary_change{f}#99, salary_change.int{f}#100, salary_change.keyword{f}#101, salary_change.long{f}#102, still_hired{f}#103] + \_Eval[[null[NULL] AS does_not_exist#106]] + \_EsRelation[languages_lookup][LOOKUP][language_code{f}#108, language_name{f}#105] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testSubqueryWithLookupJoin/nullify/query.esql b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testSubqueryWithLookupJoin/nullify/query.esql new file mode 100644 index 0000000000000..1cae2badc15ab --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testSubqueryWithLookupJoin/nullify/query.esql @@ -0,0 +1,5 @@ +SET unmapped_fields="nullify"; FROM employees, + (FROM languages | WHERE language_code > 0), + (FROM employees | EVAL language_code = languages | LOOKUP JOIN languages_lookup ON language_code) +| WHERE does_not_exist::LONG > 0 +| KEEP emp_no, language_code diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testSubqueryWithStats/load/analysis.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testSubqueryWithStats/load/analysis.expected new file mode 100644 index 0000000000000..48317bbb23980 --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testSubqueryWithStats/load/analysis.expected @@ -0,0 +1,11 @@ +Limit[1000[INTEGER],false,false] +\_Project[[emp_no{r}#0, max_ts{r}#1, does_not_exist{r}#2]] + \_UnionAll[[avg_worked_seconds{r}#3, birth_date{r}#4, emp_no{r}#0, first_name{r}#5, gender{r}#6, height{r}#7, height.float{r}#8, height.half_float{r}#9, height.scaled_float{r}#10, hire_date{r}#11, is_rehired{r}#12, job_positions{r}#13, languages{r}#14, languages.byte{r}#15, languages.long{r}#16, languages.short{r}#17, last_name{r}#18, salary{r}#19, salary_change{r}#20, salary_change.int{r}#21, salary_change.keyword{r}#22, salary_change.long{r}#23, still_hired{r}#24, max_ts{r}#1, does_not_exist{r}#2]] + |_Project[[avg_worked_seconds{f}#25, birth_date{f}#26, emp_no{f}#27, first_name{f}#28, gender{f}#29, height{f}#30, height.float{f}#31, height.half_float{f}#32, height.scaled_float{f}#33, hire_date{f}#34, is_rehired{f}#35, job_positions{f}#36, languages{f}#37, languages.byte{f}#38, languages.long{f}#39, languages.short{f}#40, last_name{f}#41, salary{f}#42, salary_change{f}#43, salary_change.int{f}#44, salary_change.keyword{f}#45, salary_change.long{f}#46, still_hired{f}#47, max_ts{r}#48, does_not_exist{r}#49]] + | \_Eval[[null[DATETIME] AS max_ts#48, null[KEYWORD] AS does_not_exist#49]] + | \_EsRelation[employees][avg_worked_seconds{f}#25, birth_date{f}#26, emp_no{f}#27, first_name{f}#28, gender{f}#29, height{f}#30, height.float{f}#31, height.half_float{f}#32, height.scaled_float{f}#33, hire_date{f}#34, is_rehired{f}#35, job_positions{f}#36, languages{f}#37, languages.byte{f}#38, languages.long{f}#39, languages.short{f}#40, last_name{f}#41, salary{f}#42, salary_change{f}#43, salary_change.int{f}#44, salary_change.keyword{f}#45, salary_change.long{f}#46, still_hired{f}#47] + \_Project[[avg_worked_seconds{r}#50, birth_date{r}#51, emp_no{r}#52, first_name{r}#53, gender{r}#54, height{r}#55, height.float{r}#56, height.half_float{r}#57, height.scaled_float{r}#58, hire_date{r}#59, is_rehired{r}#60, job_positions{r}#61, languages{r}#62, languages.byte{r}#63, languages.long{r}#64, languages.short{r}#65, last_name{r}#66, salary{r}#67, salary_change{r}#68, salary_change.int{r}#69, salary_change.keyword{r}#70, salary_change.long{r}#71, still_hired{r}#72, max_ts{r}#73, does_not_exist{f}#74]] + \_Eval[[null[LONG] AS avg_worked_seconds#50, null[DATETIME] AS birth_date#51, null[INTEGER] AS emp_no#52, null[KEYWORD] AS first_name#53, null[KEYWORD] AS gender#54, null[DOUBLE] AS height#55, null[DOUBLE] AS height.float#56, null[DOUBLE] AS height.half_float#57, null[DOUBLE] AS height.scaled_float#58, null[DATETIME] AS hire_date#59, null[BOOLEAN] AS is_rehired#60, null[KEYWORD] AS job_positions#61, null[INTEGER] AS languages#62, null[INTEGER] AS languages.byte#63, null[LONG] AS languages.long#64, null[INTEGER] AS languages.short#65, null[KEYWORD] AS last_name#66, null[INTEGER] AS salary#67, null[DOUBLE] AS salary_change#68, null[INTEGER] AS salary_change.int#69, null[KEYWORD] AS salary_change.keyword#70, null[LONG] AS salary_change.long#71, null[BOOLEAN] AS still_hired#72]] + \_Subquery[] + \_Aggregate[[does_not_exist{f}#74],[MAX(@timestamp{f}#75,true[BOOLEAN],PT0S[TIME_DURATION]) AS max_ts#73, does_not_exist{f}#74]] + \_EsRelation[sample_data][@timestamp{f}#75, client_ip{f}#76, event_duration{f}#77, message{f}#78, does_not_exist{f}#74] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testSubqueryWithStats/load/query.esql b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testSubqueryWithStats/load/query.esql new file mode 100644 index 0000000000000..dabf6fc1b0e8c --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testSubqueryWithStats/load/query.esql @@ -0,0 +1,2 @@ +SET unmapped_fields="load"; FROM employees, (FROM sample_data | STATS max_ts = MAX(@timestamp) BY does_not_exist) +| KEEP emp_no, max_ts, does_not_exist diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testSubqueryWithStats/nullify/analysis.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testSubqueryWithStats/nullify/analysis.expected new file mode 100644 index 0000000000000..1def35de13537 --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testSubqueryWithStats/nullify/analysis.expected @@ -0,0 +1,12 @@ +Limit[1000[INTEGER],false,false] +\_Project[[emp_no{r}#0, max_ts{r}#1, does_not_exist{r}#2]] + \_UnionAll[[avg_worked_seconds{r}#3, birth_date{r}#4, emp_no{r}#0, first_name{r}#5, gender{r}#6, height{r}#7, height.float{r}#8, height.half_float{r}#9, height.scaled_float{r}#10, hire_date{r}#11, is_rehired{r}#12, job_positions{r}#13, languages{r}#14, languages.byte{r}#15, languages.long{r}#16, languages.short{r}#17, last_name{r}#18, salary{r}#19, salary_change{r}#20, salary_change.int{r}#21, salary_change.keyword{r}#22, salary_change.long{r}#23, still_hired{r}#24, max_ts{r}#1, does_not_exist{r}#2]] + |_Project[[avg_worked_seconds{f}#25, birth_date{f}#26, emp_no{f}#27, first_name{f}#28, gender{f}#29, height{f}#30, height.float{f}#31, height.half_float{f}#32, height.scaled_float{f}#33, hire_date{f}#34, is_rehired{f}#35, job_positions{f}#36, languages{f}#37, languages.byte{f}#38, languages.long{f}#39, languages.short{f}#40, last_name{f}#41, salary{f}#42, salary_change{f}#43, salary_change.int{f}#44, salary_change.keyword{f}#45, salary_change.long{f}#46, still_hired{f}#47, max_ts{r}#48, does_not_exist{r}#49]] + | \_Eval[[null[DATETIME] AS max_ts#48, null[NULL] AS does_not_exist#49]] + | \_EsRelation[employees][avg_worked_seconds{f}#25, birth_date{f}#26, emp_no{f}#27, first_name{f}#28, gender{f}#29, height{f}#30, height.float{f}#31, height.half_float{f}#32, height.scaled_float{f}#33, hire_date{f}#34, is_rehired{f}#35, job_positions{f}#36, languages{f}#37, languages.byte{f}#38, languages.long{f}#39, languages.short{f}#40, last_name{f}#41, salary{f}#42, salary_change{f}#43, salary_change.int{f}#44, salary_change.keyword{f}#45, salary_change.long{f}#46, still_hired{f}#47] + \_Project[[avg_worked_seconds{r}#50, birth_date{r}#51, emp_no{r}#52, first_name{r}#53, gender{r}#54, height{r}#55, height.float{r}#56, height.half_float{r}#57, height.scaled_float{r}#58, hire_date{r}#59, is_rehired{r}#60, job_positions{r}#61, languages{r}#62, languages.byte{r}#63, languages.long{r}#64, languages.short{r}#65, last_name{r}#66, salary{r}#67, salary_change{r}#68, salary_change.int{r}#69, salary_change.keyword{r}#70, salary_change.long{r}#71, still_hired{r}#72, max_ts{r}#73, does_not_exist{r}#74]] + \_Eval[[null[LONG] AS avg_worked_seconds#50, null[DATETIME] AS birth_date#51, null[INTEGER] AS emp_no#52, null[KEYWORD] AS first_name#53, null[KEYWORD] AS gender#54, null[DOUBLE] AS height#55, null[DOUBLE] AS height.float#56, null[DOUBLE] AS height.half_float#57, null[DOUBLE] AS height.scaled_float#58, null[DATETIME] AS hire_date#59, null[BOOLEAN] AS is_rehired#60, null[KEYWORD] AS job_positions#61, null[INTEGER] AS languages#62, null[INTEGER] AS languages.byte#63, null[LONG] AS languages.long#64, null[INTEGER] AS languages.short#65, null[KEYWORD] AS last_name#66, null[INTEGER] AS salary#67, null[DOUBLE] AS salary_change#68, null[INTEGER] AS salary_change.int#69, null[KEYWORD] AS salary_change.keyword#70, null[LONG] AS salary_change.long#71, null[BOOLEAN] AS still_hired#72]] + \_Subquery[] + \_Aggregate[[does_not_exist{r}#74],[MAX(@timestamp{f}#75,true[BOOLEAN],PT0S[TIME_DURATION]) AS max_ts#73, does_not_exist{r}#74]] + \_Eval[[null[NULL] AS does_not_exist#74]] + \_EsRelation[sample_data][@timestamp{f}#75, client_ip{f}#76, event_duration{f}#77, message{f}#78] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testSubqueryWithStats/nullify/query.esql b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testSubqueryWithStats/nullify/query.esql new file mode 100644 index 0000000000000..7c5a4d44bddb0 --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testSubqueryWithStats/nullify/query.esql @@ -0,0 +1,2 @@ +SET unmapped_fields="nullify"; FROM employees, (FROM sample_data | STATS max_ts = MAX(@timestamp) BY does_not_exist) +| KEEP emp_no, max_ts, does_not_exist diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testTBucket/load/analysis.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testTBucket/load/analysis.expected new file mode 100644 index 0000000000000..0eadb71bf5ba0 --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testTBucket/load/analysis.expected @@ -0,0 +1,4 @@ +Limit[1000[INTEGER],false,false] +\_Aggregate[[TBUCKET(PT1H[TIME_DURATION],@timestamp{f}#0) AS tbucket(1 hour)#1],[COUNT(*[KEYWORD],true[BOOLEAN],PT0S[TIME_DURATION]) AS c#2, tbucket(1 hour){r}#1]] + \_Filter[TOLONG(does_not_exist{f}#3) > 0[INTEGER]] + \_EsRelation[sample_data][@timestamp{f}#0, client_ip{f}#4, event_duration{f}#5, message{f}#6, does_not_exist{f}#3] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testTBucket/load/query.esql b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testTBucket/load/query.esql new file mode 100644 index 0000000000000..b32e8bd6d23f4 --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testTBucket/load/query.esql @@ -0,0 +1,3 @@ +SET unmapped_fields="load"; FROM sample_data +| WHERE does_not_exist::LONG > 0 +| STATS c = COUNT(*) BY tbucket(1 hour) diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testTBucket/nullify/analysis.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testTBucket/nullify/analysis.expected new file mode 100644 index 0000000000000..91da106ed92ba --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testTBucket/nullify/analysis.expected @@ -0,0 +1,5 @@ +Limit[1000[INTEGER],false,false] +\_Aggregate[[TBUCKET(PT1H[TIME_DURATION],@timestamp{f}#0) AS tbucket(1 hour)#1],[COUNT(*[KEYWORD],true[BOOLEAN],PT0S[TIME_DURATION]) AS c#2, tbucket(1 hour){r}#1]] + \_Filter[TOLONG(does_not_exist{r}#3) > 0[INTEGER]] + \_Eval[[null[NULL] AS does_not_exist#3]] + \_EsRelation[sample_data][@timestamp{f}#0, client_ip{f}#4, event_duration{f}#5, message{f}#6] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testTBucket/nullify/query.esql b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testTBucket/nullify/query.esql new file mode 100644 index 0000000000000..b6b417785892b --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testTBucket/nullify/query.esql @@ -0,0 +1,3 @@ +SET unmapped_fields="nullify"; FROM sample_data +| WHERE does_not_exist::LONG > 0 +| STATS c = COUNT(*) BY tbucket(1 hour) diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testTBucketAggregateUnmapped/load/analysis.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testTBucketAggregateUnmapped/load/analysis.expected new file mode 100644 index 0000000000000..5dc208a9d01de --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testTBucketAggregateUnmapped/load/analysis.expected @@ -0,0 +1,3 @@ +Limit[1000[INTEGER],false,false] +\_Aggregate[[TBUCKET(P1D[DATE_PERIOD],@timestamp{f}#0) AS tbucket(1 day)#1],[SUM(TODOUBLE(does_not_exist{f}#2),true[BOOLEAN],PT0S[TIME_DURATION],compensated[KEYWORD]) AS s#3, COUNT(*[KEYWORD],true[BOOLEAN],PT0S[TIME_DURATION]) AS c#4, tbucket(1 day){r}#1]] + \_EsRelation[sample_data][@timestamp{f}#0, client_ip{f}#5, event_duration{f}#6, message{f}#7, does_not_exist{f}#2] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testTBucketAggregateUnmapped/load/query.esql b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testTBucketAggregateUnmapped/load/query.esql new file mode 100644 index 0000000000000..8ee634876a9b7 --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testTBucketAggregateUnmapped/load/query.esql @@ -0,0 +1,2 @@ +SET unmapped_fields="load"; FROM sample_data +| STATS s = SUM(does_not_exist::DOUBLE), c = COUNT(*) BY tbucket(1 day) diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testTBucketAggregateUnmapped/nullify/analysis.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testTBucketAggregateUnmapped/nullify/analysis.expected new file mode 100644 index 0000000000000..630cfad99e1d9 --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testTBucketAggregateUnmapped/nullify/analysis.expected @@ -0,0 +1,4 @@ +Limit[1000[INTEGER],false,false] +\_Aggregate[[TBUCKET(P1D[DATE_PERIOD],@timestamp{f}#0) AS tbucket(1 day)#1],[SUM(TODOUBLE(does_not_exist{r}#2),true[BOOLEAN],PT0S[TIME_DURATION],compensated[KEYWORD]) AS s#3, COUNT(*[KEYWORD],true[BOOLEAN],PT0S[TIME_DURATION]) AS c#4, tbucket(1 day){r}#1]] + \_Eval[[null[NULL] AS does_not_exist#2]] + \_EsRelation[sample_data][@timestamp{f}#0, client_ip{f}#5, event_duration{f}#6, message{f}#7] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testTBucketAggregateUnmapped/nullify/query.esql b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testTBucketAggregateUnmapped/nullify/query.esql new file mode 100644 index 0000000000000..cbf52dd9c02eb --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testTBucketAggregateUnmapped/nullify/query.esql @@ -0,0 +1,2 @@ +SET unmapped_fields="nullify"; FROM sample_data +| STATS s = SUM(does_not_exist::DOUBLE), c = COUNT(*) BY tbucket(1 day) diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testTBucketGroupByUnmapped/load/analysis.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testTBucketGroupByUnmapped/load/analysis.expected new file mode 100644 index 0000000000000..0a5930587890d --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testTBucketGroupByUnmapped/load/analysis.expected @@ -0,0 +1,3 @@ +Limit[1000[INTEGER],false,false] +\_Aggregate[[TBUCKET(PT1H[TIME_DURATION],@timestamp{f}#0) AS tbucket(1 hour)#1, does_not_exist{f}#2],[COUNT(*[KEYWORD],true[BOOLEAN],PT0S[TIME_DURATION]) AS c#3, tbucket(1 hour){r}#1, does_not_exist{f}#2]] + \_EsRelation[sample_data][@timestamp{f}#0, client_ip{f}#4, event_duration{f}#5, message{f}#6, does_not_exist{f}#2] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testTBucketGroupByUnmapped/load/query.esql b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testTBucketGroupByUnmapped/load/query.esql new file mode 100644 index 0000000000000..33c3866fe3563 --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testTBucketGroupByUnmapped/load/query.esql @@ -0,0 +1,2 @@ +SET unmapped_fields="load"; FROM sample_data +| STATS c = COUNT(*) BY tbucket(1 hour), does_not_exist diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testTBucketGroupByUnmapped/nullify/analysis.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testTBucketGroupByUnmapped/nullify/analysis.expected new file mode 100644 index 0000000000000..0ddcf7afa969d --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testTBucketGroupByUnmapped/nullify/analysis.expected @@ -0,0 +1,4 @@ +Limit[1000[INTEGER],false,false] +\_Aggregate[[TBUCKET(PT1H[TIME_DURATION],@timestamp{f}#0) AS tbucket(1 hour)#1, does_not_exist{r}#2],[COUNT(*[KEYWORD],true[BOOLEAN],PT0S[TIME_DURATION]) AS c#3, tbucket(1 hour){r}#1, does_not_exist{r}#2]] + \_Eval[[null[NULL] AS does_not_exist#2]] + \_EsRelation[sample_data][@timestamp{f}#0, client_ip{f}#4, event_duration{f}#5, message{f}#6] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testTBucketGroupByUnmapped/nullify/query.esql b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testTBucketGroupByUnmapped/nullify/query.esql new file mode 100644 index 0000000000000..0ddc50c5758d4 --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testTBucketGroupByUnmapped/nullify/query.esql @@ -0,0 +1,2 @@ +SET unmapped_fields="nullify"; FROM sample_data +| STATS c = COUNT(*) BY tbucket(1 hour), does_not_exist diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testTBucketWithUnmappedField/load/analysis.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testTBucketWithUnmappedField/load/analysis.expected new file mode 100644 index 0000000000000..b94f828d0e124 --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testTBucketWithUnmappedField/load/analysis.expected @@ -0,0 +1,3 @@ +Limit[1000[INTEGER],false,false] +\_Aggregate[[TBUCKET(P1D[DATE_PERIOD],@timestamp{f}#0) AS tbucket(1 day)#1],[SUM(TODOUBLE(does_not_exist{f}#2),true[BOOLEAN],PT0S[TIME_DURATION],compensated[KEYWORD]) AS s#3, tbucket(1 day){r}#1]] + \_EsRelation[sample_data][@timestamp{f}#0, client_ip{f}#4, event_duration{f}#5, message{f}#6, does_not_exist{f}#2] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testTBucketWithUnmappedField/load/query.esql b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testTBucketWithUnmappedField/load/query.esql new file mode 100644 index 0000000000000..f0d33fb33d8a2 --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testTBucketWithUnmappedField/load/query.esql @@ -0,0 +1,2 @@ +SET unmapped_fields="load"; FROM sample_data +| STATS s = SUM(does_not_exist::DOUBLE) BY tbucket(1 day) diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testTBucketWithUnmappedField/nullify/analysis.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testTBucketWithUnmappedField/nullify/analysis.expected new file mode 100644 index 0000000000000..b9d36a0af9fef --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testTBucketWithUnmappedField/nullify/analysis.expected @@ -0,0 +1,4 @@ +Limit[1000[INTEGER],false,false] +\_Aggregate[[TBUCKET(P1D[DATE_PERIOD],@timestamp{f}#0) AS tbucket(1 day)#1],[SUM(TODOUBLE(does_not_exist{r}#2),true[BOOLEAN],PT0S[TIME_DURATION],compensated[KEYWORD]) AS s#3, tbucket(1 day){r}#1]] + \_Eval[[null[NULL] AS does_not_exist#2]] + \_EsRelation[sample_data][@timestamp{f}#0, client_ip{f}#4, event_duration{f}#5, message{f}#6] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testTBucketWithUnmappedField/nullify/query.esql b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testTBucketWithUnmappedField/nullify/query.esql new file mode 100644 index 0000000000000..dbe8b20220655 --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testTBucketWithUnmappedField/nullify/query.esql @@ -0,0 +1,2 @@ +SET unmapped_fields="nullify"; FROM sample_data +| STATS s = SUM(does_not_exist::DOUBLE) BY tbucket(1 day) diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testTimeSeriesAvgOverTime/load/analysis.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testTimeSeriesAvgOverTime/load/analysis.expected new file mode 100644 index 0000000000000..461abb31b2a3e --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testTimeSeriesAvgOverTime/load/analysis.expected @@ -0,0 +1,4 @@ +Limit[1000000[INTEGER],false,false] +\_TimeSeriesAggregate[[_timeseries{f}#0, TBUCKET(PT1H[TIME_DURATION],@timestamp{f}#1) AS tbucket(1 hour)#2],[VALUES(AVGOVERTIME(network.eth0.rx{f}#3,true[BOOLEAN],PT0S[TIME_DURATION]),true[BOOLEAN],PT0S[TIME_DURATION]) AS a#4, tbucket(1 hour){r}#2],null,@timestamp{f}#1] + \_Filter[TOLONG(does_not_exist{f}#5) > 0[INTEGER]] + \_EsRelation[k8s][TIME_SERIES][@timestamp{f}#1, client.ip{f}#6, cluster{f}#7, event{f}#8, event_city{f}#9, event_city_boundary{f}#10, event_location{f}#11, event_log{f}#12, event_shape{f}#13, events_received{f}#14, network.bytes_in{f}#15, network.cost{f}#16, network.eth0.currently_connected_clients{f}#17, network.eth0.firmware_version{f}#18, network.eth0.last_up{f}#19, network.eth0.rx{f}#3, network.eth0.tx{f}#20, network.eth0.up{f}#21, network.total_bytes_in{f}#22, network.total_bytes_out{f}#23, network.total_cost{f}#24, pod{f}#25, region{f}#26, _timeseries{f}#0, does_not_exist{f}#5] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testTimeSeriesAvgOverTime/load/query.esql b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testTimeSeriesAvgOverTime/load/query.esql new file mode 100644 index 0000000000000..07b29b5b8cfac --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testTimeSeriesAvgOverTime/load/query.esql @@ -0,0 +1,3 @@ +SET unmapped_fields="load"; TS k8s +| WHERE does_not_exist::LONG > 0 +| STATS a = AVG_OVER_TIME(network.eth0.rx) BY tbucket(1 hour) diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testTimeSeriesAvgOverTime/nullify/analysis.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testTimeSeriesAvgOverTime/nullify/analysis.expected new file mode 100644 index 0000000000000..d9cd26163304f --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testTimeSeriesAvgOverTime/nullify/analysis.expected @@ -0,0 +1,5 @@ +Limit[1000000[INTEGER],false,false] +\_TimeSeriesAggregate[[_timeseries{f}#0, TBUCKET(PT1H[TIME_DURATION],@timestamp{f}#1) AS tbucket(1 hour)#2],[VALUES(AVGOVERTIME(network.eth0.rx{f}#3,true[BOOLEAN],PT0S[TIME_DURATION]),true[BOOLEAN],PT0S[TIME_DURATION]) AS a#4, tbucket(1 hour){r}#2],null,@timestamp{f}#1] + \_Filter[TOLONG(does_not_exist{r}#5) > 0[INTEGER]] + \_Eval[[null[NULL] AS does_not_exist#5]] + \_EsRelation[k8s][TIME_SERIES][@timestamp{f}#1, client.ip{f}#6, cluster{f}#7, event{f}#8, event_city{f}#9, event_city_boundary{f}#10, event_location{f}#11, event_log{f}#12, event_shape{f}#13, events_received{f}#14, network.bytes_in{f}#15, network.cost{f}#16, network.eth0.currently_connected_clients{f}#17, network.eth0.firmware_version{f}#18, network.eth0.last_up{f}#19, network.eth0.rx{f}#3, network.eth0.tx{f}#20, network.eth0.up{f}#21, network.total_bytes_in{f}#22, network.total_bytes_out{f}#23, network.total_cost{f}#24, pod{f}#25, region{f}#26, _timeseries{f}#0] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testTimeSeriesAvgOverTime/nullify/query.esql b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testTimeSeriesAvgOverTime/nullify/query.esql new file mode 100644 index 0000000000000..3ae9a1aa9dbe9 --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testTimeSeriesAvgOverTime/nullify/query.esql @@ -0,0 +1,3 @@ +SET unmapped_fields="nullify"; TS k8s +| WHERE does_not_exist::LONG > 0 +| STATS a = AVG_OVER_TIME(network.eth0.rx) BY tbucket(1 hour) diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testTimeSeriesEvalUnmapped/load/analysis.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testTimeSeriesEvalUnmapped/load/analysis.expected new file mode 100644 index 0000000000000..e19e2e842bf54 --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testTimeSeriesEvalUnmapped/load/analysis.expected @@ -0,0 +1,4 @@ +Limit[1000[INTEGER],false,false] +\_Project[[@timestamp{f}#0, cluster{f}#1, x{r}#2]] + \_Eval[[TODOUBLE(does_not_exist{f}#3) + network.cost{f}#4 AS x#2]] + \_EsRelation[k8s][TIME_SERIES][@timestamp{f}#0, client.ip{f}#5, cluster{f}#1, event{f}#6, event_city{f}#7, event_city_boundary{f}#8, event_location{f}#9, event_log{f}#10, event_shape{f}#11, events_received{f}#12, network.bytes_in{f}#13, network.cost{f}#4, network.eth0.currently_connected_clients{f}#14, network.eth0.firmware_version{f}#15, network.eth0.last_up{f}#16, network.eth0.rx{f}#17, network.eth0.tx{f}#18, network.eth0.up{f}#19, network.total_bytes_in{f}#20, network.total_bytes_out{f}#21, network.total_cost{f}#22, pod{f}#23, region{f}#24, does_not_exist{f}#3] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testTimeSeriesEvalUnmapped/load/query.esql b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testTimeSeriesEvalUnmapped/load/query.esql new file mode 100644 index 0000000000000..94e371a53661c --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testTimeSeriesEvalUnmapped/load/query.esql @@ -0,0 +1,3 @@ +SET unmapped_fields="load"; TS k8s +| EVAL x = does_not_exist::DOUBLE + network.cost +| KEEP @timestamp, cluster, x diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testTimeSeriesEvalUnmapped/nullify/analysis.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testTimeSeriesEvalUnmapped/nullify/analysis.expected new file mode 100644 index 0000000000000..0b49d801279f5 --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testTimeSeriesEvalUnmapped/nullify/analysis.expected @@ -0,0 +1,5 @@ +Limit[1000[INTEGER],false,false] +\_Project[[@timestamp{f}#0, cluster{f}#1, x{r}#2]] + \_Eval[[TODOUBLE(does_not_exist{r}#3) + network.cost{f}#4 AS x#2]] + \_Eval[[null[NULL] AS does_not_exist#3]] + \_EsRelation[k8s][TIME_SERIES][@timestamp{f}#0, client.ip{f}#5, cluster{f}#1, event{f}#6, event_city{f}#7, event_city_boundary{f}#8, event_location{f}#9, event_log{f}#10, event_shape{f}#11, events_received{f}#12, network.bytes_in{f}#13, network.cost{f}#4, network.eth0.currently_connected_clients{f}#14, network.eth0.firmware_version{f}#15, network.eth0.last_up{f}#16, network.eth0.rx{f}#17, network.eth0.tx{f}#18, network.eth0.up{f}#19, network.total_bytes_in{f}#20, network.total_bytes_out{f}#21, network.total_cost{f}#22, pod{f}#23, region{f}#24] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testTimeSeriesEvalUnmapped/nullify/query.esql b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testTimeSeriesEvalUnmapped/nullify/query.esql new file mode 100644 index 0000000000000..a9a6f91b2b94b --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testTimeSeriesEvalUnmapped/nullify/query.esql @@ -0,0 +1,3 @@ +SET unmapped_fields="nullify"; TS k8s +| EVAL x = does_not_exist::DOUBLE + network.cost +| KEEP @timestamp, cluster, x diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testTimeSeriesFirstOverTimeUnmapped/load/analysis.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testTimeSeriesFirstOverTimeUnmapped/load/analysis.expected new file mode 100644 index 0000000000000..a53ba9b57e55d --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testTimeSeriesFirstOverTimeUnmapped/load/analysis.expected @@ -0,0 +1,3 @@ +Limit[1000000[INTEGER],false,false] +\_TimeSeriesAggregate[[_timeseries{f}#0, TBUCKET(PT1H[TIME_DURATION],@timestamp{f}#1) AS tbucket(1 hour)#2],[VALUES(FIRSTOVERTIME(TODOUBLE(does_not_exist{f}#3),true[BOOLEAN],PT0S[TIME_DURATION],@timestamp{f}#1),true[BOOLEAN],PT0S[TIME_DURATION]) AS f#4, tbucket(1 hour){r}#2],null,@timestamp{f}#1] + \_EsRelation[k8s][TIME_SERIES][@timestamp{f}#1, client.ip{f}#5, cluster{f}#6, event{f}#7, event_city{f}#8, event_city_boundary{f}#9, event_location{f}#10, event_log{f}#11, event_shape{f}#12, events_received{f}#13, network.bytes_in{f}#14, network.cost{f}#15, network.eth0.currently_connected_clients{f}#16, network.eth0.firmware_version{f}#17, network.eth0.last_up{f}#18, network.eth0.rx{f}#19, network.eth0.tx{f}#20, network.eth0.up{f}#21, network.total_bytes_in{f}#22, network.total_bytes_out{f}#23, network.total_cost{f}#24, pod{f}#25, region{f}#26, _timeseries{f}#0, does_not_exist{f}#3] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testTimeSeriesFirstOverTimeUnmapped/load/query.esql b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testTimeSeriesFirstOverTimeUnmapped/load/query.esql new file mode 100644 index 0000000000000..8cddd18499f03 --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testTimeSeriesFirstOverTimeUnmapped/load/query.esql @@ -0,0 +1,2 @@ +SET unmapped_fields="load"; TS k8s +| STATS f = FIRST_OVER_TIME(does_not_exist::DOUBLE) BY tbucket(1 hour) diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testTimeSeriesFirstOverTimeUnmapped/nullify/analysis.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testTimeSeriesFirstOverTimeUnmapped/nullify/analysis.expected new file mode 100644 index 0000000000000..f5b122a261793 --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testTimeSeriesFirstOverTimeUnmapped/nullify/analysis.expected @@ -0,0 +1,4 @@ +Limit[1000000[INTEGER],false,false] +\_TimeSeriesAggregate[[_timeseries{f}#0, TBUCKET(PT1H[TIME_DURATION],@timestamp{f}#1) AS tbucket(1 hour)#2],[VALUES(FIRSTOVERTIME(TODOUBLE(does_not_exist{r}#3),true[BOOLEAN],PT0S[TIME_DURATION],@timestamp{f}#1),true[BOOLEAN],PT0S[TIME_DURATION]) AS f#4, tbucket(1 hour){r}#2],null,@timestamp{f}#1] + \_Eval[[null[NULL] AS does_not_exist#3]] + \_EsRelation[k8s][TIME_SERIES][@timestamp{f}#1, client.ip{f}#5, cluster{f}#6, event{f}#7, event_city{f}#8, event_city_boundary{f}#9, event_location{f}#10, event_log{f}#11, event_shape{f}#12, events_received{f}#13, network.bytes_in{f}#14, network.cost{f}#15, network.eth0.currently_connected_clients{f}#16, network.eth0.firmware_version{f}#17, network.eth0.last_up{f}#18, network.eth0.rx{f}#19, network.eth0.tx{f}#20, network.eth0.up{f}#21, network.total_bytes_in{f}#22, network.total_bytes_out{f}#23, network.total_cost{f}#24, pod{f}#25, region{f}#26, _timeseries{f}#0] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testTimeSeriesFirstOverTimeUnmapped/nullify/query.esql b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testTimeSeriesFirstOverTimeUnmapped/nullify/query.esql new file mode 100644 index 0000000000000..830583a7048ff --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testTimeSeriesFirstOverTimeUnmapped/nullify/query.esql @@ -0,0 +1,2 @@ +SET unmapped_fields="nullify"; TS k8s +| STATS f = FIRST_OVER_TIME(does_not_exist::DOUBLE) BY tbucket(1 hour) diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testTimeSeriesKeepUnmapped/load/analysis.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testTimeSeriesKeepUnmapped/load/analysis.expected new file mode 100644 index 0000000000000..4819c89f1c210 --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testTimeSeriesKeepUnmapped/load/analysis.expected @@ -0,0 +1,3 @@ +Limit[1000[INTEGER],false,false] +\_Project[[@timestamp{f}#0, cluster{f}#1, does_not_exist{f}#2]] + \_EsRelation[k8s][TIME_SERIES][@timestamp{f}#0, client.ip{f}#3, cluster{f}#1, event{f}#4, event_city{f}#5, event_city_boundary{f}#6, event_location{f}#7, event_log{f}#8, event_shape{f}#9, events_received{f}#10, network.bytes_in{f}#11, network.cost{f}#12, network.eth0.currently_connected_clients{f}#13, network.eth0.firmware_version{f}#14, network.eth0.last_up{f}#15, network.eth0.rx{f}#16, network.eth0.tx{f}#17, network.eth0.up{f}#18, network.total_bytes_in{f}#19, network.total_bytes_out{f}#20, network.total_cost{f}#21, pod{f}#22, region{f}#23, does_not_exist{f}#2] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testTimeSeriesKeepUnmapped/load/query.esql b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testTimeSeriesKeepUnmapped/load/query.esql new file mode 100644 index 0000000000000..d872e477d1225 --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testTimeSeriesKeepUnmapped/load/query.esql @@ -0,0 +1,2 @@ +SET unmapped_fields="load"; TS k8s +| KEEP @timestamp, cluster, does_not_exist diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testTimeSeriesKeepUnmapped/nullify/analysis.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testTimeSeriesKeepUnmapped/nullify/analysis.expected new file mode 100644 index 0000000000000..6a20c2f90cbfd --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testTimeSeriesKeepUnmapped/nullify/analysis.expected @@ -0,0 +1,4 @@ +Limit[1000[INTEGER],false,false] +\_Project[[@timestamp{f}#0, cluster{f}#1, does_not_exist{r}#2]] + \_Eval[[null[NULL] AS does_not_exist#2]] + \_EsRelation[k8s][TIME_SERIES][@timestamp{f}#0, client.ip{f}#3, cluster{f}#1, event{f}#4, event_city{f}#5, event_city_boundary{f}#6, event_location{f}#7, event_log{f}#8, event_shape{f}#9, events_received{f}#10, network.bytes_in{f}#11, network.cost{f}#12, network.eth0.currently_connected_clients{f}#13, network.eth0.firmware_version{f}#14, network.eth0.last_up{f}#15, network.eth0.rx{f}#16, network.eth0.tx{f}#17, network.eth0.up{f}#18, network.total_bytes_in{f}#19, network.total_bytes_out{f}#20, network.total_cost{f}#21, pod{f}#22, region{f}#23] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testTimeSeriesKeepUnmapped/nullify/query.esql b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testTimeSeriesKeepUnmapped/nullify/query.esql new file mode 100644 index 0000000000000..c6b92a7280467 --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testTimeSeriesKeepUnmapped/nullify/query.esql @@ -0,0 +1,2 @@ +SET unmapped_fields="nullify"; TS k8s +| KEEP @timestamp, cluster, does_not_exist diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testTimeSeriesMaxOverTime/load/analysis.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testTimeSeriesMaxOverTime/load/analysis.expected new file mode 100644 index 0000000000000..57b3580871a30 --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testTimeSeriesMaxOverTime/load/analysis.expected @@ -0,0 +1,4 @@ +Limit[1000000[INTEGER],false,false] +\_TimeSeriesAggregate[[_timeseries{f}#0, TBUCKET(PT1H[TIME_DURATION],@timestamp{f}#1) AS tbucket(1 hour)#2],[VALUES(MAXOVERTIME(network.eth0.tx{f}#3,true[BOOLEAN],PT0S[TIME_DURATION]),true[BOOLEAN],PT0S[TIME_DURATION]) AS m#4, tbucket(1 hour){r}#2],null,@timestamp{f}#1] + \_Eval[[TODOUBLE(does_not_exist{f}#5) + 1[INTEGER] AS x#6]] + \_EsRelation[k8s][TIME_SERIES][@timestamp{f}#1, client.ip{f}#7, cluster{f}#8, event{f}#9, event_city{f}#10, event_city_boundary{f}#11, event_location{f}#12, event_log{f}#13, event_shape{f}#14, events_received{f}#15, network.bytes_in{f}#16, network.cost{f}#17, network.eth0.currently_connected_clients{f}#18, network.eth0.firmware_version{f}#19, network.eth0.last_up{f}#20, network.eth0.rx{f}#21, network.eth0.tx{f}#3, network.eth0.up{f}#22, network.total_bytes_in{f}#23, network.total_bytes_out{f}#24, network.total_cost{f}#25, pod{f}#26, region{f}#27, _timeseries{f}#0, does_not_exist{f}#5] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testTimeSeriesMaxOverTime/load/query.esql b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testTimeSeriesMaxOverTime/load/query.esql new file mode 100644 index 0000000000000..5d1d571c052d2 --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testTimeSeriesMaxOverTime/load/query.esql @@ -0,0 +1,3 @@ +SET unmapped_fields="load"; TS k8s +| EVAL x = does_not_exist::DOUBLE + 1 +| STATS m = MAX_OVER_TIME(network.eth0.tx) BY tbucket(1 hour) diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testTimeSeriesMaxOverTime/nullify/analysis.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testTimeSeriesMaxOverTime/nullify/analysis.expected new file mode 100644 index 0000000000000..418f1280705a3 --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testTimeSeriesMaxOverTime/nullify/analysis.expected @@ -0,0 +1,5 @@ +Limit[1000000[INTEGER],false,false] +\_TimeSeriesAggregate[[_timeseries{f}#0, TBUCKET(PT1H[TIME_DURATION],@timestamp{f}#1) AS tbucket(1 hour)#2],[VALUES(MAXOVERTIME(network.eth0.tx{f}#3,true[BOOLEAN],PT0S[TIME_DURATION]),true[BOOLEAN],PT0S[TIME_DURATION]) AS m#4, tbucket(1 hour){r}#2],null,@timestamp{f}#1] + \_Eval[[TODOUBLE(does_not_exist{r}#5) + 1[INTEGER] AS x#6]] + \_Eval[[null[NULL] AS does_not_exist#5]] + \_EsRelation[k8s][TIME_SERIES][@timestamp{f}#1, client.ip{f}#7, cluster{f}#8, event{f}#9, event_city{f}#10, event_city_boundary{f}#11, event_location{f}#12, event_log{f}#13, event_shape{f}#14, events_received{f}#15, network.bytes_in{f}#16, network.cost{f}#17, network.eth0.currently_connected_clients{f}#18, network.eth0.firmware_version{f}#19, network.eth0.last_up{f}#20, network.eth0.rx{f}#21, network.eth0.tx{f}#3, network.eth0.up{f}#22, network.total_bytes_in{f}#23, network.total_bytes_out{f}#24, network.total_cost{f}#25, pod{f}#26, region{f}#27, _timeseries{f}#0] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testTimeSeriesMaxOverTime/nullify/query.esql b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testTimeSeriesMaxOverTime/nullify/query.esql new file mode 100644 index 0000000000000..8cfedb3e58a5c --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testTimeSeriesMaxOverTime/nullify/query.esql @@ -0,0 +1,3 @@ +SET unmapped_fields="nullify"; TS k8s +| EVAL x = does_not_exist::DOUBLE + 1 +| STATS m = MAX_OVER_TIME(network.eth0.tx) BY tbucket(1 hour) diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testTimeSeriesRate/load/analysis.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testTimeSeriesRate/load/analysis.expected new file mode 100644 index 0000000000000..c60ce59bffa66 --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testTimeSeriesRate/load/analysis.expected @@ -0,0 +1,4 @@ +Limit[1000000[INTEGER],false,false] +\_TimeSeriesAggregate[[_timeseries{f}#0, TBUCKET(PT1H[TIME_DURATION],@timestamp{f}#1) AS tbucket(1 hour)#2],[VALUES(RATE(network.total_cost{f}#3,true[BOOLEAN],PT0S[TIME_DURATION],@timestamp{f}#1),true[BOOLEAN],PT0S[TIME_DURATION]) AS r#4, tbucket(1 hour){r}#2],null,@timestamp{f}#1] + \_Filter[TOLONG(does_not_exist{f}#5) > 0[INTEGER]] + \_EsRelation[k8s][TIME_SERIES][@timestamp{f}#1, client.ip{f}#6, cluster{f}#7, event{f}#8, event_city{f}#9, event_city_boundary{f}#10, event_location{f}#11, event_log{f}#12, event_shape{f}#13, events_received{f}#14, network.bytes_in{f}#15, network.cost{f}#16, network.eth0.currently_connected_clients{f}#17, network.eth0.firmware_version{f}#18, network.eth0.last_up{f}#19, network.eth0.rx{f}#20, network.eth0.tx{f}#21, network.eth0.up{f}#22, network.total_bytes_in{f}#23, network.total_bytes_out{f}#24, network.total_cost{f}#3, pod{f}#25, region{f}#26, _timeseries{f}#0, does_not_exist{f}#5] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testTimeSeriesRate/load/query.esql b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testTimeSeriesRate/load/query.esql new file mode 100644 index 0000000000000..26c827ff5d107 --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testTimeSeriesRate/load/query.esql @@ -0,0 +1,3 @@ +SET unmapped_fields="load"; TS k8s +| WHERE does_not_exist::LONG > 0 +| STATS r = RATE(network.total_cost) BY tbucket(1 hour) diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testTimeSeriesRate/nullify/analysis.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testTimeSeriesRate/nullify/analysis.expected new file mode 100644 index 0000000000000..e51c21b27f6a7 --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testTimeSeriesRate/nullify/analysis.expected @@ -0,0 +1,5 @@ +Limit[1000000[INTEGER],false,false] +\_TimeSeriesAggregate[[_timeseries{f}#0, TBUCKET(PT1H[TIME_DURATION],@timestamp{f}#1) AS tbucket(1 hour)#2],[VALUES(RATE(network.total_cost{f}#3,true[BOOLEAN],PT0S[TIME_DURATION],@timestamp{f}#1),true[BOOLEAN],PT0S[TIME_DURATION]) AS r#4, tbucket(1 hour){r}#2],null,@timestamp{f}#1] + \_Filter[TOLONG(does_not_exist{r}#5) > 0[INTEGER]] + \_Eval[[null[NULL] AS does_not_exist#5]] + \_EsRelation[k8s][TIME_SERIES][@timestamp{f}#1, client.ip{f}#6, cluster{f}#7, event{f}#8, event_city{f}#9, event_city_boundary{f}#10, event_location{f}#11, event_log{f}#12, event_shape{f}#13, events_received{f}#14, network.bytes_in{f}#15, network.cost{f}#16, network.eth0.currently_connected_clients{f}#17, network.eth0.firmware_version{f}#18, network.eth0.last_up{f}#19, network.eth0.rx{f}#20, network.eth0.tx{f}#21, network.eth0.up{f}#22, network.total_bytes_in{f}#23, network.total_bytes_out{f}#24, network.total_cost{f}#3, pod{f}#25, region{f}#26, _timeseries{f}#0] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testTimeSeriesRate/nullify/query.esql b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testTimeSeriesRate/nullify/query.esql new file mode 100644 index 0000000000000..142d352cd603f --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testTimeSeriesRate/nullify/query.esql @@ -0,0 +1,3 @@ +SET unmapped_fields="nullify"; TS k8s +| WHERE does_not_exist::LONG > 0 +| STATS r = RATE(network.total_cost) BY tbucket(1 hour) diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testTimeSeriesRateUnmapped/nullify/analysis.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testTimeSeriesRateUnmapped/nullify/analysis.expected new file mode 100644 index 0000000000000..41c760dcac978 --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testTimeSeriesRateUnmapped/nullify/analysis.expected @@ -0,0 +1,4 @@ +Limit[1000000[INTEGER],false,false] +\_TimeSeriesAggregate[[_timeseries{f}#0, TBUCKET(PT1H[TIME_DURATION],@timestamp{f}#1) AS tbucket(1 hour)#2],[VALUES(RATE(does_not_exist{r}#3,true[BOOLEAN],PT0S[TIME_DURATION],@timestamp{f}#1),true[BOOLEAN],PT0S[TIME_DURATION]) AS r#4, tbucket(1 hour){r}#2],null,@timestamp{f}#1] + \_Eval[[null[NULL] AS does_not_exist#3]] + \_EsRelation[k8s][TIME_SERIES][@timestamp{f}#1, client.ip{f}#5, cluster{f}#6, event{f}#7, event_city{f}#8, event_city_boundary{f}#9, event_location{f}#10, event_log{f}#11, event_shape{f}#12, events_received{f}#13, network.bytes_in{f}#14, network.cost{f}#15, network.eth0.currently_connected_clients{f}#16, network.eth0.firmware_version{f}#17, network.eth0.last_up{f}#18, network.eth0.rx{f}#19, network.eth0.tx{f}#20, network.eth0.up{f}#21, network.total_bytes_in{f}#22, network.total_bytes_out{f}#23, network.total_cost{f}#24, pod{f}#25, region{f}#26, _timeseries{f}#0] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testTimeSeriesRateUnmapped/nullify/query.esql b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testTimeSeriesRateUnmapped/nullify/query.esql new file mode 100644 index 0000000000000..f398daec38c45 --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testTimeSeriesRateUnmapped/nullify/query.esql @@ -0,0 +1,2 @@ +SET unmapped_fields="nullify"; TS k8s +| STATS r = RATE(does_not_exist) BY tbucket(1 hour) diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testTimeSeriesRateWithUnmappedGroupBy/nullify/query.esql b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testTimeSeriesRateWithUnmappedGroupBy/nullify/query.esql new file mode 100644 index 0000000000000..f084c1078693a --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testTimeSeriesRateWithUnmappedGroupBy/nullify/query.esql @@ -0,0 +1,2 @@ +SET unmapped_fields="nullify"; TS k8s +| STATS r = RATE(network.total_cost) BY tbucket(1 hour), does_not_exist From eefa9cf25980413163bb43d3cda035ea9ed970d1 Mon Sep 17 00:00:00 2001 From: Gal Lalouche Date: Tue, 3 Feb 2026 21:28:52 +0200 Subject: [PATCH 19/25] Add multi index tests --- .../analysis/AnalyzerUnmappedGoldenTests.java | 37 +++++++++++++++++++ .../load/analysis.expected | 3 ++ .../load/query.esql | 2 + .../nullify/analysis.expected | 3 ++ .../nullify/query.esql | 2 + .../load/analysis.expected | 4 ++ .../load/query.esql | 3 ++ .../nullify/analysis.expected | 4 ++ .../nullify/query.esql | 3 ++ .../load/analysis.expected | 3 ++ .../testPartiallyMappedField/load/query.esql | 2 + .../nullify/analysis.expected | 4 ++ .../nullify/query.esql | 2 + .../load/analysis.expected | 4 ++ .../load/query.esql | 3 ++ .../nullify/analysis.expected | 5 +++ .../nullify/query.esql | 3 ++ .../load/analysis.expected | 3 ++ .../load/query.esql | 2 + .../nullify/analysis.expected | 4 ++ .../nullify/query.esql | 2 + 21 files changed, 98 insertions(+) create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testDifferentTypesAcrossIndices/load/analysis.expected create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testDifferentTypesAcrossIndices/load/query.esql create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testDifferentTypesAcrossIndices/nullify/analysis.expected create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testDifferentTypesAcrossIndices/nullify/query.esql create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testDifferentTypesWithCast/load/analysis.expected create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testDifferentTypesWithCast/load/query.esql create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testDifferentTypesWithCast/nullify/analysis.expected create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testDifferentTypesWithCast/nullify/query.esql create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testPartiallyMappedField/load/analysis.expected create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testPartiallyMappedField/load/query.esql create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testPartiallyMappedField/nullify/analysis.expected create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testPartiallyMappedField/nullify/query.esql create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testPartiallyMappedFieldWithEval/load/analysis.expected create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testPartiallyMappedFieldWithEval/load/query.esql create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testPartiallyMappedFieldWithEval/nullify/analysis.expected create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testPartiallyMappedFieldWithEval/nullify/query.esql create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testPartiallyMappedFieldWithStats/load/analysis.expected create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testPartiallyMappedFieldWithStats/load/query.esql create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testPartiallyMappedFieldWithStats/nullify/analysis.expected create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testPartiallyMappedFieldWithStats/nullify/query.esql diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/analysis/AnalyzerUnmappedGoldenTests.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/analysis/AnalyzerUnmappedGoldenTests.java index ce64011cdcb6c..1d480c6701019 100644 --- a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/analysis/AnalyzerUnmappedGoldenTests.java +++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/analysis/AnalyzerUnmappedGoldenTests.java @@ -363,6 +363,43 @@ public void testTimeSeriesFirstOverTimeUnmapped() throws Exception { """); } + public void testPartiallyMappedField() throws Exception { + runTests(""" + FROM sample_data, partial_mapping_sample_data + | KEEP @timestamp, message, unmapped_message + """); + } + + public void testPartiallyMappedFieldWithStats() throws Exception { + runTests(""" + FROM sample_data, partial_mapping_sample_data + | STATS c = COUNT(*) BY unmapped_message + """); + } + + public void testPartiallyMappedFieldWithEval() throws Exception { + runTests(""" + FROM sample_data, partial_mapping_sample_data + | EVAL x = COALESCE(unmapped_message, "missing") + | KEEP @timestamp, x + """); + } + + public void testDifferentTypesAcrossIndices() throws Exception { + runTests(""" + FROM sample_data, sample_data_ts_long + | KEEP @timestamp, message + """); + } + + public void testDifferentTypesWithCast() throws Exception { + runTests(""" + FROM sample_data, sample_data_ts_long + | EVAL ts = @timestamp::STRING + | KEEP ts, message + """); + } + @Override protected java.util.List filteredWarnings() { return withDefaultLimitWarning(super.filteredWarnings()); diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testDifferentTypesAcrossIndices/load/analysis.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testDifferentTypesAcrossIndices/load/analysis.expected new file mode 100644 index 0000000000000..60246e2a52c6f --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testDifferentTypesAcrossIndices/load/analysis.expected @@ -0,0 +1,3 @@ +Limit[1000[INTEGER],false,false] +\_Project[[!@timestamp, message{f}#0]] + \_EsRelation[sample_data,sample_data_ts_long][!@timestamp, client_ip{f}#1, event_duration{f}#2, message{f}#0] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testDifferentTypesAcrossIndices/load/query.esql b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testDifferentTypesAcrossIndices/load/query.esql new file mode 100644 index 0000000000000..36f26bbad39a7 --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testDifferentTypesAcrossIndices/load/query.esql @@ -0,0 +1,2 @@ +SET unmapped_fields="load"; FROM sample_data, sample_data_ts_long +| KEEP @timestamp, message diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testDifferentTypesAcrossIndices/nullify/analysis.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testDifferentTypesAcrossIndices/nullify/analysis.expected new file mode 100644 index 0000000000000..60246e2a52c6f --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testDifferentTypesAcrossIndices/nullify/analysis.expected @@ -0,0 +1,3 @@ +Limit[1000[INTEGER],false,false] +\_Project[[!@timestamp, message{f}#0]] + \_EsRelation[sample_data,sample_data_ts_long][!@timestamp, client_ip{f}#1, event_duration{f}#2, message{f}#0] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testDifferentTypesAcrossIndices/nullify/query.esql b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testDifferentTypesAcrossIndices/nullify/query.esql new file mode 100644 index 0000000000000..b469337a46ebc --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testDifferentTypesAcrossIndices/nullify/query.esql @@ -0,0 +1,2 @@ +SET unmapped_fields="nullify"; FROM sample_data, sample_data_ts_long +| KEEP @timestamp, message diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testDifferentTypesWithCast/load/analysis.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testDifferentTypesWithCast/load/analysis.expected new file mode 100644 index 0000000000000..c13045a018215 --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testDifferentTypesWithCast/load/analysis.expected @@ -0,0 +1,4 @@ +Limit[1000[INTEGER],false,false] +\_Project[[ts{r}#0, message{f}#1]] + \_Eval[[$$@timestamp$converted_to$keyword{f$}#2 AS ts#0]] + \_EsRelation[sample_data,sample_data_ts_long][!@timestamp, client_ip{f}#3, event_duration{f}#4, message{f}#1, $$@timestamp$converted_to$keyword{f$}#2] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testDifferentTypesWithCast/load/query.esql b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testDifferentTypesWithCast/load/query.esql new file mode 100644 index 0000000000000..c739306c06b40 --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testDifferentTypesWithCast/load/query.esql @@ -0,0 +1,3 @@ +SET unmapped_fields="load"; FROM sample_data, sample_data_ts_long +| EVAL ts = @timestamp::STRING +| KEEP ts, message diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testDifferentTypesWithCast/nullify/analysis.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testDifferentTypesWithCast/nullify/analysis.expected new file mode 100644 index 0000000000000..c13045a018215 --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testDifferentTypesWithCast/nullify/analysis.expected @@ -0,0 +1,4 @@ +Limit[1000[INTEGER],false,false] +\_Project[[ts{r}#0, message{f}#1]] + \_Eval[[$$@timestamp$converted_to$keyword{f$}#2 AS ts#0]] + \_EsRelation[sample_data,sample_data_ts_long][!@timestamp, client_ip{f}#3, event_duration{f}#4, message{f}#1, $$@timestamp$converted_to$keyword{f$}#2] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testDifferentTypesWithCast/nullify/query.esql b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testDifferentTypesWithCast/nullify/query.esql new file mode 100644 index 0000000000000..8a4145812c548 --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testDifferentTypesWithCast/nullify/query.esql @@ -0,0 +1,3 @@ +SET unmapped_fields="nullify"; FROM sample_data, sample_data_ts_long +| EVAL ts = @timestamp::STRING +| KEEP ts, message diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testPartiallyMappedField/load/analysis.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testPartiallyMappedField/load/analysis.expected new file mode 100644 index 0000000000000..09d01f355c3bc --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testPartiallyMappedField/load/analysis.expected @@ -0,0 +1,3 @@ +Limit[1000[INTEGER],false,false] +\_Project[[@timestamp{f}#0, message{f}#1, unmapped_message{f}#2]] + \_EsRelation[sample_data,partial_mapping_sample_data][@timestamp{f}#0, client_ip{f}#3, event_duration{f}#4, message{f}#1, unmapped_message{f}#2] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testPartiallyMappedField/load/query.esql b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testPartiallyMappedField/load/query.esql new file mode 100644 index 0000000000000..84d4cfd6038b2 --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testPartiallyMappedField/load/query.esql @@ -0,0 +1,2 @@ +SET unmapped_fields="load"; FROM sample_data, partial_mapping_sample_data +| KEEP @timestamp, message, unmapped_message diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testPartiallyMappedField/nullify/analysis.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testPartiallyMappedField/nullify/analysis.expected new file mode 100644 index 0000000000000..c23e90cb6e10b --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testPartiallyMappedField/nullify/analysis.expected @@ -0,0 +1,4 @@ +Limit[1000[INTEGER],false,false] +\_Project[[@timestamp{f}#0, message{f}#1, unmapped_message{r}#2]] + \_Eval[[null[NULL] AS unmapped_message#2]] + \_EsRelation[sample_data,partial_mapping_sample_data][@timestamp{f}#0, client_ip{f}#3, event_duration{f}#4, message{f}#1] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testPartiallyMappedField/nullify/query.esql b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testPartiallyMappedField/nullify/query.esql new file mode 100644 index 0000000000000..f685cd7d68cda --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testPartiallyMappedField/nullify/query.esql @@ -0,0 +1,2 @@ +SET unmapped_fields="nullify"; FROM sample_data, partial_mapping_sample_data +| KEEP @timestamp, message, unmapped_message diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testPartiallyMappedFieldWithEval/load/analysis.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testPartiallyMappedFieldWithEval/load/analysis.expected new file mode 100644 index 0000000000000..c5c5603a87da1 --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testPartiallyMappedFieldWithEval/load/analysis.expected @@ -0,0 +1,4 @@ +Limit[1000[INTEGER],false,false] +\_Project[[@timestamp{f}#0, x{r}#1]] + \_Eval[[COALESCE(unmapped_message{f}#2,missing[KEYWORD]) AS x#1]] + \_EsRelation[sample_data,partial_mapping_sample_data][@timestamp{f}#0, client_ip{f}#3, event_duration{f}#4, message{f}#5, unmapped_message{f}#2] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testPartiallyMappedFieldWithEval/load/query.esql b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testPartiallyMappedFieldWithEval/load/query.esql new file mode 100644 index 0000000000000..3d56b92b85d47 --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testPartiallyMappedFieldWithEval/load/query.esql @@ -0,0 +1,3 @@ +SET unmapped_fields="load"; FROM sample_data, partial_mapping_sample_data +| EVAL x = COALESCE(unmapped_message, "missing") +| KEEP @timestamp, x diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testPartiallyMappedFieldWithEval/nullify/analysis.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testPartiallyMappedFieldWithEval/nullify/analysis.expected new file mode 100644 index 0000000000000..d41f33ebff73e --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testPartiallyMappedFieldWithEval/nullify/analysis.expected @@ -0,0 +1,5 @@ +Limit[1000[INTEGER],false,false] +\_Project[[@timestamp{f}#0, x{r}#1]] + \_Eval[[COALESCE(unmapped_message{r}#2,missing[KEYWORD]) AS x#1]] + \_Eval[[null[NULL] AS unmapped_message#2]] + \_EsRelation[sample_data,partial_mapping_sample_data][@timestamp{f}#0, client_ip{f}#3, event_duration{f}#4, message{f}#5] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testPartiallyMappedFieldWithEval/nullify/query.esql b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testPartiallyMappedFieldWithEval/nullify/query.esql new file mode 100644 index 0000000000000..b066c80c57f4d --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testPartiallyMappedFieldWithEval/nullify/query.esql @@ -0,0 +1,3 @@ +SET unmapped_fields="nullify"; FROM sample_data, partial_mapping_sample_data +| EVAL x = COALESCE(unmapped_message, "missing") +| KEEP @timestamp, x diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testPartiallyMappedFieldWithStats/load/analysis.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testPartiallyMappedFieldWithStats/load/analysis.expected new file mode 100644 index 0000000000000..30aecb7154ced --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testPartiallyMappedFieldWithStats/load/analysis.expected @@ -0,0 +1,3 @@ +Limit[1000[INTEGER],false,false] +\_Aggregate[[unmapped_message{f}#0],[COUNT(*[KEYWORD],true[BOOLEAN],PT0S[TIME_DURATION]) AS c#1, unmapped_message{f}#0]] + \_EsRelation[sample_data,partial_mapping_sample_data][@timestamp{f}#2, client_ip{f}#3, event_duration{f}#4, message{f}#5, unmapped_message{f}#0] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testPartiallyMappedFieldWithStats/load/query.esql b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testPartiallyMappedFieldWithStats/load/query.esql new file mode 100644 index 0000000000000..870af673da1a0 --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testPartiallyMappedFieldWithStats/load/query.esql @@ -0,0 +1,2 @@ +SET unmapped_fields="load"; FROM sample_data, partial_mapping_sample_data +| STATS c = COUNT(*) BY unmapped_message diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testPartiallyMappedFieldWithStats/nullify/analysis.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testPartiallyMappedFieldWithStats/nullify/analysis.expected new file mode 100644 index 0000000000000..e1f96c50471b1 --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testPartiallyMappedFieldWithStats/nullify/analysis.expected @@ -0,0 +1,4 @@ +Limit[1000[INTEGER],false,false] +\_Aggregate[[unmapped_message{r}#0],[COUNT(*[KEYWORD],true[BOOLEAN],PT0S[TIME_DURATION]) AS c#1, unmapped_message{r}#0]] + \_Eval[[null[NULL] AS unmapped_message#0]] + \_EsRelation[sample_data,partial_mapping_sample_data][@timestamp{f}#2, client_ip{f}#3, event_duration{f}#4, message{f}#5] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testPartiallyMappedFieldWithStats/nullify/query.esql b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testPartiallyMappedFieldWithStats/nullify/query.esql new file mode 100644 index 0000000000000..d44b1ad301021 --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testPartiallyMappedFieldWithStats/nullify/query.esql @@ -0,0 +1,2 @@ +SET unmapped_fields="nullify"; FROM sample_data, partial_mapping_sample_data +| STATS c = COUNT(*) BY unmapped_message From 7f692347ad4773add0167f8857d71ac45295973c Mon Sep 17 00:00:00 2001 From: Gal Lalouche Date: Wed, 4 Feb 2026 13:35:11 +0200 Subject: [PATCH 20/25] TEMP --- .../xpack/esql/analysis/AnalyzerUnmappedGoldenTests.java | 8 +++++--- .../load/analysis.expected | 4 ++-- .../testDifferentTypesAcrossIndices/load/query.esql | 2 +- .../nullify/analysis.expected | 5 +++-- .../testDifferentTypesAcrossIndices/nullify/query.esql | 2 +- .../testDifferentTypesWithCast/load/analysis.expected | 6 +++--- .../testDifferentTypesWithCast/load/query.esql | 2 +- .../testDifferentTypesWithCast/nullify/analysis.expected | 6 +++--- .../testDifferentTypesWithCast/nullify/query.esql | 2 +- .../load/analysis.expected | 6 +++--- .../testPartiallyMappedFieldWithEval/load/query.esql | 2 +- .../nullify/analysis.expected | 8 ++++---- .../testPartiallyMappedFieldWithEval/nullify/query.esql | 2 +- 13 files changed, 29 insertions(+), 26 deletions(-) diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/analysis/AnalyzerUnmappedGoldenTests.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/analysis/AnalyzerUnmappedGoldenTests.java index 1d480c6701019..089a16a868bef 100644 --- a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/analysis/AnalyzerUnmappedGoldenTests.java +++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/analysis/AnalyzerUnmappedGoldenTests.java @@ -356,6 +356,8 @@ public void testTimeSeriesRateUnmapped() throws Exception { """); } + // TODO add one for text + public void testTimeSeriesFirstOverTimeUnmapped() throws Exception { runTests(""" TS k8s @@ -381,14 +383,14 @@ public void testPartiallyMappedFieldWithEval() throws Exception { runTests(""" FROM sample_data, partial_mapping_sample_data | EVAL x = COALESCE(unmapped_message, "missing") - | KEEP @timestamp, x + | KEEP @timestamp, x, does_not_exist """); } public void testDifferentTypesAcrossIndices() throws Exception { runTests(""" FROM sample_data, sample_data_ts_long - | KEEP @timestamp, message + | KEEP @timestamp, message, does_not_exist """); } @@ -396,7 +398,7 @@ public void testDifferentTypesWithCast() throws Exception { runTests(""" FROM sample_data, sample_data_ts_long | EVAL ts = @timestamp::STRING - | KEEP ts, message + | KEEP ts, message, does_not_exist """); } diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testDifferentTypesAcrossIndices/load/analysis.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testDifferentTypesAcrossIndices/load/analysis.expected index 60246e2a52c6f..12f12d30d6904 100644 --- a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testDifferentTypesAcrossIndices/load/analysis.expected +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testDifferentTypesAcrossIndices/load/analysis.expected @@ -1,3 +1,3 @@ Limit[1000[INTEGER],false,false] -\_Project[[!@timestamp, message{f}#0]] - \_EsRelation[sample_data,sample_data_ts_long][!@timestamp, client_ip{f}#1, event_duration{f}#2, message{f}#0] \ No newline at end of file +\_Project[[!@timestamp, message{f}#0, does_not_exist{f}#1]] + \_EsRelation[sample_data,sample_data_ts_long][!@timestamp, client_ip{f}#2, event_duration{f}#3, message{f}#0, does_not_exist{f}#1] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testDifferentTypesAcrossIndices/load/query.esql b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testDifferentTypesAcrossIndices/load/query.esql index 36f26bbad39a7..f8a423e9c25b6 100644 --- a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testDifferentTypesAcrossIndices/load/query.esql +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testDifferentTypesAcrossIndices/load/query.esql @@ -1,2 +1,2 @@ SET unmapped_fields="load"; FROM sample_data, sample_data_ts_long -| KEEP @timestamp, message +| KEEP @timestamp, message, does_not_exist diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testDifferentTypesAcrossIndices/nullify/analysis.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testDifferentTypesAcrossIndices/nullify/analysis.expected index 60246e2a52c6f..6666da83f0b7b 100644 --- a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testDifferentTypesAcrossIndices/nullify/analysis.expected +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testDifferentTypesAcrossIndices/nullify/analysis.expected @@ -1,3 +1,4 @@ Limit[1000[INTEGER],false,false] -\_Project[[!@timestamp, message{f}#0]] - \_EsRelation[sample_data,sample_data_ts_long][!@timestamp, client_ip{f}#1, event_duration{f}#2, message{f}#0] \ No newline at end of file +\_Project[[!@timestamp, message{f}#0, does_not_exist{r}#1]] + \_Eval[[null[NULL] AS does_not_exist#1]] + \_EsRelation[sample_data,sample_data_ts_long][!@timestamp, client_ip{f}#2, event_duration{f}#3, message{f}#0] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testDifferentTypesAcrossIndices/nullify/query.esql b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testDifferentTypesAcrossIndices/nullify/query.esql index b469337a46ebc..4336bd5f39d8e 100644 --- a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testDifferentTypesAcrossIndices/nullify/query.esql +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testDifferentTypesAcrossIndices/nullify/query.esql @@ -1,2 +1,2 @@ SET unmapped_fields="nullify"; FROM sample_data, sample_data_ts_long -| KEEP @timestamp, message +| KEEP @timestamp, message, does_not_exist diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testDifferentTypesWithCast/load/analysis.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testDifferentTypesWithCast/load/analysis.expected index c13045a018215..837e284d3469d 100644 --- a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testDifferentTypesWithCast/load/analysis.expected +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testDifferentTypesWithCast/load/analysis.expected @@ -1,4 +1,4 @@ Limit[1000[INTEGER],false,false] -\_Project[[ts{r}#0, message{f}#1]] - \_Eval[[$$@timestamp$converted_to$keyword{f$}#2 AS ts#0]] - \_EsRelation[sample_data,sample_data_ts_long][!@timestamp, client_ip{f}#3, event_duration{f}#4, message{f}#1, $$@timestamp$converted_to$keyword{f$}#2] \ No newline at end of file +\_Project[[ts{r}#0, message{f}#1, does_not_exist{f}#2]] + \_Eval[[$$@timestamp$converted_to$keyword{f$}#3 AS ts#0]] + \_EsRelation[sample_data,sample_data_ts_long][!@timestamp, client_ip{f}#4, event_duration{f}#5, message{f}#1, $$@timestamp$converted_to$keyword{f$}#3, does_not_exist{f}#2] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testDifferentTypesWithCast/load/query.esql b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testDifferentTypesWithCast/load/query.esql index c739306c06b40..1ac50de7de6cd 100644 --- a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testDifferentTypesWithCast/load/query.esql +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testDifferentTypesWithCast/load/query.esql @@ -1,3 +1,3 @@ SET unmapped_fields="load"; FROM sample_data, sample_data_ts_long | EVAL ts = @timestamp::STRING -| KEEP ts, message +| KEEP ts, message, does_not_exist diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testDifferentTypesWithCast/nullify/analysis.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testDifferentTypesWithCast/nullify/analysis.expected index c13045a018215..07c96c69b56aa 100644 --- a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testDifferentTypesWithCast/nullify/analysis.expected +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testDifferentTypesWithCast/nullify/analysis.expected @@ -1,4 +1,4 @@ Limit[1000[INTEGER],false,false] -\_Project[[ts{r}#0, message{f}#1]] - \_Eval[[$$@timestamp$converted_to$keyword{f$}#2 AS ts#0]] - \_EsRelation[sample_data,sample_data_ts_long][!@timestamp, client_ip{f}#3, event_duration{f}#4, message{f}#1, $$@timestamp$converted_to$keyword{f$}#2] \ No newline at end of file +\_Project[[ts{r}#0, message{f}#1, does_not_exist{r}#2]] + \_Eval[[$$@timestamp$converted_to$keyword{f$}#3 AS ts#0, null[NULL] AS does_not_exist#2]] + \_EsRelation[sample_data,sample_data_ts_long][!@timestamp, client_ip{f}#4, event_duration{f}#5, message{f}#1, $$@timestamp$converted_to$keyword{f$}#3] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testDifferentTypesWithCast/nullify/query.esql b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testDifferentTypesWithCast/nullify/query.esql index 8a4145812c548..ab8c59e257e6d 100644 --- a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testDifferentTypesWithCast/nullify/query.esql +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testDifferentTypesWithCast/nullify/query.esql @@ -1,3 +1,3 @@ SET unmapped_fields="nullify"; FROM sample_data, sample_data_ts_long | EVAL ts = @timestamp::STRING -| KEEP ts, message +| KEEP ts, message, does_not_exist diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testPartiallyMappedFieldWithEval/load/analysis.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testPartiallyMappedFieldWithEval/load/analysis.expected index c5c5603a87da1..b34196e39e72e 100644 --- a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testPartiallyMappedFieldWithEval/load/analysis.expected +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testPartiallyMappedFieldWithEval/load/analysis.expected @@ -1,4 +1,4 @@ Limit[1000[INTEGER],false,false] -\_Project[[@timestamp{f}#0, x{r}#1]] - \_Eval[[COALESCE(unmapped_message{f}#2,missing[KEYWORD]) AS x#1]] - \_EsRelation[sample_data,partial_mapping_sample_data][@timestamp{f}#0, client_ip{f}#3, event_duration{f}#4, message{f}#5, unmapped_message{f}#2] \ No newline at end of file +\_Project[[@timestamp{f}#0, x{r}#1, does_not_exist{f}#2]] + \_Eval[[COALESCE(unmapped_message{f}#3,missing[KEYWORD]) AS x#1]] + \_EsRelation[sample_data,partial_mapping_sample_data][@timestamp{f}#0, client_ip{f}#4, event_duration{f}#5, message{f}#6, unmapped_message{f}#3, does_not_exist{f}#2] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testPartiallyMappedFieldWithEval/load/query.esql b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testPartiallyMappedFieldWithEval/load/query.esql index 3d56b92b85d47..578e1fcb86bb8 100644 --- a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testPartiallyMappedFieldWithEval/load/query.esql +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testPartiallyMappedFieldWithEval/load/query.esql @@ -1,3 +1,3 @@ SET unmapped_fields="load"; FROM sample_data, partial_mapping_sample_data | EVAL x = COALESCE(unmapped_message, "missing") -| KEEP @timestamp, x +| KEEP @timestamp, x, does_not_exist diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testPartiallyMappedFieldWithEval/nullify/analysis.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testPartiallyMappedFieldWithEval/nullify/analysis.expected index d41f33ebff73e..3423a5d39ac06 100644 --- a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testPartiallyMappedFieldWithEval/nullify/analysis.expected +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testPartiallyMappedFieldWithEval/nullify/analysis.expected @@ -1,5 +1,5 @@ Limit[1000[INTEGER],false,false] -\_Project[[@timestamp{f}#0, x{r}#1]] - \_Eval[[COALESCE(unmapped_message{r}#2,missing[KEYWORD]) AS x#1]] - \_Eval[[null[NULL] AS unmapped_message#2]] - \_EsRelation[sample_data,partial_mapping_sample_data][@timestamp{f}#0, client_ip{f}#3, event_duration{f}#4, message{f}#5] \ No newline at end of file +\_Project[[@timestamp{f}#0, x{r}#1, does_not_exist{r}#2]] + \_Eval[[COALESCE(unmapped_message{r}#3,missing[KEYWORD]) AS x#1]] + \_Eval[[null[NULL] AS unmapped_message#3, null[NULL] AS does_not_exist#2]] + \_EsRelation[sample_data,partial_mapping_sample_data][@timestamp{f}#0, client_ip{f}#4, event_duration{f}#5, message{f}#6] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testPartiallyMappedFieldWithEval/nullify/query.esql b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testPartiallyMappedFieldWithEval/nullify/query.esql index b066c80c57f4d..8a34446c7a5cc 100644 --- a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testPartiallyMappedFieldWithEval/nullify/query.esql +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testPartiallyMappedFieldWithEval/nullify/query.esql @@ -1,3 +1,3 @@ SET unmapped_fields="nullify"; FROM sample_data, partial_mapping_sample_data | EVAL x = COALESCE(unmapped_message, "missing") -| KEEP @timestamp, x +| KEEP @timestamp, x, does_not_exist From ac35237b9d554e0c12e6bc68cd8fcb33268fb52d Mon Sep 17 00:00:00 2001 From: Gal Lalouche Date: Wed, 4 Feb 2026 14:10:06 +0200 Subject: [PATCH 21/25] Push after potentially unmapped field hack --- .../xpack/esql/core/expression/Attribute.java | 2 +- .../xpack/esql/core/expression/FieldAttribute.java | 11 +++++++++++ .../xpack/esql/core/tree/NodeUtils.java | 1 + .../testCoalesce/load/analysis.expected | 4 ++-- .../testCoalesce/nullify/analysis.expected | 4 ++-- .../load/analysis.expected | 2 +- .../nullify/analysis.expected | 2 +- .../load/analysis.expected | 4 ++-- .../nullify/analysis.expected | 4 ++-- .../testDrop/load/analysis.expected | 2 +- .../testDrop/nullify/analysis.expected | 2 +- .../testDropAndMatchingStar/load/analysis.expected | 2 +- .../nullify/analysis.expected | 2 +- .../testEvalAfterKeepStar/load/analysis.expected | 2 +- .../testEvalAfterKeepStar/nullify/analysis.expected | 2 +- .../load/analysis.expected | 2 +- .../nullify/analysis.expected | 2 +- .../testEvalAndKeep/load/analysis.expected | 2 +- .../testEvalCast/load/analysis.expected | 2 +- .../testEvalCastInPlace/load/analysis.expected | 2 +- .../testFork/load/analysis.expected | 4 ++-- .../testFork/nullify/analysis.expected | 4 ++-- .../testForkWithEval/load/analysis.expected | 4 ++-- .../testForkWithEval/nullify/analysis.expected | 4 ++-- .../testForkWithStats/load/analysis.expected | 6 +++--- .../testForkWithStats/nullify/analysis.expected | 2 +- .../testInlineStats/load/analysis.expected | 2 +- .../testInlineStats/nullify/analysis.expected | 2 +- .../testKeep/load/analysis.expected | 2 +- .../testKeepAndMatchingStar/load/analysis.expected | 2 +- .../nullify/analysis.expected | 2 +- .../testKeepRepeated/load/analysis.expected | 2 +- .../testKeepThenEval/load/analysis.expected | 2 +- .../testLookupJoin/load/analysis.expected | 4 ++-- .../testLookupJoin/nullify/analysis.expected | 2 +- .../testLookupJoinWithFilter/load/analysis.expected | 4 ++-- .../nullify/analysis.expected | 4 ++-- .../testMvExpand/load/analysis.expected | 2 +- .../testPartiallyMappedField/load/analysis.expected | 2 +- .../nullify/analysis.expected | 2 +- .../load/analysis.expected | 4 ++-- .../nullify/analysis.expected | 2 +- .../load/analysis.expected | 2 +- .../testRename/load/analysis.expected | 2 +- .../testRename/nullify/analysis.expected | 2 +- .../testRenameEval/load/analysis.expected | 2 +- .../testRenameEval/nullify/analysis.expected | 2 +- .../testRenameRepeated/load/analysis.expected | 2 +- .../testRenameRepeated/nullify/analysis.expected | 2 +- .../testSort/load/analysis.expected | 2 +- .../testSortMultiple/load/analysis.expected | 2 +- .../testSortMultiple/nullify/analysis.expected | 2 +- .../testStatsBy/load/analysis.expected | 2 +- .../testStatsCount/load/analysis.expected | 2 +- .../testStatsMultiple/load/analysis.expected | 2 +- .../testStatsMultiple/nullify/analysis.expected | 2 +- .../load/analysis.expected | 2 +- .../testStatsSumBy/load/analysis.expected | 2 +- .../testStatsSumByComplex/load/analysis.expected | 2 +- .../testStatsSumByComplex/nullify/analysis.expected | 2 +- .../testStatsSumByMultiple/load/analysis.expected | 2 +- .../testStatsSumByMultiple/nullify/analysis.expected | 2 +- .../load/analysis.expected | 6 +++--- .../nullify/analysis.expected | 6 +++--- .../testSubqueryKeepUnmapped/load/analysis.expected | 6 +++--- .../nullify/analysis.expected | 6 +++--- .../testSubqueryWithStats/load/analysis.expected | 6 +++--- .../testSubqueryWithStats/nullify/analysis.expected | 4 ++-- .../load/analysis.expected | 2 +- .../nullify/analysis.expected | 2 +- .../load/analysis.expected | 2 +- .../nullify/analysis.expected | 2 +- .../load/analysis.expected | 2 +- .../nullify/analysis.expected | 2 +- .../nullify/analysis.expected | 2 +- .../bucket/local_physical_optimization.expected | 12 ++++++------ .../date_trunc/local_physical_optimization.expected | 12 ++++++------ .../round_to/local_physical_optimization.expected | 12 ++++++------ .../bucket/local_physical_optimization.expected | 4 ++-- .../date_trunc/local_physical_optimization.expected | 4 ++-- .../round_to/local_physical_optimization.expected | 4 ++-- .../bucket/local_physical_optimization.expected | 6 +++--- .../date_trunc/local_physical_optimization.expected | 6 +++--- .../round_to/local_physical_optimization.expected | 6 +++--- .../local_physical_optimization.expected | 2 +- .../local_physical_optimization.expected | 2 +- .../local_physical_optimization.expected | 2 +- .../local_physical_optimization.expected | 2 +- .../local_physical_optimization.expected | 2 +- .../local_physical_optimization.expected | 2 +- .../bucket/local_physical_optimization.expected | 2 +- .../date_trunc/local_physical_optimization.expected | 2 +- .../round_to/local_physical_optimization.expected | 2 +- .../date_trunc/local_physical_optimization.expected | 10 +++++----- .../round_to/local_physical_optimization.expected | 10 +++++----- .../local_physical_optimization.expected | 12 ++++++------ .../local_physical_optimization.expected | 4 ++-- ...reduce_physical_optimization_data_driver.expected | 4 ++-- .../local_reduce_planned_data_driver.expected | 6 +++--- .../local_reduce_planned_reduce_driver.expected | 8 ++++---- .../physical_optimization.expected | 10 +++++----- ...reduce_physical_optimization_data_driver.expected | 4 ++-- .../local_reduce_planned_data_driver.expected | 4 ++-- .../local_reduce_planned_reduce_driver.expected | 6 +++--- .../physical_optimization.expected | 6 +++--- ...reduce_physical_optimization_data_driver.expected | 4 ++-- .../local_reduce_planned_data_driver.expected | 4 ++-- .../local_reduce_planned_reduce_driver.expected | 6 +++--- .../physical_optimization.expected | 6 +++--- ...reduce_physical_optimization_data_driver.expected | 10 +++++----- .../local_reduce_planned_data_driver.expected | 10 +++++----- .../local_reduce_planned_reduce_driver.expected | 8 ++++---- .../physical_optimization.expected | 12 ++++++------ ...reduce_physical_optimization_data_driver.expected | 4 ++-- .../local_reduce_planned_data_driver.expected | 6 +++--- .../local_reduce_planned_reduce_driver.expected | 8 ++++---- .../physical_optimization.expected | 10 +++++----- ...reduce_physical_optimization_data_driver.expected | 4 ++-- .../local_reduce_planned_data_driver.expected | 6 +++--- .../local_reduce_planned_reduce_driver.expected | 8 ++++---- .../testMultipleTopN/physical_optimization.expected | 12 ++++++------ ...reduce_physical_optimization_data_driver.expected | 10 +++++----- ...duce_physical_optimization_reduce_driver.expected | 6 +++--- .../local_reduce_planned_data_driver.expected | 10 +++++----- .../local_reduce_planned_reduce_driver.expected | 6 +++--- .../physical_optimization.expected | 12 ++++++------ ...reduce_physical_optimization_data_driver.expected | 4 ++-- .../local_reduce_planned_data_driver.expected | 6 +++--- .../local_reduce_planned_reduce_driver.expected | 8 ++++---- .../physical_optimization.expected | 10 +++++----- ...reduce_physical_optimization_data_driver.expected | 4 ++-- .../local_reduce_planned_data_driver.expected | 6 +++--- .../local_reduce_planned_reduce_driver.expected | 8 ++++---- .../physical_optimization.expected | 10 +++++----- ...reduce_physical_optimization_data_driver.expected | 4 ++-- .../local_reduce_planned_data_driver.expected | 6 +++--- .../local_reduce_planned_reduce_driver.expected | 8 ++++---- .../testTopNThenStats/physical_optimization.expected | 10 +++++----- ...reduce_physical_optimization_data_driver.expected | 4 ++-- .../local_reduce_planned_data_driver.expected | 6 +++--- .../local_reduce_planned_reduce_driver.expected | 8 ++++---- .../physical_optimization.expected | 10 +++++----- 142 files changed, 331 insertions(+), 319 deletions(-) diff --git a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/core/expression/Attribute.java b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/core/expression/Attribute.java index 69233e86ef865..62cfd9786b0c7 100644 --- a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/core/expression/Attribute.java +++ b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/core/expression/Attribute.java @@ -221,7 +221,7 @@ public String toString() { @Override public String nodeString(NodeStringFormat format) { - return toString(); + return toString(format); } protected abstract String label(); diff --git a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/core/expression/FieldAttribute.java b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/core/expression/FieldAttribute.java index bd6377cfd109d..28dec3ad94a2a 100644 --- a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/core/expression/FieldAttribute.java +++ b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/core/expression/FieldAttribute.java @@ -271,4 +271,15 @@ public boolean isMetric() { public EsField field() { return field; } + + @Override + public String nodeString(NodeStringFormat format) { + return switch (format) { + // FIXME(gal, NOCOMMIT) unhack + case FULL -> Strings.format( + "%s{%s(%s)%s}#%s".formatted(qualifiedName(), label(), field.getWriteableName(), synthetic() ? "$" : "", id()) + ); + case LIMITED -> super.nodeString(format); + }; + } } diff --git a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/core/tree/NodeUtils.java b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/core/tree/NodeUtils.java index 6874b869ec872..ed453bedbacf6 100644 --- a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/core/tree/NodeUtils.java +++ b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/core/tree/NodeUtils.java @@ -62,6 +62,7 @@ public static String diffString(String left, String right) { public static String toString(Collection c, Node.NodeStringFormat format) { return switch (format) { case LIMITED -> limitedToString(c); + // FIXME(gal, NOCOMMIT) This need to pass format to c as well case FULL -> unlimitedToString(c); }; } diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testCoalesce/load/analysis.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testCoalesce/load/analysis.expected index d3111b5b4cda6..e3749cf60fe6d 100644 --- a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testCoalesce/load/analysis.expected +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testCoalesce/load/analysis.expected @@ -1,4 +1,4 @@ Limit[1000[INTEGER],false,false] -\_Project[[emp_no{f}#0, x{r}#1]] - \_Eval[[COALESCE(TOLONG(does_not_exist{f}#2),TOLONG(emp_no{f}#0),TOLONG(0[INTEGER])) AS x#1]] +\_Project[[emp_no{f(EsField)}#0, x{r}#1]] + \_Eval[[COALESCE(TOLONG(does_not_exist{f(PotentiallyUnmappedKeywordEsField)}#2),TOLONG(emp_no{f(EsField)}#0),TOLONG(0[INTEGER])) AS x#1]] \_EsRelation[employees][avg_worked_seconds{f}#3, birth_date{f}#4, emp_no{f}#0, first_name{f}#5, gender{f}#6, height{f}#7, height.float{f}#8, height.half_float{f}#9, height.scaled_float{f}#10, hire_date{f}#11, is_rehired{f}#12, job_positions{f}#13, languages{f}#14, languages.byte{f}#15, languages.long{f}#16, languages.short{f}#17, last_name{f}#18, salary{f}#19, salary_change{f}#20, salary_change.int{f}#21, salary_change.keyword{f}#22, salary_change.long{f}#23, still_hired{f}#24, does_not_exist{f}#2, x{f}#25] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testCoalesce/nullify/analysis.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testCoalesce/nullify/analysis.expected index 5cccb49a752cc..bcdfea953020a 100644 --- a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testCoalesce/nullify/analysis.expected +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testCoalesce/nullify/analysis.expected @@ -1,5 +1,5 @@ Limit[1000[INTEGER],false,false] -\_Project[[emp_no{f}#0, x{r}#1]] - \_Eval[[COALESCE(TOLONG(does_not_exist{r}#2),TOLONG(emp_no{f}#0),TOLONG(0[INTEGER])) AS x#1]] +\_Project[[emp_no{f(EsField)}#0, x{r}#1]] + \_Eval[[COALESCE(TOLONG(does_not_exist{r}#2),TOLONG(emp_no{f(EsField)}#0),TOLONG(0[INTEGER])) AS x#1]] \_Eval[[null[NULL] AS does_not_exist#2, null[NULL] AS x#3]] \_EsRelation[employees][avg_worked_seconds{f}#4, birth_date{f}#5, emp_no{f}#0, first_name{f}#6, gender{f}#7, height{f}#8, height.float{f}#9, height.half_float{f}#10, height.scaled_float{f}#11, hire_date{f}#12, is_rehired{f}#13, job_positions{f}#14, languages{f}#15, languages.byte{f}#16, languages.long{f}#17, languages.short{f}#18, last_name{f}#19, salary{f}#20, salary_change{f}#21, salary_change.int{f}#22, salary_change.keyword{f}#23, salary_change.long{f}#24, still_hired{f}#25] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testDifferentTypesAcrossIndices/load/analysis.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testDifferentTypesAcrossIndices/load/analysis.expected index 12f12d30d6904..fa51740222109 100644 --- a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testDifferentTypesAcrossIndices/load/analysis.expected +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testDifferentTypesAcrossIndices/load/analysis.expected @@ -1,3 +1,3 @@ Limit[1000[INTEGER],false,false] -\_Project[[!@timestamp, message{f}#0, does_not_exist{f}#1]] +\_Project[[!@timestamp, message{f(KeywordEsField)}#0, does_not_exist{f(PotentiallyUnmappedKeywordEsField)}#1]] \_EsRelation[sample_data,sample_data_ts_long][!@timestamp, client_ip{f}#2, event_duration{f}#3, message{f}#0, does_not_exist{f}#1] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testDifferentTypesAcrossIndices/nullify/analysis.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testDifferentTypesAcrossIndices/nullify/analysis.expected index 6666da83f0b7b..b20e372050ebe 100644 --- a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testDifferentTypesAcrossIndices/nullify/analysis.expected +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testDifferentTypesAcrossIndices/nullify/analysis.expected @@ -1,4 +1,4 @@ Limit[1000[INTEGER],false,false] -\_Project[[!@timestamp, message{f}#0, does_not_exist{r}#1]] +\_Project[[!@timestamp, message{f(KeywordEsField)}#0, does_not_exist{r}#1]] \_Eval[[null[NULL] AS does_not_exist#1]] \_EsRelation[sample_data,sample_data_ts_long][!@timestamp, client_ip{f}#2, event_duration{f}#3, message{f}#0] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testDifferentTypesWithCast/load/analysis.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testDifferentTypesWithCast/load/analysis.expected index 837e284d3469d..4e22cfb0e1b0c 100644 --- a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testDifferentTypesWithCast/load/analysis.expected +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testDifferentTypesWithCast/load/analysis.expected @@ -1,4 +1,4 @@ Limit[1000[INTEGER],false,false] -\_Project[[ts{r}#0, message{f}#1, does_not_exist{f}#2]] - \_Eval[[$$@timestamp$converted_to$keyword{f$}#3 AS ts#0]] +\_Project[[ts{r}#0, message{f(KeywordEsField)}#1, does_not_exist{f(PotentiallyUnmappedKeywordEsField)}#2]] + \_Eval[[$$@timestamp$converted_to$keyword{f(MultiTypeEsField)$}#3 AS ts#0]] \_EsRelation[sample_data,sample_data_ts_long][!@timestamp, client_ip{f}#4, event_duration{f}#5, message{f}#1, $$@timestamp$converted_to$keyword{f$}#3, does_not_exist{f}#2] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testDifferentTypesWithCast/nullify/analysis.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testDifferentTypesWithCast/nullify/analysis.expected index 07c96c69b56aa..f280fa143e76e 100644 --- a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testDifferentTypesWithCast/nullify/analysis.expected +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testDifferentTypesWithCast/nullify/analysis.expected @@ -1,4 +1,4 @@ Limit[1000[INTEGER],false,false] -\_Project[[ts{r}#0, message{f}#1, does_not_exist{r}#2]] - \_Eval[[$$@timestamp$converted_to$keyword{f$}#3 AS ts#0, null[NULL] AS does_not_exist#2]] +\_Project[[ts{r}#0, message{f(KeywordEsField)}#1, does_not_exist{r}#2]] + \_Eval[[$$@timestamp$converted_to$keyword{f(MultiTypeEsField)$}#3 AS ts#0, null[NULL] AS does_not_exist#2]] \_EsRelation[sample_data,sample_data_ts_long][!@timestamp, client_ip{f}#4, event_duration{f}#5, message{f}#1, $$@timestamp$converted_to$keyword{f$}#3] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testDrop/load/analysis.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testDrop/load/analysis.expected index f5ab73414c471..acd024f56f58a 100644 --- a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testDrop/load/analysis.expected +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testDrop/load/analysis.expected @@ -1,3 +1,3 @@ Limit[1000[INTEGER],false,false] -\_Project[[avg_worked_seconds{f}#0, birth_date{f}#1, first_name{f}#2, gender{f}#3, height{f}#4, height.float{f}#5, height.half_float{f}#6, height.scaled_float{f}#7, hire_date{f}#8, is_rehired{f}#9, job_positions{f}#10, languages{f}#11, languages.byte{f}#12, languages.long{f}#13, languages.short{f}#14, last_name{f}#15, salary{f}#16, salary_change{f}#17, salary_change.int{f}#18, salary_change.keyword{f}#19, salary_change.long{f}#20, still_hired{f}#21]] +\_Project[[avg_worked_seconds{f(EsField)}#0, birth_date{f(DateEsField)}#1, first_name{f(KeywordEsField)}#2, gender{f(KeywordEsField)}#3, height{f(EsField)}#4, height.float{f(EsField)}#5, height.half_float{f(EsField)}#6, height.scaled_float{f(EsField)}#7, hire_date{f(DateEsField)}#8, is_rehired{f(EsField)}#9, job_positions{f(KeywordEsField)}#10, languages{f(EsField)}#11, languages.byte{f(EsField)}#12, languages.long{f(EsField)}#13, languages.short{f(EsField)}#14, last_name{f(KeywordEsField)}#15, salary{f(EsField)}#16, salary_change{f(EsField)}#17, salary_change.int{f(EsField)}#18, salary_change.keyword{f(KeywordEsField)}#19, salary_change.long{f(EsField)}#20, still_hired{f(EsField)}#21]] \_EsRelation[employees][avg_worked_seconds{f}#0, birth_date{f}#1, emp_no{f}#22, first_name{f}#2, gender{f}#3, height{f}#4, height.float{f}#5, height.half_float{f}#6, height.scaled_float{f}#7, hire_date{f}#8, is_rehired{f}#9, job_positions{f}#10, languages{f}#11, languages.byte{f}#12, languages.long{f}#13, languages.short{f}#14, last_name{f}#15, salary{f}#16, salary_change{f}#17, salary_change.int{f}#18, salary_change.keyword{f}#19, salary_change.long{f}#20, still_hired{f}#21, does_not_exist_field{f}#23] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testDrop/nullify/analysis.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testDrop/nullify/analysis.expected index 09d5818b5d458..9b31329838788 100644 --- a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testDrop/nullify/analysis.expected +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testDrop/nullify/analysis.expected @@ -1,4 +1,4 @@ Limit[1000[INTEGER],false,false] -\_Project[[avg_worked_seconds{f}#0, birth_date{f}#1, first_name{f}#2, gender{f}#3, height{f}#4, height.float{f}#5, height.half_float{f}#6, height.scaled_float{f}#7, hire_date{f}#8, is_rehired{f}#9, job_positions{f}#10, languages{f}#11, languages.byte{f}#12, languages.long{f}#13, languages.short{f}#14, last_name{f}#15, salary{f}#16, salary_change{f}#17, salary_change.int{f}#18, salary_change.keyword{f}#19, salary_change.long{f}#20, still_hired{f}#21]] +\_Project[[avg_worked_seconds{f(EsField)}#0, birth_date{f(DateEsField)}#1, first_name{f(KeywordEsField)}#2, gender{f(KeywordEsField)}#3, height{f(EsField)}#4, height.float{f(EsField)}#5, height.half_float{f(EsField)}#6, height.scaled_float{f(EsField)}#7, hire_date{f(DateEsField)}#8, is_rehired{f(EsField)}#9, job_positions{f(KeywordEsField)}#10, languages{f(EsField)}#11, languages.byte{f(EsField)}#12, languages.long{f(EsField)}#13, languages.short{f(EsField)}#14, last_name{f(KeywordEsField)}#15, salary{f(EsField)}#16, salary_change{f(EsField)}#17, salary_change.int{f(EsField)}#18, salary_change.keyword{f(KeywordEsField)}#19, salary_change.long{f(EsField)}#20, still_hired{f(EsField)}#21]] \_Eval[[null[NULL] AS does_not_exist_field#22]] \_EsRelation[employees][avg_worked_seconds{f}#0, birth_date{f}#1, emp_no{f}#23, first_name{f}#2, gender{f}#3, height{f}#4, height.float{f}#5, height.half_float{f}#6, height.scaled_float{f}#7, hire_date{f}#8, is_rehired{f}#9, job_positions{f}#10, languages{f}#11, languages.byte{f}#12, languages.long{f}#13, languages.short{f}#14, last_name{f}#15, salary{f}#16, salary_change{f}#17, salary_change.int{f}#18, salary_change.keyword{f}#19, salary_change.long{f}#20, still_hired{f}#21] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testDropAndMatchingStar/load/analysis.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testDropAndMatchingStar/load/analysis.expected index f5ab73414c471..acd024f56f58a 100644 --- a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testDropAndMatchingStar/load/analysis.expected +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testDropAndMatchingStar/load/analysis.expected @@ -1,3 +1,3 @@ Limit[1000[INTEGER],false,false] -\_Project[[avg_worked_seconds{f}#0, birth_date{f}#1, first_name{f}#2, gender{f}#3, height{f}#4, height.float{f}#5, height.half_float{f}#6, height.scaled_float{f}#7, hire_date{f}#8, is_rehired{f}#9, job_positions{f}#10, languages{f}#11, languages.byte{f}#12, languages.long{f}#13, languages.short{f}#14, last_name{f}#15, salary{f}#16, salary_change{f}#17, salary_change.int{f}#18, salary_change.keyword{f}#19, salary_change.long{f}#20, still_hired{f}#21]] +\_Project[[avg_worked_seconds{f(EsField)}#0, birth_date{f(DateEsField)}#1, first_name{f(KeywordEsField)}#2, gender{f(KeywordEsField)}#3, height{f(EsField)}#4, height.float{f(EsField)}#5, height.half_float{f(EsField)}#6, height.scaled_float{f(EsField)}#7, hire_date{f(DateEsField)}#8, is_rehired{f(EsField)}#9, job_positions{f(KeywordEsField)}#10, languages{f(EsField)}#11, languages.byte{f(EsField)}#12, languages.long{f(EsField)}#13, languages.short{f(EsField)}#14, last_name{f(KeywordEsField)}#15, salary{f(EsField)}#16, salary_change{f(EsField)}#17, salary_change.int{f(EsField)}#18, salary_change.keyword{f(KeywordEsField)}#19, salary_change.long{f(EsField)}#20, still_hired{f(EsField)}#21]] \_EsRelation[employees][avg_worked_seconds{f}#0, birth_date{f}#1, emp_no{f}#22, first_name{f}#2, gender{f}#3, height{f}#4, height.float{f}#5, height.half_float{f}#6, height.scaled_float{f}#7, hire_date{f}#8, is_rehired{f}#9, job_positions{f}#10, languages{f}#11, languages.byte{f}#12, languages.long{f}#13, languages.short{f}#14, last_name{f}#15, salary{f}#16, salary_change{f}#17, salary_change.int{f}#18, salary_change.keyword{f}#19, salary_change.long{f}#20, still_hired{f}#21, does_not_exist_field{f}#23] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testDropAndMatchingStar/nullify/analysis.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testDropAndMatchingStar/nullify/analysis.expected index 09d5818b5d458..9b31329838788 100644 --- a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testDropAndMatchingStar/nullify/analysis.expected +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testDropAndMatchingStar/nullify/analysis.expected @@ -1,4 +1,4 @@ Limit[1000[INTEGER],false,false] -\_Project[[avg_worked_seconds{f}#0, birth_date{f}#1, first_name{f}#2, gender{f}#3, height{f}#4, height.float{f}#5, height.half_float{f}#6, height.scaled_float{f}#7, hire_date{f}#8, is_rehired{f}#9, job_positions{f}#10, languages{f}#11, languages.byte{f}#12, languages.long{f}#13, languages.short{f}#14, last_name{f}#15, salary{f}#16, salary_change{f}#17, salary_change.int{f}#18, salary_change.keyword{f}#19, salary_change.long{f}#20, still_hired{f}#21]] +\_Project[[avg_worked_seconds{f(EsField)}#0, birth_date{f(DateEsField)}#1, first_name{f(KeywordEsField)}#2, gender{f(KeywordEsField)}#3, height{f(EsField)}#4, height.float{f(EsField)}#5, height.half_float{f(EsField)}#6, height.scaled_float{f(EsField)}#7, hire_date{f(DateEsField)}#8, is_rehired{f(EsField)}#9, job_positions{f(KeywordEsField)}#10, languages{f(EsField)}#11, languages.byte{f(EsField)}#12, languages.long{f(EsField)}#13, languages.short{f(EsField)}#14, last_name{f(KeywordEsField)}#15, salary{f(EsField)}#16, salary_change{f(EsField)}#17, salary_change.int{f(EsField)}#18, salary_change.keyword{f(KeywordEsField)}#19, salary_change.long{f(EsField)}#20, still_hired{f(EsField)}#21]] \_Eval[[null[NULL] AS does_not_exist_field#22]] \_EsRelation[employees][avg_worked_seconds{f}#0, birth_date{f}#1, emp_no{f}#23, first_name{f}#2, gender{f}#3, height{f}#4, height.float{f}#5, height.half_float{f}#6, height.scaled_float{f}#7, hire_date{f}#8, is_rehired{f}#9, job_positions{f}#10, languages{f}#11, languages.byte{f}#12, languages.long{f}#13, languages.short{f}#14, last_name{f}#15, salary{f}#16, salary_change{f}#17, salary_change.int{f}#18, salary_change.keyword{f}#19, salary_change.long{f}#20, still_hired{f}#21] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testEvalAfterKeepStar/load/analysis.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testEvalAfterKeepStar/load/analysis.expected index fffeff38bda8f..8f5d075d36aaf 100644 --- a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testEvalAfterKeepStar/load/analysis.expected +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testEvalAfterKeepStar/load/analysis.expected @@ -1,5 +1,5 @@ Limit[1000[INTEGER],false,false] \_Eval[[TODOUBLE(does_not_exist_field{f}#0) + 2[INTEGER] AS y#1]] \_Eval[[emp_no{f}#2 + 1[INTEGER] AS x#3]] - \_Project[[avg_worked_seconds{f}#4, birth_date{f}#5, emp_no{f}#2, first_name{f}#6, gender{f}#7, height{f}#8, height.float{f}#9, height.half_float{f}#10, height.scaled_float{f}#11, hire_date{f}#12, is_rehired{f}#13, job_positions{f}#14, languages{f}#15, languages.byte{f}#16, languages.long{f}#17, languages.short{f}#18, last_name{f}#19, salary{f}#20, salary_change{f}#21, salary_change.int{f}#22, salary_change.keyword{f}#23, salary_change.long{f}#24, still_hired{f}#25, does_not_exist_field{f}#0]] + \_Project[[avg_worked_seconds{f(EsField)}#4, birth_date{f(DateEsField)}#5, emp_no{f(EsField)}#2, first_name{f(KeywordEsField)}#6, gender{f(KeywordEsField)}#7, height{f(EsField)}#8, height.float{f(EsField)}#9, height.half_float{f(EsField)}#10, height.scaled_float{f(EsField)}#11, hire_date{f(DateEsField)}#12, is_rehired{f(EsField)}#13, job_positions{f(KeywordEsField)}#14, languages{f(EsField)}#15, languages.byte{f(EsField)}#16, languages.long{f(EsField)}#17, languages.short{f(EsField)}#18, last_name{f(KeywordEsField)}#19, salary{f(EsField)}#20, salary_change{f(EsField)}#21, salary_change.int{f(EsField)}#22, salary_change.keyword{f(KeywordEsField)}#23, salary_change.long{f(EsField)}#24, still_hired{f(EsField)}#25, does_not_exist_field{f(PotentiallyUnmappedKeywordEsField)}#0]] \_EsRelation[employees][avg_worked_seconds{f}#4, birth_date{f}#5, emp_no{f}#2, first_name{f}#6, gender{f}#7, height{f}#8, height.float{f}#9, height.half_float{f}#10, height.scaled_float{f}#11, hire_date{f}#12, is_rehired{f}#13, job_positions{f}#14, languages{f}#15, languages.byte{f}#16, languages.long{f}#17, languages.short{f}#18, last_name{f}#19, salary{f}#20, salary_change{f}#21, salary_change.int{f}#22, salary_change.keyword{f}#23, salary_change.long{f}#24, still_hired{f}#25, does_not_exist_field{f}#0] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testEvalAfterKeepStar/nullify/analysis.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testEvalAfterKeepStar/nullify/analysis.expected index 8a7ed2a845200..2b90aac6121b2 100644 --- a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testEvalAfterKeepStar/nullify/analysis.expected +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testEvalAfterKeepStar/nullify/analysis.expected @@ -1,6 +1,6 @@ Limit[1000[INTEGER],false,false] \_Eval[[TODOUBLE(does_not_exist_field{r}#0) + 2[INTEGER] AS y#1]] \_Eval[[emp_no{f}#2 + 1[INTEGER] AS x#3]] - \_Project[[avg_worked_seconds{f}#4, birth_date{f}#5, emp_no{f}#2, first_name{f}#6, gender{f}#7, height{f}#8, height.float{f}#9, height.half_float{f}#10, height.scaled_float{f}#11, hire_date{f}#12, is_rehired{f}#13, job_positions{f}#14, languages{f}#15, languages.byte{f}#16, languages.long{f}#17, languages.short{f}#18, last_name{f}#19, salary{f}#20, salary_change{f}#21, salary_change.int{f}#22, salary_change.keyword{f}#23, salary_change.long{f}#24, still_hired{f}#25, does_not_exist_field{r}#0]] + \_Project[[avg_worked_seconds{f(EsField)}#4, birth_date{f(DateEsField)}#5, emp_no{f(EsField)}#2, first_name{f(KeywordEsField)}#6, gender{f(KeywordEsField)}#7, height{f(EsField)}#8, height.float{f(EsField)}#9, height.half_float{f(EsField)}#10, height.scaled_float{f(EsField)}#11, hire_date{f(DateEsField)}#12, is_rehired{f(EsField)}#13, job_positions{f(KeywordEsField)}#14, languages{f(EsField)}#15, languages.byte{f(EsField)}#16, languages.long{f(EsField)}#17, languages.short{f(EsField)}#18, last_name{f(KeywordEsField)}#19, salary{f(EsField)}#20, salary_change{f(EsField)}#21, salary_change.int{f(EsField)}#22, salary_change.keyword{f(KeywordEsField)}#23, salary_change.long{f(EsField)}#24, still_hired{f(EsField)}#25, does_not_exist_field{r}#0]] \_Eval[[null[NULL] AS does_not_exist_field#0]] \_EsRelation[employees][avg_worked_seconds{f}#4, birth_date{f}#5, emp_no{f}#2, first_name{f}#6, gender{f}#7, height{f}#8, height.float{f}#9, height.half_float{f}#10, height.scaled_float{f}#11, hire_date{f}#12, is_rehired{f}#13, job_positions{f}#14, languages{f}#15, languages.byte{f}#16, languages.long{f}#17, languages.short{f}#18, last_name{f}#19, salary{f}#20, salary_change{f}#21, salary_change.int{f}#22, salary_change.keyword{f}#23, salary_change.long{f}#24, still_hired{f}#25] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testEvalAfterMatchingKeepWithWildcard/load/analysis.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testEvalAfterMatchingKeepWithWildcard/load/analysis.expected index 985d0ddb1a1f7..14e653fae9924 100644 --- a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testEvalAfterMatchingKeepWithWildcard/load/analysis.expected +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testEvalAfterMatchingKeepWithWildcard/load/analysis.expected @@ -1,5 +1,5 @@ Limit[1000[INTEGER],false,false] \_Eval[[TODOUBLE(emp_does_not_exist_field{f}#0) + 2[INTEGER] AS y#1]] \_Eval[[emp_no{f}#2 + 1[INTEGER] AS x#3]] - \_Project[[emp_no{f}#2, avg_worked_seconds{f}#4, birth_date{f}#5, first_name{f}#6, gender{f}#7, height{f}#8, height.float{f}#9, height.half_float{f}#10, height.scaled_float{f}#11, hire_date{f}#12, is_rehired{f}#13, job_positions{f}#14, languages{f}#15, languages.byte{f}#16, languages.long{f}#17, languages.short{f}#18, last_name{f}#19, salary{f}#20, salary_change{f}#21, salary_change.int{f}#22, salary_change.keyword{f}#23, salary_change.long{f}#24, still_hired{f}#25, emp_does_not_exist_field{f}#0]] + \_Project[[emp_no{f(EsField)}#2, avg_worked_seconds{f(EsField)}#4, birth_date{f(DateEsField)}#5, first_name{f(KeywordEsField)}#6, gender{f(KeywordEsField)}#7, height{f(EsField)}#8, height.float{f(EsField)}#9, height.half_float{f(EsField)}#10, height.scaled_float{f(EsField)}#11, hire_date{f(DateEsField)}#12, is_rehired{f(EsField)}#13, job_positions{f(KeywordEsField)}#14, languages{f(EsField)}#15, languages.byte{f(EsField)}#16, languages.long{f(EsField)}#17, languages.short{f(EsField)}#18, last_name{f(KeywordEsField)}#19, salary{f(EsField)}#20, salary_change{f(EsField)}#21, salary_change.int{f(EsField)}#22, salary_change.keyword{f(KeywordEsField)}#23, salary_change.long{f(EsField)}#24, still_hired{f(EsField)}#25, emp_does_not_exist_field{f(PotentiallyUnmappedKeywordEsField)}#0]] \_EsRelation[employees][avg_worked_seconds{f}#4, birth_date{f}#5, emp_no{f}#2, first_name{f}#6, gender{f}#7, height{f}#8, height.float{f}#9, height.half_float{f}#10, height.scaled_float{f}#11, hire_date{f}#12, is_rehired{f}#13, job_positions{f}#14, languages{f}#15, languages.byte{f}#16, languages.long{f}#17, languages.short{f}#18, last_name{f}#19, salary{f}#20, salary_change{f}#21, salary_change.int{f}#22, salary_change.keyword{f}#23, salary_change.long{f}#24, still_hired{f}#25, emp_does_not_exist_field{f}#0] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testEvalAfterMatchingKeepWithWildcard/nullify/analysis.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testEvalAfterMatchingKeepWithWildcard/nullify/analysis.expected index c85c64472a028..87cf671c0534f 100644 --- a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testEvalAfterMatchingKeepWithWildcard/nullify/analysis.expected +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testEvalAfterMatchingKeepWithWildcard/nullify/analysis.expected @@ -1,6 +1,6 @@ Limit[1000[INTEGER],false,false] \_Eval[[TODOUBLE(emp_does_not_exist_field{r}#0) + 2[INTEGER] AS y#1]] \_Eval[[emp_no{f}#2 + 1[INTEGER] AS x#3]] - \_Project[[emp_no{f}#2, avg_worked_seconds{f}#4, birth_date{f}#5, first_name{f}#6, gender{f}#7, height{f}#8, height.float{f}#9, height.half_float{f}#10, height.scaled_float{f}#11, hire_date{f}#12, is_rehired{f}#13, job_positions{f}#14, languages{f}#15, languages.byte{f}#16, languages.long{f}#17, languages.short{f}#18, last_name{f}#19, salary{f}#20, salary_change{f}#21, salary_change.int{f}#22, salary_change.keyword{f}#23, salary_change.long{f}#24, still_hired{f}#25, emp_does_not_exist_field{r}#0]] + \_Project[[emp_no{f(EsField)}#2, avg_worked_seconds{f(EsField)}#4, birth_date{f(DateEsField)}#5, first_name{f(KeywordEsField)}#6, gender{f(KeywordEsField)}#7, height{f(EsField)}#8, height.float{f(EsField)}#9, height.half_float{f(EsField)}#10, height.scaled_float{f(EsField)}#11, hire_date{f(DateEsField)}#12, is_rehired{f(EsField)}#13, job_positions{f(KeywordEsField)}#14, languages{f(EsField)}#15, languages.byte{f(EsField)}#16, languages.long{f(EsField)}#17, languages.short{f(EsField)}#18, last_name{f(KeywordEsField)}#19, salary{f(EsField)}#20, salary_change{f(EsField)}#21, salary_change.int{f(EsField)}#22, salary_change.keyword{f(KeywordEsField)}#23, salary_change.long{f(EsField)}#24, still_hired{f(EsField)}#25, emp_does_not_exist_field{r}#0]] \_Eval[[null[NULL] AS emp_does_not_exist_field#0]] \_EsRelation[employees][avg_worked_seconds{f}#4, birth_date{f}#5, emp_no{f}#2, first_name{f}#6, gender{f}#7, height{f}#8, height.float{f}#9, height.half_float{f}#10, height.scaled_float{f}#11, hire_date{f}#12, is_rehired{f}#13, job_positions{f}#14, languages{f}#15, languages.byte{f}#16, languages.long{f}#17, languages.short{f}#18, last_name{f}#19, salary{f}#20, salary_change{f}#21, salary_change.int{f}#22, salary_change.keyword{f}#23, salary_change.long{f}#24, still_hired{f}#25] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testEvalAndKeep/load/analysis.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testEvalAndKeep/load/analysis.expected index 5577ec2723da6..9639c04a04474 100644 --- a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testEvalAndKeep/load/analysis.expected +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testEvalAndKeep/load/analysis.expected @@ -1,4 +1,4 @@ Limit[1000[INTEGER],false,false] -\_Project[[does_not_exist_field1{f}#0, does_not_exist_field2{f}#1]] +\_Project[[does_not_exist_field1{f(PotentiallyUnmappedKeywordEsField)}#0, does_not_exist_field2{f(PotentiallyUnmappedKeywordEsField)}#1]] \_Eval[[TOINTEGER(does_not_exist_field1{f}#0) + 42[INTEGER] AS x#2]] \_EsRelation[employees][avg_worked_seconds{f}#3, birth_date{f}#4, emp_no{f}#5, first_name{f}#6, gender{f}#7, height{f}#8, height.float{f}#9, height.half_float{f}#10, height.scaled_float{f}#11, hire_date{f}#12, is_rehired{f}#13, job_positions{f}#14, languages{f}#15, languages.byte{f}#16, languages.long{f}#17, languages.short{f}#18, last_name{f}#19, salary{f}#20, salary_change{f}#21, salary_change.int{f}#22, salary_change.keyword{f}#23, salary_change.long{f}#24, still_hired{f}#25, does_not_exist_field1{f}#0, does_not_exist_field2{f}#1] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testEvalCast/load/analysis.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testEvalCast/load/analysis.expected index 11402fc799020..93fe00d388c1d 100644 --- a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testEvalCast/load/analysis.expected +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testEvalCast/load/analysis.expected @@ -1,3 +1,3 @@ Limit[1000[INTEGER],false,false] -\_Eval[[TOLONG(does_not_exist_field{f}#0) AS x#1]] +\_Eval[[TOLONG(does_not_exist_field{f(PotentiallyUnmappedKeywordEsField)}#0) AS x#1]] \_EsRelation[employees][avg_worked_seconds{f}#2, birth_date{f}#3, emp_no{f}#4, first_name{f}#5, gender{f}#6, height{f}#7, height.float{f}#8, height.half_float{f}#9, height.scaled_float{f}#10, hire_date{f}#11, is_rehired{f}#12, job_positions{f}#13, languages{f}#14, languages.byte{f}#15, languages.long{f}#16, languages.short{f}#17, last_name{f}#18, salary{f}#19, salary_change{f}#20, salary_change.int{f}#21, salary_change.keyword{f}#22, salary_change.long{f}#23, still_hired{f}#24, does_not_exist_field{f}#0] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testEvalCastInPlace/load/analysis.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testEvalCastInPlace/load/analysis.expected index 81f2f5801c839..1057b571c78de 100644 --- a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testEvalCastInPlace/load/analysis.expected +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testEvalCastInPlace/load/analysis.expected @@ -1,3 +1,3 @@ Limit[1000[INTEGER],false,false] -\_Eval[[TOLONG(does_not_exist_field{f}#0) AS does_not_exist_field::LONG#1]] +\_Eval[[TOLONG(does_not_exist_field{f(PotentiallyUnmappedKeywordEsField)}#0) AS does_not_exist_field::LONG#1]] \_EsRelation[employees][avg_worked_seconds{f}#2, birth_date{f}#3, emp_no{f}#4, first_name{f}#5, gender{f}#6, height{f}#7, height.float{f}#8, height.half_float{f}#9, height.scaled_float{f}#10, hire_date{f}#11, is_rehired{f}#12, job_positions{f}#13, languages{f}#14, languages.byte{f}#15, languages.long{f}#16, languages.short{f}#17, last_name{f}#18, salary{f}#19, salary_change{f}#20, salary_change.int{f}#21, salary_change.keyword{f}#22, salary_change.long{f}#23, still_hired{f}#24, does_not_exist_field{f}#0] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testFork/load/analysis.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testFork/load/analysis.expected index 8c02caed8fa2b..1ea65e9515a9e 100644 --- a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testFork/load/analysis.expected +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testFork/load/analysis.expected @@ -1,12 +1,12 @@ Limit[1000[INTEGER],false,false] \_Fork[[avg_worked_seconds{r}#0, birth_date{r}#1, emp_no{r}#2, first_name{r}#3, gender{r}#4, height{r}#5, height.float{r}#6, height.half_float{r}#7, height.scaled_float{r}#8, hire_date{r}#9, is_rehired{r}#10, job_positions{r}#11, languages{r}#12, languages.byte{r}#13, languages.long{r}#14, languages.short{r}#15, last_name{r}#16, salary{r}#17, salary_change{r}#18, salary_change.int{r}#19, salary_change.keyword{r}#20, salary_change.long{r}#21, still_hired{r}#22, does_not_exist{r}#23, _fork{r}#24]] |_Limit[1000[INTEGER],false,false] - | \_Project[[avg_worked_seconds{f}#25, birth_date{f}#26, emp_no{f}#27, first_name{f}#28, gender{f}#29, height{f}#30, height.float{f}#31, height.half_float{f}#32, height.scaled_float{f}#33, hire_date{f}#34, is_rehired{f}#35, job_positions{f}#36, languages{f}#37, languages.byte{f}#38, languages.long{f}#39, languages.short{f}#40, last_name{f}#41, salary{f}#42, salary_change{f}#43, salary_change.int{f}#44, salary_change.keyword{f}#45, salary_change.long{f}#46, still_hired{f}#47, does_not_exist{f}#48, _fork{r}#49]] + | \_Project[[avg_worked_seconds{f(EsField)}#25, birth_date{f(DateEsField)}#26, emp_no{f(EsField)}#27, first_name{f(KeywordEsField)}#28, gender{f(KeywordEsField)}#29, height{f(EsField)}#30, height.float{f(EsField)}#31, height.half_float{f(EsField)}#32, height.scaled_float{f(EsField)}#33, hire_date{f(DateEsField)}#34, is_rehired{f(EsField)}#35, job_positions{f(KeywordEsField)}#36, languages{f(EsField)}#37, languages.byte{f(EsField)}#38, languages.long{f(EsField)}#39, languages.short{f(EsField)}#40, last_name{f(KeywordEsField)}#41, salary{f(EsField)}#42, salary_change{f(EsField)}#43, salary_change.int{f(EsField)}#44, salary_change.keyword{f(KeywordEsField)}#45, salary_change.long{f(EsField)}#46, still_hired{f(EsField)}#47, does_not_exist{f(PotentiallyUnmappedKeywordEsField)}#48, _fork{r}#49]] | \_Eval[[fork1[KEYWORD] AS _fork#49]] | \_Filter[TOLONG(does_not_exist{f}#48) > 0[INTEGER]] | \_EsRelation[employees][avg_worked_seconds{f}#25, birth_date{f}#26, emp_no{f}#27, first_name{f}#28, gender{f}#29, height{f}#30, height.float{f}#31, height.half_float{f}#32, height.scaled_float{f}#33, hire_date{f}#34, is_rehired{f}#35, job_positions{f}#36, languages{f}#37, languages.byte{f}#38, languages.long{f}#39, languages.short{f}#40, last_name{f}#41, salary{f}#42, salary_change{f}#43, salary_change.int{f}#44, salary_change.keyword{f}#45, salary_change.long{f}#46, still_hired{f}#47, does_not_exist{f}#48] \_Limit[1000[INTEGER],false,false] - \_Project[[avg_worked_seconds{f}#50, birth_date{f}#51, emp_no{f}#52, first_name{f}#53, gender{f}#54, height{f}#55, height.float{f}#56, height.half_float{f}#57, height.scaled_float{f}#58, hire_date{f}#59, is_rehired{f}#60, job_positions{f}#61, languages{f}#62, languages.byte{f}#63, languages.long{f}#64, languages.short{f}#65, last_name{f}#66, salary{f}#67, salary_change{f}#68, salary_change.int{f}#69, salary_change.keyword{f}#70, salary_change.long{f}#71, still_hired{f}#72, does_not_exist{r}#73, _fork{r}#49]] + \_Project[[avg_worked_seconds{f(EsField)}#50, birth_date{f(DateEsField)}#51, emp_no{f(EsField)}#52, first_name{f(KeywordEsField)}#53, gender{f(KeywordEsField)}#54, height{f(EsField)}#55, height.float{f(EsField)}#56, height.half_float{f(EsField)}#57, height.scaled_float{f(EsField)}#58, hire_date{f(DateEsField)}#59, is_rehired{f(EsField)}#60, job_positions{f(KeywordEsField)}#61, languages{f(EsField)}#62, languages.byte{f(EsField)}#63, languages.long{f(EsField)}#64, languages.short{f(EsField)}#65, last_name{f(KeywordEsField)}#66, salary{f(EsField)}#67, salary_change{f(EsField)}#68, salary_change.int{f(EsField)}#69, salary_change.keyword{f(KeywordEsField)}#70, salary_change.long{f(EsField)}#71, still_hired{f(EsField)}#72, does_not_exist{r}#73, _fork{r}#49]] \_Eval[[null[KEYWORD] AS does_not_exist#73]] \_Eval[[fork2[KEYWORD] AS _fork#49]] \_Filter[emp_no{f}#52 > 0[INTEGER]] diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testFork/nullify/analysis.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testFork/nullify/analysis.expected index 126b23315f762..bef6a1204b623 100644 --- a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testFork/nullify/analysis.expected +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testFork/nullify/analysis.expected @@ -1,13 +1,13 @@ Limit[1000[INTEGER],false,false] \_Fork[[avg_worked_seconds{r}#0, birth_date{r}#1, emp_no{r}#2, first_name{r}#3, gender{r}#4, height{r}#5, height.float{r}#6, height.half_float{r}#7, height.scaled_float{r}#8, hire_date{r}#9, is_rehired{r}#10, job_positions{r}#11, languages{r}#12, languages.byte{r}#13, languages.long{r}#14, languages.short{r}#15, last_name{r}#16, salary{r}#17, salary_change{r}#18, salary_change.int{r}#19, salary_change.keyword{r}#20, salary_change.long{r}#21, still_hired{r}#22, does_not_exist{r}#23, _fork{r}#24]] |_Limit[1000[INTEGER],false,false] - | \_Project[[avg_worked_seconds{f}#25, birth_date{f}#26, emp_no{f}#27, first_name{f}#28, gender{f}#29, height{f}#30, height.float{f}#31, height.half_float{f}#32, height.scaled_float{f}#33, hire_date{f}#34, is_rehired{f}#35, job_positions{f}#36, languages{f}#37, languages.byte{f}#38, languages.long{f}#39, languages.short{f}#40, last_name{f}#41, salary{f}#42, salary_change{f}#43, salary_change.int{f}#44, salary_change.keyword{f}#45, salary_change.long{f}#46, still_hired{f}#47, does_not_exist{r}#48, _fork{r}#49]] + | \_Project[[avg_worked_seconds{f(EsField)}#25, birth_date{f(DateEsField)}#26, emp_no{f(EsField)}#27, first_name{f(KeywordEsField)}#28, gender{f(KeywordEsField)}#29, height{f(EsField)}#30, height.float{f(EsField)}#31, height.half_float{f(EsField)}#32, height.scaled_float{f(EsField)}#33, hire_date{f(DateEsField)}#34, is_rehired{f(EsField)}#35, job_positions{f(KeywordEsField)}#36, languages{f(EsField)}#37, languages.byte{f(EsField)}#38, languages.long{f(EsField)}#39, languages.short{f(EsField)}#40, last_name{f(KeywordEsField)}#41, salary{f(EsField)}#42, salary_change{f(EsField)}#43, salary_change.int{f(EsField)}#44, salary_change.keyword{f(KeywordEsField)}#45, salary_change.long{f(EsField)}#46, still_hired{f(EsField)}#47, does_not_exist{r}#48, _fork{r}#49]] | \_Eval[[fork1[KEYWORD] AS _fork#49]] | \_Filter[TOLONG(does_not_exist{r}#48) > 0[INTEGER]] | \_Eval[[null[NULL] AS does_not_exist#48]] | \_EsRelation[employees][avg_worked_seconds{f}#25, birth_date{f}#26, emp_no{f}#27, first_name{f}#28, gender{f}#29, height{f}#30, height.float{f}#31, height.half_float{f}#32, height.scaled_float{f}#33, hire_date{f}#34, is_rehired{f}#35, job_positions{f}#36, languages{f}#37, languages.byte{f}#38, languages.long{f}#39, languages.short{f}#40, last_name{f}#41, salary{f}#42, salary_change{f}#43, salary_change.int{f}#44, salary_change.keyword{f}#45, salary_change.long{f}#46, still_hired{f}#47] \_Limit[1000[INTEGER],false,false] - \_Project[[avg_worked_seconds{f}#50, birth_date{f}#51, emp_no{f}#52, first_name{f}#53, gender{f}#54, height{f}#55, height.float{f}#56, height.half_float{f}#57, height.scaled_float{f}#58, hire_date{f}#59, is_rehired{f}#60, job_positions{f}#61, languages{f}#62, languages.byte{f}#63, languages.long{f}#64, languages.short{f}#65, last_name{f}#66, salary{f}#67, salary_change{f}#68, salary_change.int{f}#69, salary_change.keyword{f}#70, salary_change.long{f}#71, still_hired{f}#72, does_not_exist{r}#73, _fork{r}#49]] + \_Project[[avg_worked_seconds{f(EsField)}#50, birth_date{f(DateEsField)}#51, emp_no{f(EsField)}#52, first_name{f(KeywordEsField)}#53, gender{f(KeywordEsField)}#54, height{f(EsField)}#55, height.float{f(EsField)}#56, height.half_float{f(EsField)}#57, height.scaled_float{f(EsField)}#58, hire_date{f(DateEsField)}#59, is_rehired{f(EsField)}#60, job_positions{f(KeywordEsField)}#61, languages{f(EsField)}#62, languages.byte{f(EsField)}#63, languages.long{f(EsField)}#64, languages.short{f(EsField)}#65, last_name{f(KeywordEsField)}#66, salary{f(EsField)}#67, salary_change{f(EsField)}#68, salary_change.int{f(EsField)}#69, salary_change.keyword{f(KeywordEsField)}#70, salary_change.long{f(EsField)}#71, still_hired{f(EsField)}#72, does_not_exist{r}#73, _fork{r}#49]] \_Eval[[null[NULL] AS does_not_exist#73]] \_Eval[[fork2[KEYWORD] AS _fork#49]] \_Filter[emp_no{f}#52 > 0[INTEGER]] diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testForkWithEval/load/analysis.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testForkWithEval/load/analysis.expected index 96d5b43c3eb3b..312bfbd84c8b9 100644 --- a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testForkWithEval/load/analysis.expected +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testForkWithEval/load/analysis.expected @@ -1,13 +1,13 @@ Limit[1000[INTEGER],false,false] \_Fork[[avg_worked_seconds{r}#0, birth_date{r}#1, emp_no{r}#2, first_name{r}#3, gender{r}#4, height{r}#5, height.float{r}#6, height.half_float{r}#7, height.scaled_float{r}#8, hire_date{r}#9, is_rehired{r}#10, job_positions{r}#11, languages{r}#12, languages.byte{r}#13, languages.long{r}#14, languages.short{r}#15, last_name{r}#16, salary{r}#17, salary_change{r}#18, salary_change.int{r}#19, salary_change.keyword{r}#20, salary_change.long{r}#21, still_hired{r}#22, does_not_exist{r}#23, x{r}#24, _fork{r}#25, y{r}#26]] |_Limit[1000[INTEGER],false,false] - | \_Project[[avg_worked_seconds{f}#27, birth_date{f}#28, emp_no{f}#29, first_name{f}#30, gender{f}#31, height{f}#32, height.float{f}#33, height.half_float{f}#34, height.scaled_float{f}#35, hire_date{f}#36, is_rehired{f}#37, job_positions{f}#38, languages{f}#39, languages.byte{f}#40, languages.long{f}#41, languages.short{f}#42, last_name{f}#43, salary{f}#44, salary_change{f}#45, salary_change.int{f}#46, salary_change.keyword{f}#47, salary_change.long{f}#48, still_hired{f}#49, does_not_exist{f}#50, x{r}#51, _fork{r}#52, y{r}#53]] + | \_Project[[avg_worked_seconds{f(EsField)}#27, birth_date{f(DateEsField)}#28, emp_no{f(EsField)}#29, first_name{f(KeywordEsField)}#30, gender{f(KeywordEsField)}#31, height{f(EsField)}#32, height.float{f(EsField)}#33, height.half_float{f(EsField)}#34, height.scaled_float{f(EsField)}#35, hire_date{f(DateEsField)}#36, is_rehired{f(EsField)}#37, job_positions{f(KeywordEsField)}#38, languages{f(EsField)}#39, languages.byte{f(EsField)}#40, languages.long{f(EsField)}#41, languages.short{f(EsField)}#42, last_name{f(KeywordEsField)}#43, salary{f(EsField)}#44, salary_change{f(EsField)}#45, salary_change.int{f(EsField)}#46, salary_change.keyword{f(KeywordEsField)}#47, salary_change.long{f(EsField)}#48, still_hired{f(EsField)}#49, does_not_exist{f(PotentiallyUnmappedKeywordEsField)}#50, x{r}#51, _fork{r}#52, y{r}#53]] | \_Eval[[null[INTEGER] AS y#53]] | \_Eval[[fork1[KEYWORD] AS _fork#52]] | \_Eval[[TODOUBLE(does_not_exist{f}#50) + 1[INTEGER] AS x#51]] | \_EsRelation[employees][avg_worked_seconds{f}#27, birth_date{f}#28, emp_no{f}#29, first_name{f}#30, gender{f}#31, height{f}#32, height.float{f}#33, height.half_float{f}#34, height.scaled_float{f}#35, hire_date{f}#36, is_rehired{f}#37, job_positions{f}#38, languages{f}#39, languages.byte{f}#40, languages.long{f}#41, languages.short{f}#42, last_name{f}#43, salary{f}#44, salary_change{f}#45, salary_change.int{f}#46, salary_change.keyword{f}#47, salary_change.long{f}#48, still_hired{f}#49, does_not_exist{f}#50] \_Limit[1000[INTEGER],false,false] - \_Project[[avg_worked_seconds{f}#54, birth_date{f}#55, emp_no{f}#56, first_name{f}#57, gender{f}#58, height{f}#59, height.float{f}#60, height.half_float{f}#61, height.scaled_float{f}#62, hire_date{f}#63, is_rehired{f}#64, job_positions{f}#65, languages{f}#66, languages.byte{f}#67, languages.long{f}#68, languages.short{f}#69, last_name{f}#70, salary{f}#71, salary_change{f}#72, salary_change.int{f}#73, salary_change.keyword{f}#74, salary_change.long{f}#75, still_hired{f}#76, does_not_exist{r}#77, x{r}#78, _fork{r}#52, y{r}#79]] + \_Project[[avg_worked_seconds{f(EsField)}#54, birth_date{f(DateEsField)}#55, emp_no{f(EsField)}#56, first_name{f(KeywordEsField)}#57, gender{f(KeywordEsField)}#58, height{f(EsField)}#59, height.float{f(EsField)}#60, height.half_float{f(EsField)}#61, height.scaled_float{f(EsField)}#62, hire_date{f(DateEsField)}#63, is_rehired{f(EsField)}#64, job_positions{f(KeywordEsField)}#65, languages{f(EsField)}#66, languages.byte{f(EsField)}#67, languages.long{f(EsField)}#68, languages.short{f(EsField)}#69, last_name{f(KeywordEsField)}#70, salary{f(EsField)}#71, salary_change{f(EsField)}#72, salary_change.int{f(EsField)}#73, salary_change.keyword{f(KeywordEsField)}#74, salary_change.long{f(EsField)}#75, still_hired{f(EsField)}#76, does_not_exist{r}#77, x{r}#78, _fork{r}#52, y{r}#79]] \_Eval[[null[KEYWORD] AS does_not_exist#77, null[DOUBLE] AS x#78]] \_Eval[[fork2[KEYWORD] AS _fork#52]] \_Eval[[emp_no{f}#56 + 1[INTEGER] AS y#79]] diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testForkWithEval/nullify/analysis.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testForkWithEval/nullify/analysis.expected index 745bf77c8febb..c02033434bdb1 100644 --- a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testForkWithEval/nullify/analysis.expected +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testForkWithEval/nullify/analysis.expected @@ -1,14 +1,14 @@ Limit[1000[INTEGER],false,false] \_Fork[[avg_worked_seconds{r}#0, birth_date{r}#1, emp_no{r}#2, first_name{r}#3, gender{r}#4, height{r}#5, height.float{r}#6, height.half_float{r}#7, height.scaled_float{r}#8, hire_date{r}#9, is_rehired{r}#10, job_positions{r}#11, languages{r}#12, languages.byte{r}#13, languages.long{r}#14, languages.short{r}#15, last_name{r}#16, salary{r}#17, salary_change{r}#18, salary_change.int{r}#19, salary_change.keyword{r}#20, salary_change.long{r}#21, still_hired{r}#22, does_not_exist{r}#23, x{r}#24, _fork{r}#25, y{r}#26]] |_Limit[1000[INTEGER],false,false] - | \_Project[[avg_worked_seconds{f}#27, birth_date{f}#28, emp_no{f}#29, first_name{f}#30, gender{f}#31, height{f}#32, height.float{f}#33, height.half_float{f}#34, height.scaled_float{f}#35, hire_date{f}#36, is_rehired{f}#37, job_positions{f}#38, languages{f}#39, languages.byte{f}#40, languages.long{f}#41, languages.short{f}#42, last_name{f}#43, salary{f}#44, salary_change{f}#45, salary_change.int{f}#46, salary_change.keyword{f}#47, salary_change.long{f}#48, still_hired{f}#49, does_not_exist{r}#50, x{r}#51, _fork{r}#52, y{r}#53]] + | \_Project[[avg_worked_seconds{f(EsField)}#27, birth_date{f(DateEsField)}#28, emp_no{f(EsField)}#29, first_name{f(KeywordEsField)}#30, gender{f(KeywordEsField)}#31, height{f(EsField)}#32, height.float{f(EsField)}#33, height.half_float{f(EsField)}#34, height.scaled_float{f(EsField)}#35, hire_date{f(DateEsField)}#36, is_rehired{f(EsField)}#37, job_positions{f(KeywordEsField)}#38, languages{f(EsField)}#39, languages.byte{f(EsField)}#40, languages.long{f(EsField)}#41, languages.short{f(EsField)}#42, last_name{f(KeywordEsField)}#43, salary{f(EsField)}#44, salary_change{f(EsField)}#45, salary_change.int{f(EsField)}#46, salary_change.keyword{f(KeywordEsField)}#47, salary_change.long{f(EsField)}#48, still_hired{f(EsField)}#49, does_not_exist{r}#50, x{r}#51, _fork{r}#52, y{r}#53]] | \_Eval[[null[INTEGER] AS y#53]] | \_Eval[[fork1[KEYWORD] AS _fork#52]] | \_Eval[[TODOUBLE(does_not_exist{r}#50) + 1[INTEGER] AS x#51]] | \_Eval[[null[NULL] AS does_not_exist#50]] | \_EsRelation[employees][avg_worked_seconds{f}#27, birth_date{f}#28, emp_no{f}#29, first_name{f}#30, gender{f}#31, height{f}#32, height.float{f}#33, height.half_float{f}#34, height.scaled_float{f}#35, hire_date{f}#36, is_rehired{f}#37, job_positions{f}#38, languages{f}#39, languages.byte{f}#40, languages.long{f}#41, languages.short{f}#42, last_name{f}#43, salary{f}#44, salary_change{f}#45, salary_change.int{f}#46, salary_change.keyword{f}#47, salary_change.long{f}#48, still_hired{f}#49] \_Limit[1000[INTEGER],false,false] - \_Project[[avg_worked_seconds{f}#54, birth_date{f}#55, emp_no{f}#56, first_name{f}#57, gender{f}#58, height{f}#59, height.float{f}#60, height.half_float{f}#61, height.scaled_float{f}#62, hire_date{f}#63, is_rehired{f}#64, job_positions{f}#65, languages{f}#66, languages.byte{f}#67, languages.long{f}#68, languages.short{f}#69, last_name{f}#70, salary{f}#71, salary_change{f}#72, salary_change.int{f}#73, salary_change.keyword{f}#74, salary_change.long{f}#75, still_hired{f}#76, does_not_exist{r}#77, x{r}#78, _fork{r}#52, y{r}#79]] + \_Project[[avg_worked_seconds{f(EsField)}#54, birth_date{f(DateEsField)}#55, emp_no{f(EsField)}#56, first_name{f(KeywordEsField)}#57, gender{f(KeywordEsField)}#58, height{f(EsField)}#59, height.float{f(EsField)}#60, height.half_float{f(EsField)}#61, height.scaled_float{f(EsField)}#62, hire_date{f(DateEsField)}#63, is_rehired{f(EsField)}#64, job_positions{f(KeywordEsField)}#65, languages{f(EsField)}#66, languages.byte{f(EsField)}#67, languages.long{f(EsField)}#68, languages.short{f(EsField)}#69, last_name{f(KeywordEsField)}#70, salary{f(EsField)}#71, salary_change{f(EsField)}#72, salary_change.int{f(EsField)}#73, salary_change.keyword{f(KeywordEsField)}#74, salary_change.long{f(EsField)}#75, still_hired{f(EsField)}#76, does_not_exist{r}#77, x{r}#78, _fork{r}#52, y{r}#79]] \_Eval[[null[NULL] AS does_not_exist#77, null[DOUBLE] AS x#78]] \_Eval[[fork2[KEYWORD] AS _fork#52]] \_Eval[[emp_no{f}#56 + 1[INTEGER] AS y#79]] diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testForkWithStats/load/analysis.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testForkWithStats/load/analysis.expected index 179c4819647d5..3c38b14082b60 100644 --- a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testForkWithStats/load/analysis.expected +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testForkWithStats/load/analysis.expected @@ -2,14 +2,14 @@ Limit[1000[INTEGER],false,false] \_OrderBy[[Order[does_not_exist{r}#0,ASC,LAST]]] \_Fork[[c{r}#1, does_not_exist{r}#0, _fork{r}#2, d{r}#3]] |_Limit[1000[INTEGER],false,false] - | \_Project[[c{r}#4, does_not_exist{f}#5, _fork{r}#6, d{r}#7]] + | \_Project[[c{r}#4, does_not_exist{f(PotentiallyUnmappedKeywordEsField)}#5, _fork{r}#6, d{r}#7]] | \_Eval[[null[DOUBLE] AS d#7]] | \_Eval[[fork1[KEYWORD] AS _fork#6]] - | \_Aggregate[[does_not_exist{f}#5],[COUNT(*[KEYWORD],true[BOOLEAN],PT0S[TIME_DURATION]) AS c#4, does_not_exist{f}#5]] + | \_Aggregate[[does_not_exist{f(PotentiallyUnmappedKeywordEsField)}#5],[COUNT(*[KEYWORD],true[BOOLEAN],PT0S[TIME_DURATION]) AS c#4, does_not_exist{f(PotentiallyUnmappedKeywordEsField)}#5]] | \_EsRelation[employees][avg_worked_seconds{f}#8, birth_date{f}#9, emp_no{f}#10, first_name{f}#11, gender{f}#12, height{f}#13, height.float{f}#14, height.half_float{f}#15, height.scaled_float{f}#16, hire_date{f}#17, is_rehired{f}#18, job_positions{f}#19, languages{f}#20, languages.byte{f}#21, languages.long{f}#22, languages.short{f}#23, last_name{f}#24, salary{f}#25, salary_change{f}#26, salary_change.int{f}#27, salary_change.keyword{f}#28, salary_change.long{f}#29, still_hired{f}#30, does_not_exist{f}#5] \_Limit[1000[INTEGER],false,false] \_Project[[c{r}#31, does_not_exist{r}#32, _fork{r}#6, d{r}#33]] \_Eval[[null[LONG] AS c#31, null[KEYWORD] AS does_not_exist#32]] \_Eval[[fork2[KEYWORD] AS _fork#6]] - \_Aggregate[[],[AVG(TODOUBLE(salary{f}#34),true[BOOLEAN],PT0S[TIME_DURATION],compensated[KEYWORD]) AS d#33]] + \_Aggregate[[],[AVG(TODOUBLE(salary{f(EsField)}#34),true[BOOLEAN],PT0S[TIME_DURATION],compensated[KEYWORD]) AS d#33]] \_EsRelation[employees][avg_worked_seconds{f}#35, birth_date{f}#36, emp_no{f}#37, first_name{f}#38, gender{f}#39, height{f}#40, height.float{f}#41, height.half_float{f}#42, height.scaled_float{f}#43, hire_date{f}#44, is_rehired{f}#45, job_positions{f}#46, languages{f}#47, languages.byte{f}#48, languages.long{f}#49, languages.short{f}#50, last_name{f}#51, salary{f}#34, salary_change{f}#52, salary_change.int{f}#53, salary_change.keyword{f}#54, salary_change.long{f}#55, still_hired{f}#56] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testForkWithStats/nullify/analysis.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testForkWithStats/nullify/analysis.expected index 0905fb72ef867..2b609c20b89e9 100644 --- a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testForkWithStats/nullify/analysis.expected +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testForkWithStats/nullify/analysis.expected @@ -12,5 +12,5 @@ Limit[1000[INTEGER],false,false] \_Project[[c{r}#31, does_not_exist{r}#32, _fork{r}#6, d{r}#33]] \_Eval[[null[LONG] AS c#31, null[NULL] AS does_not_exist#32]] \_Eval[[fork2[KEYWORD] AS _fork#6]] - \_Aggregate[[],[AVG(TODOUBLE(salary{f}#34),true[BOOLEAN],PT0S[TIME_DURATION],compensated[KEYWORD]) AS d#33]] + \_Aggregate[[],[AVG(TODOUBLE(salary{f(EsField)}#34),true[BOOLEAN],PT0S[TIME_DURATION],compensated[KEYWORD]) AS d#33]] \_EsRelation[employees][avg_worked_seconds{f}#35, birth_date{f}#36, emp_no{f}#37, first_name{f}#38, gender{f}#39, height{f}#40, height.float{f}#41, height.half_float{f}#42, height.scaled_float{f}#43, hire_date{f}#44, is_rehired{f}#45, job_positions{f}#46, languages{f}#47, languages.byte{f}#48, languages.long{f}#49, languages.short{f}#50, last_name{f}#51, salary{f}#34, salary_change{f}#52, salary_change.int{f}#53, salary_change.keyword{f}#54, salary_change.long{f}#55, still_hired{f}#56] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testInlineStats/load/analysis.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testInlineStats/load/analysis.expected index 36814b4fcb812..0507eaa2c2446 100644 --- a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testInlineStats/load/analysis.expected +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testInlineStats/load/analysis.expected @@ -1,4 +1,4 @@ Limit[1000[INTEGER],false,false] \_InlineStats[] - \_Aggregate[[does_not_exist2{f}#0, emp_no{f}#1],[SUM(TODOUBLE(does_not_exist1{f}#2),true[BOOLEAN],PT0S[TIME_DURATION],compensated[KEYWORD]) AS s#3, COUNT(*[KEYWORD],true[BOOLEAN],PT0S[TIME_DURATION]) AS c#4, does_not_exist2{f}#0, emp_no{f}#1]] + \_Aggregate[[does_not_exist2{f(PotentiallyUnmappedKeywordEsField)}#0, emp_no{f(EsField)}#1],[SUM(TODOUBLE(does_not_exist1{f(PotentiallyUnmappedKeywordEsField)}#2),true[BOOLEAN],PT0S[TIME_DURATION],compensated[KEYWORD]) AS s#3, COUNT(*[KEYWORD],true[BOOLEAN],PT0S[TIME_DURATION]) AS c#4, does_not_exist2{f(PotentiallyUnmappedKeywordEsField)}#0, emp_no{f(EsField)}#1]] \_EsRelation[employees][avg_worked_seconds{f}#5, birth_date{f}#6, emp_no{f}#1, first_name{f}#7, gender{f}#8, height{f}#9, height.float{f}#10, height.half_float{f}#11, height.scaled_float{f}#12, hire_date{f}#13, is_rehired{f}#14, job_positions{f}#15, languages{f}#16, languages.byte{f}#17, languages.long{f}#18, languages.short{f}#19, last_name{f}#20, salary{f}#21, salary_change{f}#22, salary_change.int{f}#23, salary_change.keyword{f}#24, salary_change.long{f}#25, still_hired{f}#26, does_not_exist2{f}#0, does_not_exist1{f}#2] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testInlineStats/nullify/analysis.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testInlineStats/nullify/analysis.expected index 5f2ab1697cd95..3d44e8346ff78 100644 --- a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testInlineStats/nullify/analysis.expected +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testInlineStats/nullify/analysis.expected @@ -1,5 +1,5 @@ Limit[1000[INTEGER],false,false] \_InlineStats[] - \_Aggregate[[does_not_exist2{r}#0, emp_no{f}#1],[SUM(TODOUBLE(does_not_exist1{r}#2),true[BOOLEAN],PT0S[TIME_DURATION],compensated[KEYWORD]) AS s#3, COUNT(*[KEYWORD],true[BOOLEAN],PT0S[TIME_DURATION]) AS c#4, does_not_exist2{r}#0, emp_no{f}#1]] + \_Aggregate[[does_not_exist2{r}#0, emp_no{f(EsField)}#1],[SUM(TODOUBLE(does_not_exist1{r}#2),true[BOOLEAN],PT0S[TIME_DURATION],compensated[KEYWORD]) AS s#3, COUNT(*[KEYWORD],true[BOOLEAN],PT0S[TIME_DURATION]) AS c#4, does_not_exist2{r}#0, emp_no{f(EsField)}#1]] \_Eval[[null[NULL] AS does_not_exist2#0, null[NULL] AS does_not_exist1#2]] \_EsRelation[employees][avg_worked_seconds{f}#5, birth_date{f}#6, emp_no{f}#1, first_name{f}#7, gender{f}#8, height{f}#9, height.float{f}#10, height.half_float{f}#11, height.scaled_float{f}#12, hire_date{f}#13, is_rehired{f}#14, job_positions{f}#15, languages{f}#16, languages.byte{f}#17, languages.long{f}#18, languages.short{f}#19, last_name{f}#20, salary{f}#21, salary_change{f}#22, salary_change.int{f}#23, salary_change.keyword{f}#24, salary_change.long{f}#25, still_hired{f}#26] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testKeep/load/analysis.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testKeep/load/analysis.expected index b0d320e2b8ee8..d21ff127af792 100644 --- a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testKeep/load/analysis.expected +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testKeep/load/analysis.expected @@ -1,3 +1,3 @@ Limit[1000[INTEGER],false,false] -\_Project[[does_not_exist_field{f}#0]] +\_Project[[does_not_exist_field{f(PotentiallyUnmappedKeywordEsField)}#0]] \_EsRelation[employees][avg_worked_seconds{f}#1, birth_date{f}#2, emp_no{f}#3, first_name{f}#4, gender{f}#5, height{f}#6, height.float{f}#7, height.half_float{f}#8, height.scaled_float{f}#9, hire_date{f}#10, is_rehired{f}#11, job_positions{f}#12, languages{f}#13, languages.byte{f}#14, languages.long{f}#15, languages.short{f}#16, last_name{f}#17, salary{f}#18, salary_change{f}#19, salary_change.int{f}#20, salary_change.keyword{f}#21, salary_change.long{f}#22, still_hired{f}#23, does_not_exist_field{f}#0] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testKeepAndMatchingStar/load/analysis.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testKeepAndMatchingStar/load/analysis.expected index 872c7642ff1f5..31f790943f6fd 100644 --- a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testKeepAndMatchingStar/load/analysis.expected +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testKeepAndMatchingStar/load/analysis.expected @@ -1,3 +1,3 @@ Limit[1000[INTEGER],false,false] -\_Project[[emp_no{f}#0, does_not_exist_field{f}#1]] +\_Project[[emp_no{f(EsField)}#0, does_not_exist_field{f(PotentiallyUnmappedKeywordEsField)}#1]] \_EsRelation[employees][avg_worked_seconds{f}#2, birth_date{f}#3, emp_no{f}#0, first_name{f}#4, gender{f}#5, height{f}#6, height.float{f}#7, height.half_float{f}#8, height.scaled_float{f}#9, hire_date{f}#10, is_rehired{f}#11, job_positions{f}#12, languages{f}#13, languages.byte{f}#14, languages.long{f}#15, languages.short{f}#16, last_name{f}#17, salary{f}#18, salary_change{f}#19, salary_change.int{f}#20, salary_change.keyword{f}#21, salary_change.long{f}#22, still_hired{f}#23, does_not_exist_field{f}#1] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testKeepAndMatchingStar/nullify/analysis.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testKeepAndMatchingStar/nullify/analysis.expected index cc66e19745707..7b3dd01202d22 100644 --- a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testKeepAndMatchingStar/nullify/analysis.expected +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testKeepAndMatchingStar/nullify/analysis.expected @@ -1,4 +1,4 @@ Limit[1000[INTEGER],false,false] -\_Project[[emp_no{f}#0, does_not_exist_field{r}#1]] +\_Project[[emp_no{f(EsField)}#0, does_not_exist_field{r}#1]] \_Eval[[null[NULL] AS does_not_exist_field#1]] \_EsRelation[employees][avg_worked_seconds{f}#2, birth_date{f}#3, emp_no{f}#0, first_name{f}#4, gender{f}#5, height{f}#6, height.float{f}#7, height.half_float{f}#8, height.scaled_float{f}#9, hire_date{f}#10, is_rehired{f}#11, job_positions{f}#12, languages{f}#13, languages.byte{f}#14, languages.long{f}#15, languages.short{f}#16, last_name{f}#17, salary{f}#18, salary_change{f}#19, salary_change.int{f}#20, salary_change.keyword{f}#21, salary_change.long{f}#22, still_hired{f}#23] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testKeepRepeated/load/analysis.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testKeepRepeated/load/analysis.expected index b0d320e2b8ee8..d21ff127af792 100644 --- a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testKeepRepeated/load/analysis.expected +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testKeepRepeated/load/analysis.expected @@ -1,3 +1,3 @@ Limit[1000[INTEGER],false,false] -\_Project[[does_not_exist_field{f}#0]] +\_Project[[does_not_exist_field{f(PotentiallyUnmappedKeywordEsField)}#0]] \_EsRelation[employees][avg_worked_seconds{f}#1, birth_date{f}#2, emp_no{f}#3, first_name{f}#4, gender{f}#5, height{f}#6, height.float{f}#7, height.half_float{f}#8, height.scaled_float{f}#9, hire_date{f}#10, is_rehired{f}#11, job_positions{f}#12, languages{f}#13, languages.byte{f}#14, languages.long{f}#15, languages.short{f}#16, last_name{f}#17, salary{f}#18, salary_change{f}#19, salary_change.int{f}#20, salary_change.keyword{f}#21, salary_change.long{f}#22, still_hired{f}#23, does_not_exist_field{f}#0] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testKeepThenEval/load/analysis.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testKeepThenEval/load/analysis.expected index c6a21f8491422..01fc4148688e2 100644 --- a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testKeepThenEval/load/analysis.expected +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testKeepThenEval/load/analysis.expected @@ -1,4 +1,4 @@ Limit[1000[INTEGER],false,false] \_Eval[[42[INTEGER] AS does_not_exist_field#0]] - \_Project[[does_not_exist_field{f}#1]] + \_Project[[does_not_exist_field{f(PotentiallyUnmappedKeywordEsField)}#1]] \_EsRelation[employees][avg_worked_seconds{f}#2, birth_date{f}#3, emp_no{f}#4, first_name{f}#5, gender{f}#6, height{f}#7, height.float{f}#8, height.half_float{f}#9, height.scaled_float{f}#10, hire_date{f}#11, is_rehired{f}#12, job_positions{f}#13, languages{f}#14, languages.byte{f}#15, languages.long{f}#16, languages.short{f}#17, last_name{f}#18, salary{f}#19, salary_change{f}#20, salary_change.int{f}#21, salary_change.keyword{f}#22, salary_change.long{f}#23, still_hired{f}#24, does_not_exist_field{f}#1] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testLookupJoin/load/analysis.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testLookupJoin/load/analysis.expected index f57fe6df9c0a7..92f45cdd558bd 100644 --- a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testLookupJoin/load/analysis.expected +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testLookupJoin/load/analysis.expected @@ -1,5 +1,5 @@ Limit[1000[INTEGER],false,false] -\_LookupJoin[LEFT,[language_code{r}#0],[language_code{f}#1],false,null] - |_Eval[[TOINTEGER(does_not_exist{f}#2) AS language_code#0]] +\_LookupJoin[LEFT,[language_code{r}#0],[language_code{f(EsField)}#1],false,null] + |_Eval[[TOINTEGER(does_not_exist{f(PotentiallyUnmappedKeywordEsField)}#2) AS language_code#0]] | \_EsRelation[employees][avg_worked_seconds{f}#3, birth_date{f}#4, emp_no{f}#5, first_name{f}#6, gender{f}#7, height{f}#8, height.float{f}#9, height.half_float{f}#10, height.scaled_float{f}#11, hire_date{f}#12, is_rehired{f}#13, job_positions{f}#14, languages{f}#15, languages.byte{f}#16, languages.long{f}#17, languages.short{f}#18, last_name{f}#19, salary{f}#20, salary_change{f}#21, salary_change.int{f}#22, salary_change.keyword{f}#23, salary_change.long{f}#24, still_hired{f}#25, does_not_exist{f}#2] \_EsRelation[languages_lookup][LOOKUP][language_code{f}#1, language_name{f}#26] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testLookupJoin/nullify/analysis.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testLookupJoin/nullify/analysis.expected index 8a2b4eaf82e13..a6ffe3dba751f 100644 --- a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testLookupJoin/nullify/analysis.expected +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testLookupJoin/nullify/analysis.expected @@ -1,5 +1,5 @@ Limit[1000[INTEGER],false,false] -\_LookupJoin[LEFT,[language_code{r}#0],[language_code{f}#1],false,null] +\_LookupJoin[LEFT,[language_code{r}#0],[language_code{f(EsField)}#1],false,null] |_Eval[[TOINTEGER(does_not_exist{r}#2) AS language_code#0]] | \_Eval[[null[NULL] AS does_not_exist#2]] | \_EsRelation[employees][avg_worked_seconds{f}#3, birth_date{f}#4, emp_no{f}#5, first_name{f}#6, gender{f}#7, height{f}#8, height.float{f}#9, height.half_float{f}#10, height.scaled_float{f}#11, hire_date{f}#12, is_rehired{f}#13, job_positions{f}#14, languages{f}#15, languages.byte{f}#16, languages.long{f}#17, languages.short{f}#18, last_name{f}#19, salary{f}#20, salary_change{f}#21, salary_change.int{f}#22, salary_change.keyword{f}#23, salary_change.long{f}#24, still_hired{f}#25] diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testLookupJoinWithFilter/load/analysis.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testLookupJoinWithFilter/load/analysis.expected index 0e429b6f7e085..89dfad1b7ef36 100644 --- a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testLookupJoinWithFilter/load/analysis.expected +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testLookupJoinWithFilter/load/analysis.expected @@ -1,6 +1,6 @@ Limit[1000[INTEGER],false,false] \_Filter[TOLONG(does_not_exist{f}#0) > 0[INTEGER]] - \_LookupJoin[LEFT,[language_code{r}#1],[language_code{f}#2],false,null] - |_Eval[[languages{f}#3 AS language_code#1]] + \_LookupJoin[LEFT,[language_code{r}#1],[language_code{f(EsField)}#2],false,null] + |_Eval[[languages{f(EsField)}#3 AS language_code#1]] | \_EsRelation[employees][avg_worked_seconds{f}#4, birth_date{f}#5, emp_no{f}#6, first_name{f}#7, gender{f}#8, height{f}#9, height.float{f}#10, height.half_float{f}#11, height.scaled_float{f}#12, hire_date{f}#13, is_rehired{f}#14, job_positions{f}#15, languages{f}#3, languages.byte{f}#16, languages.long{f}#17, languages.short{f}#18, last_name{f}#19, salary{f}#20, salary_change{f}#21, salary_change.int{f}#22, salary_change.keyword{f}#23, salary_change.long{f}#24, still_hired{f}#25, does_not_exist{f}#0] \_EsRelation[languages_lookup][LOOKUP][language_code{f}#2, language_name{f}#26] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testLookupJoinWithFilter/nullify/analysis.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testLookupJoinWithFilter/nullify/analysis.expected index 204ffb0063c39..b67ae7d9398f2 100644 --- a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testLookupJoinWithFilter/nullify/analysis.expected +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testLookupJoinWithFilter/nullify/analysis.expected @@ -1,7 +1,7 @@ Limit[1000[INTEGER],false,false] \_Filter[TOLONG(does_not_exist{r}#0) > 0[INTEGER]] - \_LookupJoin[LEFT,[language_code{r}#1],[language_code{f}#2],false,null] - |_Eval[[languages{f}#3 AS language_code#1, null[NULL] AS does_not_exist#4]] + \_LookupJoin[LEFT,[language_code{r}#1],[language_code{f(EsField)}#2],false,null] + |_Eval[[languages{f(EsField)}#3 AS language_code#1, null[NULL] AS does_not_exist#4]] | \_EsRelation[employees][avg_worked_seconds{f}#5, birth_date{f}#6, emp_no{f}#7, first_name{f}#8, gender{f}#9, height{f}#10, height.float{f}#11, height.half_float{f}#12, height.scaled_float{f}#13, hire_date{f}#14, is_rehired{f}#15, job_positions{f}#16, languages{f}#3, languages.byte{f}#17, languages.long{f}#18, languages.short{f}#19, last_name{f}#20, salary{f}#21, salary_change{f}#22, salary_change.int{f}#23, salary_change.keyword{f}#24, salary_change.long{f}#25, still_hired{f}#26] \_Eval[[null[NULL] AS does_not_exist#0]] \_EsRelation[languages_lookup][LOOKUP][language_code{f}#2, language_name{f}#27] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testMvExpand/load/analysis.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testMvExpand/load/analysis.expected index 431d39d786c87..16c852fe171c6 100644 --- a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testMvExpand/load/analysis.expected +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testMvExpand/load/analysis.expected @@ -1,3 +1,3 @@ Limit[1000[INTEGER],false,false] -\_MvExpand[does_not_exist{f}#0,does_not_exist{r}#1] +\_MvExpand[does_not_exist{f(PotentiallyUnmappedKeywordEsField)}#0,does_not_exist{r}#1] \_EsRelation[employees][avg_worked_seconds{f}#2, birth_date{f}#3, emp_no{f}#4, first_name{f}#5, gender{f}#6, height{f}#7, height.float{f}#8, height.half_float{f}#9, height.scaled_float{f}#10, hire_date{f}#11, is_rehired{f}#12, job_positions{f}#13, languages{f}#14, languages.byte{f}#15, languages.long{f}#16, languages.short{f}#17, last_name{f}#18, salary{f}#19, salary_change{f}#20, salary_change.int{f}#21, salary_change.keyword{f}#22, salary_change.long{f}#23, still_hired{f}#24, does_not_exist{f}#0] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testPartiallyMappedField/load/analysis.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testPartiallyMappedField/load/analysis.expected index 09d01f355c3bc..6491d2ecb54e7 100644 --- a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testPartiallyMappedField/load/analysis.expected +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testPartiallyMappedField/load/analysis.expected @@ -1,3 +1,3 @@ Limit[1000[INTEGER],false,false] -\_Project[[@timestamp{f}#0, message{f}#1, unmapped_message{f}#2]] +\_Project[[@timestamp{f(DateEsField)}#0, message{f(KeywordEsField)}#1, unmapped_message{f(PotentiallyUnmappedKeywordEsField)}#2]] \_EsRelation[sample_data,partial_mapping_sample_data][@timestamp{f}#0, client_ip{f}#3, event_duration{f}#4, message{f}#1, unmapped_message{f}#2] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testPartiallyMappedField/nullify/analysis.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testPartiallyMappedField/nullify/analysis.expected index c23e90cb6e10b..b637cc104c27c 100644 --- a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testPartiallyMappedField/nullify/analysis.expected +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testPartiallyMappedField/nullify/analysis.expected @@ -1,4 +1,4 @@ Limit[1000[INTEGER],false,false] -\_Project[[@timestamp{f}#0, message{f}#1, unmapped_message{r}#2]] +\_Project[[@timestamp{f(DateEsField)}#0, message{f(KeywordEsField)}#1, unmapped_message{r}#2]] \_Eval[[null[NULL] AS unmapped_message#2]] \_EsRelation[sample_data,partial_mapping_sample_data][@timestamp{f}#0, client_ip{f}#3, event_duration{f}#4, message{f}#1] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testPartiallyMappedFieldWithEval/load/analysis.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testPartiallyMappedFieldWithEval/load/analysis.expected index b34196e39e72e..056d8546be64a 100644 --- a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testPartiallyMappedFieldWithEval/load/analysis.expected +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testPartiallyMappedFieldWithEval/load/analysis.expected @@ -1,4 +1,4 @@ Limit[1000[INTEGER],false,false] -\_Project[[@timestamp{f}#0, x{r}#1, does_not_exist{f}#2]] - \_Eval[[COALESCE(unmapped_message{f}#3,missing[KEYWORD]) AS x#1]] +\_Project[[@timestamp{f(DateEsField)}#0, x{r}#1, does_not_exist{f(PotentiallyUnmappedKeywordEsField)}#2]] + \_Eval[[COALESCE(unmapped_message{f(PotentiallyUnmappedKeywordEsField)}#3,missing[KEYWORD]) AS x#1]] \_EsRelation[sample_data,partial_mapping_sample_data][@timestamp{f}#0, client_ip{f}#4, event_duration{f}#5, message{f}#6, unmapped_message{f}#3, does_not_exist{f}#2] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testPartiallyMappedFieldWithEval/nullify/analysis.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testPartiallyMappedFieldWithEval/nullify/analysis.expected index 3423a5d39ac06..e32df7a3a8f8d 100644 --- a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testPartiallyMappedFieldWithEval/nullify/analysis.expected +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testPartiallyMappedFieldWithEval/nullify/analysis.expected @@ -1,5 +1,5 @@ Limit[1000[INTEGER],false,false] -\_Project[[@timestamp{f}#0, x{r}#1, does_not_exist{r}#2]] +\_Project[[@timestamp{f(DateEsField)}#0, x{r}#1, does_not_exist{r}#2]] \_Eval[[COALESCE(unmapped_message{r}#3,missing[KEYWORD]) AS x#1]] \_Eval[[null[NULL] AS unmapped_message#3, null[NULL] AS does_not_exist#2]] \_EsRelation[sample_data,partial_mapping_sample_data][@timestamp{f}#0, client_ip{f}#4, event_duration{f}#5, message{f}#6] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testPartiallyMappedFieldWithStats/load/analysis.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testPartiallyMappedFieldWithStats/load/analysis.expected index 30aecb7154ced..a3725a08f77a4 100644 --- a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testPartiallyMappedFieldWithStats/load/analysis.expected +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testPartiallyMappedFieldWithStats/load/analysis.expected @@ -1,3 +1,3 @@ Limit[1000[INTEGER],false,false] -\_Aggregate[[unmapped_message{f}#0],[COUNT(*[KEYWORD],true[BOOLEAN],PT0S[TIME_DURATION]) AS c#1, unmapped_message{f}#0]] +\_Aggregate[[unmapped_message{f(PotentiallyUnmappedKeywordEsField)}#0],[COUNT(*[KEYWORD],true[BOOLEAN],PT0S[TIME_DURATION]) AS c#1, unmapped_message{f(PotentiallyUnmappedKeywordEsField)}#0]] \_EsRelation[sample_data,partial_mapping_sample_data][@timestamp{f}#2, client_ip{f}#3, event_duration{f}#4, message{f}#5, unmapped_message{f}#0] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testRename/load/analysis.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testRename/load/analysis.expected index d593728177af5..fc6e42d4dce53 100644 --- a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testRename/load/analysis.expected +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testRename/load/analysis.expected @@ -1,3 +1,3 @@ Limit[1000[INTEGER],false,false] -\_Project[[avg_worked_seconds{f}#0, birth_date{f}#1, emp_no{f}#2 AS employee_number#3, first_name{f}#4, gender{f}#5, height{f}#6, height.float{f}#7, height.half_float{f}#8, height.scaled_float{f}#9, hire_date{f}#10, is_rehired{f}#11, job_positions{f}#12, languages{f}#13, languages.byte{f}#14, languages.long{f}#15, languages.short{f}#16, last_name{f}#17, salary{f}#18, salary_change{f}#19, salary_change.int{f}#20, salary_change.keyword{f}#21, salary_change.long{f}#22, still_hired{f}#23, does_not_exist_field{f}#24 AS now_it_does#25]] +\_Project[[avg_worked_seconds{f(EsField)}#0, birth_date{f(DateEsField)}#1, emp_no{f(EsField)}#2 AS employee_number#3, first_name{f(KeywordEsField)}#4, gender{f(KeywordEsField)}#5, height{f(EsField)}#6, height.float{f(EsField)}#7, height.half_float{f(EsField)}#8, height.scaled_float{f(EsField)}#9, hire_date{f(DateEsField)}#10, is_rehired{f(EsField)}#11, job_positions{f(KeywordEsField)}#12, languages{f(EsField)}#13, languages.byte{f(EsField)}#14, languages.long{f(EsField)}#15, languages.short{f(EsField)}#16, last_name{f(KeywordEsField)}#17, salary{f(EsField)}#18, salary_change{f(EsField)}#19, salary_change.int{f(EsField)}#20, salary_change.keyword{f(KeywordEsField)}#21, salary_change.long{f(EsField)}#22, still_hired{f(EsField)}#23, does_not_exist_field{f(PotentiallyUnmappedKeywordEsField)}#24 AS now_it_does#25]] \_EsRelation[employees][avg_worked_seconds{f}#0, birth_date{f}#1, emp_no{f}#2, first_name{f}#4, gender{f}#5, height{f}#6, height.float{f}#7, height.half_float{f}#8, height.scaled_float{f}#9, hire_date{f}#10, is_rehired{f}#11, job_positions{f}#12, languages{f}#13, languages.byte{f}#14, languages.long{f}#15, languages.short{f}#16, last_name{f}#17, salary{f}#18, salary_change{f}#19, salary_change.int{f}#20, salary_change.keyword{f}#21, salary_change.long{f}#22, still_hired{f}#23, does_not_exist_field{f}#24] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testRename/nullify/analysis.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testRename/nullify/analysis.expected index 8dd19dd1a11b8..f0e2cc4908423 100644 --- a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testRename/nullify/analysis.expected +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testRename/nullify/analysis.expected @@ -1,4 +1,4 @@ Limit[1000[INTEGER],false,false] -\_Project[[avg_worked_seconds{f}#0, birth_date{f}#1, emp_no{f}#2 AS employee_number#3, first_name{f}#4, gender{f}#5, height{f}#6, height.float{f}#7, height.half_float{f}#8, height.scaled_float{f}#9, hire_date{f}#10, is_rehired{f}#11, job_positions{f}#12, languages{f}#13, languages.byte{f}#14, languages.long{f}#15, languages.short{f}#16, last_name{f}#17, salary{f}#18, salary_change{f}#19, salary_change.int{f}#20, salary_change.keyword{f}#21, salary_change.long{f}#22, still_hired{f}#23, does_not_exist_field{r}#24 AS now_it_does#25]] +\_Project[[avg_worked_seconds{f(EsField)}#0, birth_date{f(DateEsField)}#1, emp_no{f(EsField)}#2 AS employee_number#3, first_name{f(KeywordEsField)}#4, gender{f(KeywordEsField)}#5, height{f(EsField)}#6, height.float{f(EsField)}#7, height.half_float{f(EsField)}#8, height.scaled_float{f(EsField)}#9, hire_date{f(DateEsField)}#10, is_rehired{f(EsField)}#11, job_positions{f(KeywordEsField)}#12, languages{f(EsField)}#13, languages.byte{f(EsField)}#14, languages.long{f(EsField)}#15, languages.short{f(EsField)}#16, last_name{f(KeywordEsField)}#17, salary{f(EsField)}#18, salary_change{f(EsField)}#19, salary_change.int{f(EsField)}#20, salary_change.keyword{f(KeywordEsField)}#21, salary_change.long{f(EsField)}#22, still_hired{f(EsField)}#23, does_not_exist_field{r}#24 AS now_it_does#25]] \_Eval[[null[NULL] AS does_not_exist_field#24]] \_EsRelation[employees][avg_worked_seconds{f}#0, birth_date{f}#1, emp_no{f}#2, first_name{f}#4, gender{f}#5, height{f}#6, height.float{f}#7, height.half_float{f}#8, height.scaled_float{f}#9, hire_date{f}#10, is_rehired{f}#11, job_positions{f}#12, languages{f}#13, languages.byte{f}#14, languages.long{f}#15, languages.short{f}#16, last_name{f}#17, salary{f}#18, salary_change{f}#19, salary_change.int{f}#20, salary_change.keyword{f}#21, salary_change.long{f}#22, still_hired{f}#23] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testRenameEval/load/analysis.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testRenameEval/load/analysis.expected index a802df25ed62b..c31cede9fea9b 100644 --- a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testRenameEval/load/analysis.expected +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testRenameEval/load/analysis.expected @@ -1,4 +1,4 @@ Limit[1000[INTEGER],false,false] \_Eval[[TODOUBLE(does_not_exist{f}#0) + 1[INTEGER] AS x#1]] - \_Project[[avg_worked_seconds{f}#2, birth_date{f}#3, emp_no{f}#4 AS employee_number#5, first_name{f}#6, gender{f}#7, height{f}#8, height.float{f}#9, height.half_float{f}#10, height.scaled_float{f}#11, hire_date{f}#12, is_rehired{f}#13, job_positions{f}#14, languages{f}#15, languages.byte{f}#16, languages.long{f}#17, languages.short{f}#18, last_name{f}#19, salary{f}#20, salary_change{f}#21, salary_change.int{f}#22, salary_change.keyword{f}#23, salary_change.long{f}#24, still_hired{f}#25, does_not_exist{f}#0]] + \_Project[[avg_worked_seconds{f(EsField)}#2, birth_date{f(DateEsField)}#3, emp_no{f(EsField)}#4 AS employee_number#5, first_name{f(KeywordEsField)}#6, gender{f(KeywordEsField)}#7, height{f(EsField)}#8, height.float{f(EsField)}#9, height.half_float{f(EsField)}#10, height.scaled_float{f(EsField)}#11, hire_date{f(DateEsField)}#12, is_rehired{f(EsField)}#13, job_positions{f(KeywordEsField)}#14, languages{f(EsField)}#15, languages.byte{f(EsField)}#16, languages.long{f(EsField)}#17, languages.short{f(EsField)}#18, last_name{f(KeywordEsField)}#19, salary{f(EsField)}#20, salary_change{f(EsField)}#21, salary_change.int{f(EsField)}#22, salary_change.keyword{f(KeywordEsField)}#23, salary_change.long{f(EsField)}#24, still_hired{f(EsField)}#25, does_not_exist{f(PotentiallyUnmappedKeywordEsField)}#0]] \_EsRelation[employees][avg_worked_seconds{f}#2, birth_date{f}#3, emp_no{f}#4, first_name{f}#6, gender{f}#7, height{f}#8, height.float{f}#9, height.half_float{f}#10, height.scaled_float{f}#11, hire_date{f}#12, is_rehired{f}#13, job_positions{f}#14, languages{f}#15, languages.byte{f}#16, languages.long{f}#17, languages.short{f}#18, last_name{f}#19, salary{f}#20, salary_change{f}#21, salary_change.int{f}#22, salary_change.keyword{f}#23, salary_change.long{f}#24, still_hired{f}#25, does_not_exist{f}#0] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testRenameEval/nullify/analysis.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testRenameEval/nullify/analysis.expected index f96459400cd9a..1ead97977e5fb 100644 --- a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testRenameEval/nullify/analysis.expected +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testRenameEval/nullify/analysis.expected @@ -1,5 +1,5 @@ Limit[1000[INTEGER],false,false] \_Eval[[TODOUBLE(does_not_exist{r}#0) + 1[INTEGER] AS x#1]] - \_Project[[avg_worked_seconds{f}#2, birth_date{f}#3, emp_no{f}#4 AS employee_number#5, first_name{f}#6, gender{f}#7, height{f}#8, height.float{f}#9, height.half_float{f}#10, height.scaled_float{f}#11, hire_date{f}#12, is_rehired{f}#13, job_positions{f}#14, languages{f}#15, languages.byte{f}#16, languages.long{f}#17, languages.short{f}#18, last_name{f}#19, salary{f}#20, salary_change{f}#21, salary_change.int{f}#22, salary_change.keyword{f}#23, salary_change.long{f}#24, still_hired{f}#25, does_not_exist{r}#0]] + \_Project[[avg_worked_seconds{f(EsField)}#2, birth_date{f(DateEsField)}#3, emp_no{f(EsField)}#4 AS employee_number#5, first_name{f(KeywordEsField)}#6, gender{f(KeywordEsField)}#7, height{f(EsField)}#8, height.float{f(EsField)}#9, height.half_float{f(EsField)}#10, height.scaled_float{f(EsField)}#11, hire_date{f(DateEsField)}#12, is_rehired{f(EsField)}#13, job_positions{f(KeywordEsField)}#14, languages{f(EsField)}#15, languages.byte{f(EsField)}#16, languages.long{f(EsField)}#17, languages.short{f(EsField)}#18, last_name{f(KeywordEsField)}#19, salary{f(EsField)}#20, salary_change{f(EsField)}#21, salary_change.int{f(EsField)}#22, salary_change.keyword{f(KeywordEsField)}#23, salary_change.long{f(EsField)}#24, still_hired{f(EsField)}#25, does_not_exist{r}#0]] \_Eval[[null[NULL] AS does_not_exist#0]] \_EsRelation[employees][avg_worked_seconds{f}#2, birth_date{f}#3, emp_no{f}#4, first_name{f}#6, gender{f}#7, height{f}#8, height.float{f}#9, height.half_float{f}#10, height.scaled_float{f}#11, hire_date{f}#12, is_rehired{f}#13, job_positions{f}#14, languages{f}#15, languages.byte{f}#16, languages.long{f}#17, languages.short{f}#18, last_name{f}#19, salary{f}#20, salary_change{f}#21, salary_change.int{f}#22, salary_change.keyword{f}#23, salary_change.long{f}#24, still_hired{f}#25] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testRenameRepeated/load/analysis.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testRenameRepeated/load/analysis.expected index 0cc4d05a2041e..41a803dee2b34 100644 --- a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testRenameRepeated/load/analysis.expected +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testRenameRepeated/load/analysis.expected @@ -1,3 +1,3 @@ Limit[1000[INTEGER],false,false] -\_Project[[avg_worked_seconds{f}#0, birth_date{f}#1, emp_no{f}#2 AS employee_number#3, first_name{f}#4, gender{f}#5, height{f}#6, height.float{f}#7, height.half_float{f}#8, height.scaled_float{f}#9, hire_date{f}#10, is_rehired{f}#11, job_positions{f}#12, languages{f}#13, languages.byte{f}#14, languages.long{f}#15, languages.short{f}#16, last_name{f}#17, salary{f}#18, salary_change{f}#19, salary_change.int{f}#20, salary_change.keyword{f}#21, salary_change.long{f}#22, still_hired{f}#23, neither_does_this{f}#24 AS now_it_does#25]] +\_Project[[avg_worked_seconds{f(EsField)}#0, birth_date{f(DateEsField)}#1, emp_no{f(EsField)}#2 AS employee_number#3, first_name{f(KeywordEsField)}#4, gender{f(KeywordEsField)}#5, height{f(EsField)}#6, height.float{f(EsField)}#7, height.half_float{f(EsField)}#8, height.scaled_float{f(EsField)}#9, hire_date{f(DateEsField)}#10, is_rehired{f(EsField)}#11, job_positions{f(KeywordEsField)}#12, languages{f(EsField)}#13, languages.byte{f(EsField)}#14, languages.long{f(EsField)}#15, languages.short{f(EsField)}#16, last_name{f(KeywordEsField)}#17, salary{f(EsField)}#18, salary_change{f(EsField)}#19, salary_change.int{f(EsField)}#20, salary_change.keyword{f(KeywordEsField)}#21, salary_change.long{f(EsField)}#22, still_hired{f(EsField)}#23, neither_does_this{f(PotentiallyUnmappedKeywordEsField)}#24 AS now_it_does#25]] \_EsRelation[employees][avg_worked_seconds{f}#0, birth_date{f}#1, emp_no{f}#2, first_name{f}#4, gender{f}#5, height{f}#6, height.float{f}#7, height.half_float{f}#8, height.scaled_float{f}#9, hire_date{f}#10, is_rehired{f}#11, job_positions{f}#12, languages{f}#13, languages.byte{f}#14, languages.long{f}#15, languages.short{f}#16, last_name{f}#17, salary{f}#18, salary_change{f}#19, salary_change.int{f}#20, salary_change.keyword{f}#21, salary_change.long{f}#22, still_hired{f}#23, does_not_exist_field{f}#26, neither_does_this{f}#24] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testRenameRepeated/nullify/analysis.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testRenameRepeated/nullify/analysis.expected index 7507e4ff3fa4e..f828b3f7c9f30 100644 --- a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testRenameRepeated/nullify/analysis.expected +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testRenameRepeated/nullify/analysis.expected @@ -1,4 +1,4 @@ Limit[1000[INTEGER],false,false] -\_Project[[avg_worked_seconds{f}#0, birth_date{f}#1, emp_no{f}#2 AS employee_number#3, first_name{f}#4, gender{f}#5, height{f}#6, height.float{f}#7, height.half_float{f}#8, height.scaled_float{f}#9, hire_date{f}#10, is_rehired{f}#11, job_positions{f}#12, languages{f}#13, languages.byte{f}#14, languages.long{f}#15, languages.short{f}#16, last_name{f}#17, salary{f}#18, salary_change{f}#19, salary_change.int{f}#20, salary_change.keyword{f}#21, salary_change.long{f}#22, still_hired{f}#23, neither_does_this{r}#24 AS now_it_does#25]] +\_Project[[avg_worked_seconds{f(EsField)}#0, birth_date{f(DateEsField)}#1, emp_no{f(EsField)}#2 AS employee_number#3, first_name{f(KeywordEsField)}#4, gender{f(KeywordEsField)}#5, height{f(EsField)}#6, height.float{f(EsField)}#7, height.half_float{f(EsField)}#8, height.scaled_float{f(EsField)}#9, hire_date{f(DateEsField)}#10, is_rehired{f(EsField)}#11, job_positions{f(KeywordEsField)}#12, languages{f(EsField)}#13, languages.byte{f(EsField)}#14, languages.long{f(EsField)}#15, languages.short{f(EsField)}#16, last_name{f(KeywordEsField)}#17, salary{f(EsField)}#18, salary_change{f(EsField)}#19, salary_change.int{f(EsField)}#20, salary_change.keyword{f(KeywordEsField)}#21, salary_change.long{f(EsField)}#22, still_hired{f(EsField)}#23, neither_does_this{r}#24 AS now_it_does#25]] \_Eval[[null[NULL] AS does_not_exist_field#26, null[NULL] AS neither_does_this#24]] \_EsRelation[employees][avg_worked_seconds{f}#0, birth_date{f}#1, emp_no{f}#2, first_name{f}#4, gender{f}#5, height{f}#6, height.float{f}#7, height.half_float{f}#8, height.scaled_float{f}#9, hire_date{f}#10, is_rehired{f}#11, job_positions{f}#12, languages{f}#13, languages.byte{f}#14, languages.long{f}#15, languages.short{f}#16, last_name{f}#17, salary{f}#18, salary_change{f}#19, salary_change.int{f}#20, salary_change.keyword{f}#21, salary_change.long{f}#22, still_hired{f}#23] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testSort/load/analysis.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testSort/load/analysis.expected index 441f28eeb2c20..fd2ab06e624be 100644 --- a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testSort/load/analysis.expected +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testSort/load/analysis.expected @@ -1,3 +1,3 @@ Limit[1000[INTEGER],false,false] -\_OrderBy[[Order[does_not_exist{f}#0,ASC,LAST]]] +\_OrderBy[[Order[does_not_exist{f(PotentiallyUnmappedKeywordEsField)}#0,ASC,LAST]]] \_EsRelation[employees][avg_worked_seconds{f}#1, birth_date{f}#2, emp_no{f}#3, first_name{f}#4, gender{f}#5, height{f}#6, height.float{f}#7, height.half_float{f}#8, height.scaled_float{f}#9, hire_date{f}#10, is_rehired{f}#11, job_positions{f}#12, languages{f}#13, languages.byte{f}#14, languages.long{f}#15, languages.short{f}#16, last_name{f}#17, salary{f}#18, salary_change{f}#19, salary_change.int{f}#20, salary_change.keyword{f}#21, salary_change.long{f}#22, still_hired{f}#23, does_not_exist{f}#0] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testSortMultiple/load/analysis.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testSortMultiple/load/analysis.expected index 663bca06a5e21..b6e10e3bc15c1 100644 --- a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testSortMultiple/load/analysis.expected +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testSortMultiple/load/analysis.expected @@ -1,3 +1,3 @@ Limit[1000[INTEGER],false,false] -\_OrderBy[[Order[TOLONG(does_not_exist1{f}#0) + 1[INTEGER],ASC,LAST], Order[does_not_exist2{f}#1,DESC,FIRST], Order[emp_no{f}#2,ASC,LAST]]] +\_OrderBy[[Order[TOLONG(does_not_exist1{f}#0) + 1[INTEGER],ASC,LAST], Order[does_not_exist2{f(PotentiallyUnmappedKeywordEsField)}#1,DESC,FIRST], Order[emp_no{f(EsField)}#2,ASC,LAST]]] \_EsRelation[employees][avg_worked_seconds{f}#3, birth_date{f}#4, emp_no{f}#2, first_name{f}#5, gender{f}#6, height{f}#7, height.float{f}#8, height.half_float{f}#9, height.scaled_float{f}#10, hire_date{f}#11, is_rehired{f}#12, job_positions{f}#13, languages{f}#14, languages.byte{f}#15, languages.long{f}#16, languages.short{f}#17, last_name{f}#18, salary{f}#19, salary_change{f}#20, salary_change.int{f}#21, salary_change.keyword{f}#22, salary_change.long{f}#23, still_hired{f}#24, does_not_exist1{f}#0, does_not_exist2{f}#1] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testSortMultiple/nullify/analysis.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testSortMultiple/nullify/analysis.expected index f57ed4d6c6fda..272402c1c32eb 100644 --- a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testSortMultiple/nullify/analysis.expected +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testSortMultiple/nullify/analysis.expected @@ -1,4 +1,4 @@ Limit[1000[INTEGER],false,false] -\_OrderBy[[Order[TOLONG(does_not_exist1{r}#0) + 1[INTEGER],ASC,LAST], Order[does_not_exist2{r}#1,DESC,FIRST], Order[emp_no{f}#2,ASC,LAST]]] +\_OrderBy[[Order[TOLONG(does_not_exist1{r}#0) + 1[INTEGER],ASC,LAST], Order[does_not_exist2{r}#1,DESC,FIRST], Order[emp_no{f(EsField)}#2,ASC,LAST]]] \_Eval[[null[NULL] AS does_not_exist1#0, null[NULL] AS does_not_exist2#1]] \_EsRelation[employees][avg_worked_seconds{f}#3, birth_date{f}#4, emp_no{f}#2, first_name{f}#5, gender{f}#6, height{f}#7, height.float{f}#8, height.half_float{f}#9, height.scaled_float{f}#10, hire_date{f}#11, is_rehired{f}#12, job_positions{f}#13, languages{f}#14, languages.byte{f}#15, languages.long{f}#16, languages.short{f}#17, last_name{f}#18, salary{f}#19, salary_change{f}#20, salary_change.int{f}#21, salary_change.keyword{f}#22, salary_change.long{f}#23, still_hired{f}#24] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testStatsBy/load/analysis.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testStatsBy/load/analysis.expected index 1b58079c3c0e9..72036927b0717 100644 --- a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testStatsBy/load/analysis.expected +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testStatsBy/load/analysis.expected @@ -1,3 +1,3 @@ Limit[1000[INTEGER],false,false] -\_Aggregate[[does_not_exist_field{f}#0],[does_not_exist_field{f}#0]] +\_Aggregate[[does_not_exist_field{f(PotentiallyUnmappedKeywordEsField)}#0],[does_not_exist_field{f(PotentiallyUnmappedKeywordEsField)}#0]] \_EsRelation[employees][avg_worked_seconds{f}#1, birth_date{f}#2, emp_no{f}#3, first_name{f}#4, gender{f}#5, height{f}#6, height.float{f}#7, height.half_float{f}#8, height.scaled_float{f}#9, hire_date{f}#10, is_rehired{f}#11, job_positions{f}#12, languages{f}#13, languages.byte{f}#14, languages.long{f}#15, languages.short{f}#16, last_name{f}#17, salary{f}#18, salary_change{f}#19, salary_change.int{f}#20, salary_change.keyword{f}#21, salary_change.long{f}#22, still_hired{f}#23, does_not_exist_field{f}#0] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testStatsCount/load/analysis.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testStatsCount/load/analysis.expected index 456247586e3be..4266a433ba529 100644 --- a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testStatsCount/load/analysis.expected +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testStatsCount/load/analysis.expected @@ -1,3 +1,3 @@ Limit[1000[INTEGER],false,false] -\_Aggregate[[],[COUNT(does_not_exist_field{f}#0,true[BOOLEAN],PT0S[TIME_DURATION]) AS cnt#1]] +\_Aggregate[[],[COUNT(does_not_exist_field{f(PotentiallyUnmappedKeywordEsField)}#0,true[BOOLEAN],PT0S[TIME_DURATION]) AS cnt#1]] \_EsRelation[employees][avg_worked_seconds{f}#2, birth_date{f}#3, emp_no{f}#4, first_name{f}#5, gender{f}#6, height{f}#7, height.float{f}#8, height.half_float{f}#9, height.scaled_float{f}#10, hire_date{f}#11, is_rehired{f}#12, job_positions{f}#13, languages{f}#14, languages.byte{f}#15, languages.long{f}#16, languages.short{f}#17, last_name{f}#18, salary{f}#19, salary_change{f}#20, salary_change.int{f}#21, salary_change.keyword{f}#22, salary_change.long{f}#23, still_hired{f}#24, does_not_exist_field{f}#0] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testStatsMultiple/load/analysis.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testStatsMultiple/load/analysis.expected index 860ec580b8dd8..20e247409cc03 100644 --- a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testStatsMultiple/load/analysis.expected +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testStatsMultiple/load/analysis.expected @@ -1,3 +1,3 @@ Limit[1000[INTEGER],false,false] -\_Aggregate[[does_not_exist2{f}#0, emp_no{f}#1],[SUM(TODOUBLE(does_not_exist1{f}#2),true[BOOLEAN],PT0S[TIME_DURATION],compensated[KEYWORD]) AS s#3, COUNT(*[KEYWORD],true[BOOLEAN],PT0S[TIME_DURATION]) AS c#4, does_not_exist2{f}#0, emp_no{f}#1]] +\_Aggregate[[does_not_exist2{f(PotentiallyUnmappedKeywordEsField)}#0, emp_no{f(EsField)}#1],[SUM(TODOUBLE(does_not_exist1{f(PotentiallyUnmappedKeywordEsField)}#2),true[BOOLEAN],PT0S[TIME_DURATION],compensated[KEYWORD]) AS s#3, COUNT(*[KEYWORD],true[BOOLEAN],PT0S[TIME_DURATION]) AS c#4, does_not_exist2{f(PotentiallyUnmappedKeywordEsField)}#0, emp_no{f(EsField)}#1]] \_EsRelation[employees][avg_worked_seconds{f}#5, birth_date{f}#6, emp_no{f}#1, first_name{f}#7, gender{f}#8, height{f}#9, height.float{f}#10, height.half_float{f}#11, height.scaled_float{f}#12, hire_date{f}#13, is_rehired{f}#14, job_positions{f}#15, languages{f}#16, languages.byte{f}#17, languages.long{f}#18, languages.short{f}#19, last_name{f}#20, salary{f}#21, salary_change{f}#22, salary_change.int{f}#23, salary_change.keyword{f}#24, salary_change.long{f}#25, still_hired{f}#26, does_not_exist2{f}#0, does_not_exist1{f}#2] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testStatsMultiple/nullify/analysis.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testStatsMultiple/nullify/analysis.expected index 3bd26f310af82..4e82f82142c41 100644 --- a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testStatsMultiple/nullify/analysis.expected +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testStatsMultiple/nullify/analysis.expected @@ -1,4 +1,4 @@ Limit[1000[INTEGER],false,false] -\_Aggregate[[does_not_exist2{r}#0, emp_no{f}#1],[SUM(TODOUBLE(does_not_exist1{r}#2),true[BOOLEAN],PT0S[TIME_DURATION],compensated[KEYWORD]) AS s#3, COUNT(*[KEYWORD],true[BOOLEAN],PT0S[TIME_DURATION]) AS c#4, does_not_exist2{r}#0, emp_no{f}#1]] +\_Aggregate[[does_not_exist2{r}#0, emp_no{f(EsField)}#1],[SUM(TODOUBLE(does_not_exist1{r}#2),true[BOOLEAN],PT0S[TIME_DURATION],compensated[KEYWORD]) AS s#3, COUNT(*[KEYWORD],true[BOOLEAN],PT0S[TIME_DURATION]) AS c#4, does_not_exist2{r}#0, emp_no{f(EsField)}#1]] \_Eval[[null[NULL] AS does_not_exist2#0, null[NULL] AS does_not_exist1#2]] \_EsRelation[employees][avg_worked_seconds{f}#5, birth_date{f}#6, emp_no{f}#1, first_name{f}#7, gender{f}#8, height{f}#9, height.float{f}#10, height.half_float{f}#11, height.scaled_float{f}#12, hire_date{f}#13, is_rehired{f}#14, job_positions{f}#15, languages{f}#16, languages.byte{f}#17, languages.long{f}#18, languages.short{f}#19, last_name{f}#20, salary{f}#21, salary_change{f}#22, salary_change.int{f}#23, salary_change.keyword{f}#24, salary_change.long{f}#25, still_hired{f}#26] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testStatsMultipleCountWhere/load/analysis.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testStatsMultipleCountWhere/load/analysis.expected index a4fbd276de29c..de76cbb9a017a 100644 --- a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testStatsMultipleCountWhere/load/analysis.expected +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testStatsMultipleCountWhere/load/analysis.expected @@ -1,3 +1,3 @@ Limit[1000[INTEGER],false,false] -\_Aggregate[[],[FilteredExpression[COUNT(*[KEYWORD],true[BOOLEAN],PT0S[TIME_DURATION]),TOLONG(does_not_exist1{f}#0) > 0[INTEGER] OR emp_no{f}#1 > 0[INTEGER] OR TOLONG(does_not_exist2{f}#2) < 100[INTEGER]] AS c1#3, FilteredExpression[COUNT(*[KEYWORD],true[BOOLEAN],PT0S[TIME_DURATION]),ISNULL(does_not_exist3{f}#4)] AS c2#5]] +\_Aggregate[[],[FilteredExpression[COUNT(*[KEYWORD],true[BOOLEAN],PT0S[TIME_DURATION]),TOLONG(does_not_exist1{f}#0) > 0[INTEGER] OR emp_no{f}#1 > 0[INTEGER] OR TOLONG(does_not_exist2{f}#2) < 100[INTEGER]] AS c1#3, FilteredExpression[COUNT(*[KEYWORD],true[BOOLEAN],PT0S[TIME_DURATION]),ISNULL(does_not_exist3{f(PotentiallyUnmappedKeywordEsField)}#4)] AS c2#5]] \_EsRelation[employees][avg_worked_seconds{f}#6, birth_date{f}#7, emp_no{f}#1, first_name{f}#8, gender{f}#9, height{f}#10, height.float{f}#11, height.half_float{f}#12, height.scaled_float{f}#13, hire_date{f}#14, is_rehired{f}#15, job_positions{f}#16, languages{f}#17, languages.byte{f}#18, languages.long{f}#19, languages.short{f}#20, last_name{f}#21, salary{f}#22, salary_change{f}#23, salary_change.int{f}#24, salary_change.keyword{f}#25, salary_change.long{f}#26, still_hired{f}#27, does_not_exist1{f}#0, does_not_exist2{f}#2, does_not_exist3{f}#4] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testStatsSumBy/load/analysis.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testStatsSumBy/load/analysis.expected index 27b179dff2e21..3da6706296c63 100644 --- a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testStatsSumBy/load/analysis.expected +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testStatsSumBy/load/analysis.expected @@ -1,3 +1,3 @@ Limit[1000[INTEGER],false,false] -\_Aggregate[[does_not_exist2{f}#0],[SUM(TODOUBLE(does_not_exist1{f}#1),true[BOOLEAN],PT0S[TIME_DURATION],compensated[KEYWORD]) AS s#2, does_not_exist2{f}#0]] +\_Aggregate[[does_not_exist2{f(PotentiallyUnmappedKeywordEsField)}#0],[SUM(TODOUBLE(does_not_exist1{f(PotentiallyUnmappedKeywordEsField)}#1),true[BOOLEAN],PT0S[TIME_DURATION],compensated[KEYWORD]) AS s#2, does_not_exist2{f(PotentiallyUnmappedKeywordEsField)}#0]] \_EsRelation[employees][avg_worked_seconds{f}#3, birth_date{f}#4, emp_no{f}#5, first_name{f}#6, gender{f}#7, height{f}#8, height.float{f}#9, height.half_float{f}#10, height.scaled_float{f}#11, hire_date{f}#12, is_rehired{f}#13, job_positions{f}#14, languages{f}#15, languages.byte{f}#16, languages.long{f}#17, languages.short{f}#18, last_name{f}#19, salary{f}#20, salary_change{f}#21, salary_change.int{f}#22, salary_change.keyword{f}#23, salary_change.long{f}#24, still_hired{f}#25, does_not_exist2{f}#0, does_not_exist1{f}#1] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testStatsSumByComplex/load/analysis.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testStatsSumByComplex/load/analysis.expected index 021eab43d5186..f8c89887de2f8 100644 --- a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testStatsSumByComplex/load/analysis.expected +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testStatsSumByComplex/load/analysis.expected @@ -1,3 +1,3 @@ Limit[1000[INTEGER],false,false] -\_Aggregate[[TODOUBLE(does_not_exist2{f}#0) + TODOUBLE(does_not_exist3{f}#1) AS s0#2, emp_no{f}#3 AS s1#4],[SUM(TODOUBLE(does_not_exist1{f}#5),true[BOOLEAN],PT0S[TIME_DURATION],compensated[KEYWORD]) + s0{r}#2 + s1{r}#4 AS sum#6, s0{r}#2, s1{r}#4]] +\_Aggregate[[TODOUBLE(does_not_exist2{f}#0) + TODOUBLE(does_not_exist3{f}#1) AS s0#2, emp_no{f(EsField)}#3 AS s1#4],[SUM(TODOUBLE(does_not_exist1{f}#5),true[BOOLEAN],PT0S[TIME_DURATION],compensated[KEYWORD]) + s0{r}#2 + s1{r}#4 AS sum#6, s0{r}#2, s1{r}#4]] \_EsRelation[employees][avg_worked_seconds{f}#7, birth_date{f}#8, emp_no{f}#3, first_name{f}#9, gender{f}#10, height{f}#11, height.float{f}#12, height.half_float{f}#13, height.scaled_float{f}#14, hire_date{f}#15, is_rehired{f}#16, job_positions{f}#17, languages{f}#18, languages.byte{f}#19, languages.long{f}#20, languages.short{f}#21, last_name{f}#22, salary{f}#23, salary_change{f}#24, salary_change.int{f}#25, salary_change.keyword{f}#26, salary_change.long{f}#27, still_hired{f}#28, does_not_exist2{f}#0, does_not_exist3{f}#1, does_not_exist1{f}#5, s0{f}#29] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testStatsSumByComplex/nullify/analysis.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testStatsSumByComplex/nullify/analysis.expected index a877b9d0f0588..f324c6cc494bb 100644 --- a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testStatsSumByComplex/nullify/analysis.expected +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testStatsSumByComplex/nullify/analysis.expected @@ -1,4 +1,4 @@ Limit[1000[INTEGER],false,false] -\_Aggregate[[TODOUBLE(does_not_exist2{r}#0) + TODOUBLE(does_not_exist3{r}#1) AS s0#2, emp_no{f}#3 AS s1#4],[SUM(TODOUBLE(does_not_exist1{r}#5),true[BOOLEAN],PT0S[TIME_DURATION],compensated[KEYWORD]) + s0{r}#2 + s1{r}#4 AS sum#6, s0{r}#2, s1{r}#4]] +\_Aggregate[[TODOUBLE(does_not_exist2{r}#0) + TODOUBLE(does_not_exist3{r}#1) AS s0#2, emp_no{f(EsField)}#3 AS s1#4],[SUM(TODOUBLE(does_not_exist1{r}#5),true[BOOLEAN],PT0S[TIME_DURATION],compensated[KEYWORD]) + s0{r}#2 + s1{r}#4 AS sum#6, s0{r}#2, s1{r}#4]] \_Eval[[null[NULL] AS does_not_exist2#0, null[NULL] AS does_not_exist3#1, null[NULL] AS does_not_exist1#5, null[NULL] AS s0#7]] \_EsRelation[employees][avg_worked_seconds{f}#8, birth_date{f}#9, emp_no{f}#3, first_name{f}#10, gender{f}#11, height{f}#12, height.float{f}#13, height.half_float{f}#14, height.scaled_float{f}#15, hire_date{f}#16, is_rehired{f}#17, job_positions{f}#18, languages{f}#19, languages.byte{f}#20, languages.long{f}#21, languages.short{f}#22, last_name{f}#23, salary{f}#24, salary_change{f}#25, salary_change.int{f}#26, salary_change.keyword{f}#27, salary_change.long{f}#28, still_hired{f}#29] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testStatsSumByMultiple/load/analysis.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testStatsSumByMultiple/load/analysis.expected index 2ad8609f9bac6..441d733d2e22d 100644 --- a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testStatsSumByMultiple/load/analysis.expected +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testStatsSumByMultiple/load/analysis.expected @@ -1,3 +1,3 @@ Limit[1000[INTEGER],false,false] -\_Aggregate[[TODOUBLE(does_not_exist2{f}#0) AS d2#1, emp_no{f}#2],[SUM(TODOUBLE(does_not_exist1{f}#3),true[BOOLEAN],PT0S[TIME_DURATION],compensated[KEYWORD]) + d2{r}#1 AS s#4, d2{r}#1, emp_no{f}#2]] +\_Aggregate[[TODOUBLE(does_not_exist2{f(PotentiallyUnmappedKeywordEsField)}#0) AS d2#1, emp_no{f(EsField)}#2],[SUM(TODOUBLE(does_not_exist1{f}#3),true[BOOLEAN],PT0S[TIME_DURATION],compensated[KEYWORD]) + d2{r}#1 AS s#4, d2{r}#1, emp_no{f(EsField)}#2]] \_EsRelation[employees][avg_worked_seconds{f}#5, birth_date{f}#6, emp_no{f}#2, first_name{f}#7, gender{f}#8, height{f}#9, height.float{f}#10, height.half_float{f}#11, height.scaled_float{f}#12, hire_date{f}#13, is_rehired{f}#14, job_positions{f}#15, languages{f}#16, languages.byte{f}#17, languages.long{f}#18, languages.short{f}#19, last_name{f}#20, salary{f}#21, salary_change{f}#22, salary_change.int{f}#23, salary_change.keyword{f}#24, salary_change.long{f}#25, still_hired{f}#26, does_not_exist2{f}#0, does_not_exist1{f}#3, d2{f}#27] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testStatsSumByMultiple/nullify/analysis.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testStatsSumByMultiple/nullify/analysis.expected index f06e76b90283d..bcfbad0e4899c 100644 --- a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testStatsSumByMultiple/nullify/analysis.expected +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testStatsSumByMultiple/nullify/analysis.expected @@ -1,4 +1,4 @@ Limit[1000[INTEGER],false,false] -\_Aggregate[[TODOUBLE(does_not_exist2{r}#0) AS d2#1, emp_no{f}#2],[SUM(TODOUBLE(does_not_exist1{r}#3),true[BOOLEAN],PT0S[TIME_DURATION],compensated[KEYWORD]) + d2{r}#1 AS s#4, d2{r}#1, emp_no{f}#2]] +\_Aggregate[[TODOUBLE(does_not_exist2{r}#0) AS d2#1, emp_no{f(EsField)}#2],[SUM(TODOUBLE(does_not_exist1{r}#3),true[BOOLEAN],PT0S[TIME_DURATION],compensated[KEYWORD]) + d2{r}#1 AS s#4, d2{r}#1, emp_no{f(EsField)}#2]] \_Eval[[null[NULL] AS does_not_exist2#0, null[NULL] AS does_not_exist1#3, null[NULL] AS d2#5]] \_EsRelation[employees][avg_worked_seconds{f}#6, birth_date{f}#7, emp_no{f}#2, first_name{f}#8, gender{f}#9, height{f}#10, height.float{f}#11, height.half_float{f}#12, height.scaled_float{f}#13, hire_date{f}#14, is_rehired{f}#15, job_positions{f}#16, languages{f}#17, languages.byte{f}#18, languages.long{f}#19, languages.short{f}#20, last_name{f}#21, salary{f}#22, salary_change{f}#23, salary_change.int{f}#24, salary_change.keyword{f}#25, salary_change.long{f}#26, still_hired{f}#27] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testSubqueryKeepMultipleUnmapped/load/analysis.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testSubqueryKeepMultipleUnmapped/load/analysis.expected index d6b8d29c43430..5c3d84282236b 100644 --- a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testSubqueryKeepMultipleUnmapped/load/analysis.expected +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testSubqueryKeepMultipleUnmapped/load/analysis.expected @@ -1,11 +1,11 @@ Limit[1000[INTEGER],false,false] \_Project[[emp_no{r}#0, language_code{r}#1, unmapped1{r}#2, unmapped2{r}#3]] \_UnionAll[[avg_worked_seconds{r}#4, birth_date{r}#5, emp_no{r}#0, first_name{r}#6, gender{r}#7, height{r}#8, height.float{r}#9, height.half_float{r}#10, height.scaled_float{r}#11, hire_date{r}#12, is_rehired{r}#13, job_positions{r}#14, languages{r}#15, languages.byte{r}#16, languages.long{r}#17, languages.short{r}#18, last_name{r}#19, salary{r}#20, salary_change{r}#21, salary_change.int{r}#22, salary_change.keyword{r}#23, salary_change.long{r}#24, still_hired{r}#25, language_code{r}#1, unmapped1{r}#2, unmapped2{r}#3]] - |_Project[[avg_worked_seconds{f}#26, birth_date{f}#27, emp_no{f}#28, first_name{f}#29, gender{f}#30, height{f}#31, height.float{f}#32, height.half_float{f}#33, height.scaled_float{f}#34, hire_date{f}#35, is_rehired{f}#36, job_positions{f}#37, languages{f}#38, languages.byte{f}#39, languages.long{f}#40, languages.short{f}#41, last_name{f}#42, salary{f}#43, salary_change{f}#44, salary_change.int{f}#45, salary_change.keyword{f}#46, salary_change.long{f}#47, still_hired{f}#48, language_code{r}#49, unmapped1{r}#50, unmapped2{r}#51]] + |_Project[[avg_worked_seconds{f(EsField)}#26, birth_date{f(DateEsField)}#27, emp_no{f(EsField)}#28, first_name{f(KeywordEsField)}#29, gender{f(KeywordEsField)}#30, height{f(EsField)}#31, height.float{f(EsField)}#32, height.half_float{f(EsField)}#33, height.scaled_float{f(EsField)}#34, hire_date{f(DateEsField)}#35, is_rehired{f(EsField)}#36, job_positions{f(KeywordEsField)}#37, languages{f(EsField)}#38, languages.byte{f(EsField)}#39, languages.long{f(EsField)}#40, languages.short{f(EsField)}#41, last_name{f(KeywordEsField)}#42, salary{f(EsField)}#43, salary_change{f(EsField)}#44, salary_change.int{f(EsField)}#45, salary_change.keyword{f(KeywordEsField)}#46, salary_change.long{f(EsField)}#47, still_hired{f(EsField)}#48, language_code{r}#49, unmapped1{r}#50, unmapped2{r}#51]] | \_Eval[[null[INTEGER] AS language_code#49, null[KEYWORD] AS unmapped1#50, null[KEYWORD] AS unmapped2#51]] | \_EsRelation[employees][avg_worked_seconds{f}#26, birth_date{f}#27, emp_no{f}#28, first_name{f}#29, gender{f}#30, height{f}#31, height.float{f}#32, height.half_float{f}#33, height.scaled_float{f}#34, hire_date{f}#35, is_rehired{f}#36, job_positions{f}#37, languages{f}#38, languages.byte{f}#39, languages.long{f}#40, languages.short{f}#41, last_name{f}#42, salary{f}#43, salary_change{f}#44, salary_change.int{f}#45, salary_change.keyword{f}#46, salary_change.long{f}#47, still_hired{f}#48] - \_Project[[avg_worked_seconds{r}#52, birth_date{r}#53, emp_no{r}#54, first_name{r}#55, gender{r}#56, height{r}#57, height.float{r}#58, height.half_float{r}#59, height.scaled_float{r}#60, hire_date{r}#61, is_rehired{r}#62, job_positions{r}#63, languages{r}#64, languages.byte{r}#65, languages.long{r}#66, languages.short{r}#67, last_name{r}#68, salary{r}#69, salary_change{r}#70, salary_change.int{r}#71, salary_change.keyword{r}#72, salary_change.long{r}#73, still_hired{r}#74, language_code{f}#75, unmapped1{f}#76, unmapped2{f}#77]] + \_Project[[avg_worked_seconds{r}#52, birth_date{r}#53, emp_no{r}#54, first_name{r}#55, gender{r}#56, height{r}#57, height.float{r}#58, height.half_float{r}#59, height.scaled_float{r}#60, hire_date{r}#61, is_rehired{r}#62, job_positions{r}#63, languages{r}#64, languages.byte{r}#65, languages.long{r}#66, languages.short{r}#67, last_name{r}#68, salary{r}#69, salary_change{r}#70, salary_change.int{r}#71, salary_change.keyword{r}#72, salary_change.long{r}#73, still_hired{r}#74, language_code{f(EsField)}#75, unmapped1{f(PotentiallyUnmappedKeywordEsField)}#76, unmapped2{f(PotentiallyUnmappedKeywordEsField)}#77]] \_Eval[[null[LONG] AS avg_worked_seconds#52, null[DATETIME] AS birth_date#53, null[INTEGER] AS emp_no#54, null[KEYWORD] AS first_name#55, null[KEYWORD] AS gender#56, null[DOUBLE] AS height#57, null[DOUBLE] AS height.float#58, null[DOUBLE] AS height.half_float#59, null[DOUBLE] AS height.scaled_float#60, null[DATETIME] AS hire_date#61, null[BOOLEAN] AS is_rehired#62, null[KEYWORD] AS job_positions#63, null[INTEGER] AS languages#64, null[INTEGER] AS languages.byte#65, null[LONG] AS languages.long#66, null[INTEGER] AS languages.short#67, null[KEYWORD] AS last_name#68, null[INTEGER] AS salary#69, null[DOUBLE] AS salary_change#70, null[INTEGER] AS salary_change.int#71, null[KEYWORD] AS salary_change.keyword#72, null[LONG] AS salary_change.long#73, null[BOOLEAN] AS still_hired#74]] \_Subquery[] - \_Project[[language_code{f}#75, unmapped1{f}#76, unmapped2{f}#77]] + \_Project[[language_code{f(EsField)}#75, unmapped1{f(PotentiallyUnmappedKeywordEsField)}#76, unmapped2{f(PotentiallyUnmappedKeywordEsField)}#77]] \_EsRelation[languages][language_code{f}#75, language_name{f}#78, unmapped1{f}#76, unmapped2{f}#77] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testSubqueryKeepMultipleUnmapped/nullify/analysis.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testSubqueryKeepMultipleUnmapped/nullify/analysis.expected index 5edcc387fc727..12cb504aaa345 100644 --- a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testSubqueryKeepMultipleUnmapped/nullify/analysis.expected +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testSubqueryKeepMultipleUnmapped/nullify/analysis.expected @@ -1,12 +1,12 @@ Limit[1000[INTEGER],false,false] \_Project[[emp_no{r}#0, language_code{r}#1, unmapped1{r}#2, unmapped2{r}#3]] \_UnionAll[[avg_worked_seconds{r}#4, birth_date{r}#5, emp_no{r}#0, first_name{r}#6, gender{r}#7, height{r}#8, height.float{r}#9, height.half_float{r}#10, height.scaled_float{r}#11, hire_date{r}#12, is_rehired{r}#13, job_positions{r}#14, languages{r}#15, languages.byte{r}#16, languages.long{r}#17, languages.short{r}#18, last_name{r}#19, salary{r}#20, salary_change{r}#21, salary_change.int{r}#22, salary_change.keyword{r}#23, salary_change.long{r}#24, still_hired{r}#25, language_code{r}#1, unmapped1{r}#2, unmapped2{r}#3]] - |_Project[[avg_worked_seconds{f}#26, birth_date{f}#27, emp_no{f}#28, first_name{f}#29, gender{f}#30, height{f}#31, height.float{f}#32, height.half_float{f}#33, height.scaled_float{f}#34, hire_date{f}#35, is_rehired{f}#36, job_positions{f}#37, languages{f}#38, languages.byte{f}#39, languages.long{f}#40, languages.short{f}#41, last_name{f}#42, salary{f}#43, salary_change{f}#44, salary_change.int{f}#45, salary_change.keyword{f}#46, salary_change.long{f}#47, still_hired{f}#48, language_code{r}#49, unmapped1{r}#50, unmapped2{r}#51]] + |_Project[[avg_worked_seconds{f(EsField)}#26, birth_date{f(DateEsField)}#27, emp_no{f(EsField)}#28, first_name{f(KeywordEsField)}#29, gender{f(KeywordEsField)}#30, height{f(EsField)}#31, height.float{f(EsField)}#32, height.half_float{f(EsField)}#33, height.scaled_float{f(EsField)}#34, hire_date{f(DateEsField)}#35, is_rehired{f(EsField)}#36, job_positions{f(KeywordEsField)}#37, languages{f(EsField)}#38, languages.byte{f(EsField)}#39, languages.long{f(EsField)}#40, languages.short{f(EsField)}#41, last_name{f(KeywordEsField)}#42, salary{f(EsField)}#43, salary_change{f(EsField)}#44, salary_change.int{f(EsField)}#45, salary_change.keyword{f(KeywordEsField)}#46, salary_change.long{f(EsField)}#47, still_hired{f(EsField)}#48, language_code{r}#49, unmapped1{r}#50, unmapped2{r}#51]] | \_Eval[[null[INTEGER] AS language_code#49, null[NULL] AS unmapped1#50, null[NULL] AS unmapped2#51]] | \_EsRelation[employees][avg_worked_seconds{f}#26, birth_date{f}#27, emp_no{f}#28, first_name{f}#29, gender{f}#30, height{f}#31, height.float{f}#32, height.half_float{f}#33, height.scaled_float{f}#34, hire_date{f}#35, is_rehired{f}#36, job_positions{f}#37, languages{f}#38, languages.byte{f}#39, languages.long{f}#40, languages.short{f}#41, last_name{f}#42, salary{f}#43, salary_change{f}#44, salary_change.int{f}#45, salary_change.keyword{f}#46, salary_change.long{f}#47, still_hired{f}#48] - \_Project[[avg_worked_seconds{r}#52, birth_date{r}#53, emp_no{r}#54, first_name{r}#55, gender{r}#56, height{r}#57, height.float{r}#58, height.half_float{r}#59, height.scaled_float{r}#60, hire_date{r}#61, is_rehired{r}#62, job_positions{r}#63, languages{r}#64, languages.byte{r}#65, languages.long{r}#66, languages.short{r}#67, last_name{r}#68, salary{r}#69, salary_change{r}#70, salary_change.int{r}#71, salary_change.keyword{r}#72, salary_change.long{r}#73, still_hired{r}#74, language_code{f}#75, unmapped1{r}#76, unmapped2{r}#77]] + \_Project[[avg_worked_seconds{r}#52, birth_date{r}#53, emp_no{r}#54, first_name{r}#55, gender{r}#56, height{r}#57, height.float{r}#58, height.half_float{r}#59, height.scaled_float{r}#60, hire_date{r}#61, is_rehired{r}#62, job_positions{r}#63, languages{r}#64, languages.byte{r}#65, languages.long{r}#66, languages.short{r}#67, last_name{r}#68, salary{r}#69, salary_change{r}#70, salary_change.int{r}#71, salary_change.keyword{r}#72, salary_change.long{r}#73, still_hired{r}#74, language_code{f(EsField)}#75, unmapped1{r}#76, unmapped2{r}#77]] \_Eval[[null[LONG] AS avg_worked_seconds#52, null[DATETIME] AS birth_date#53, null[INTEGER] AS emp_no#54, null[KEYWORD] AS first_name#55, null[KEYWORD] AS gender#56, null[DOUBLE] AS height#57, null[DOUBLE] AS height.float#58, null[DOUBLE] AS height.half_float#59, null[DOUBLE] AS height.scaled_float#60, null[DATETIME] AS hire_date#61, null[BOOLEAN] AS is_rehired#62, null[KEYWORD] AS job_positions#63, null[INTEGER] AS languages#64, null[INTEGER] AS languages.byte#65, null[LONG] AS languages.long#66, null[INTEGER] AS languages.short#67, null[KEYWORD] AS last_name#68, null[INTEGER] AS salary#69, null[DOUBLE] AS salary_change#70, null[INTEGER] AS salary_change.int#71, null[KEYWORD] AS salary_change.keyword#72, null[LONG] AS salary_change.long#73, null[BOOLEAN] AS still_hired#74]] \_Subquery[] - \_Project[[language_code{f}#75, unmapped1{r}#76, unmapped2{r}#77]] + \_Project[[language_code{f(EsField)}#75, unmapped1{r}#76, unmapped2{r}#77]] \_Eval[[null[NULL] AS unmapped1#76, null[NULL] AS unmapped2#77]] \_EsRelation[languages][language_code{f}#75, language_name{f}#78] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testSubqueryKeepUnmapped/load/analysis.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testSubqueryKeepUnmapped/load/analysis.expected index 0f0fb589b8c87..b4452dd003c30 100644 --- a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testSubqueryKeepUnmapped/load/analysis.expected +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testSubqueryKeepUnmapped/load/analysis.expected @@ -1,11 +1,11 @@ Limit[1000[INTEGER],false,false] \_Project[[emp_no{r}#0, language_code{r}#1, does_not_exist{r}#2]] \_UnionAll[[avg_worked_seconds{r}#3, birth_date{r}#4, emp_no{r}#0, first_name{r}#5, gender{r}#6, height{r}#7, height.float{r}#8, height.half_float{r}#9, height.scaled_float{r}#10, hire_date{r}#11, is_rehired{r}#12, job_positions{r}#13, languages{r}#14, languages.byte{r}#15, languages.long{r}#16, languages.short{r}#17, last_name{r}#18, salary{r}#19, salary_change{r}#20, salary_change.int{r}#21, salary_change.keyword{r}#22, salary_change.long{r}#23, still_hired{r}#24, language_code{r}#1, does_not_exist{r}#2]] - |_Project[[avg_worked_seconds{f}#25, birth_date{f}#26, emp_no{f}#27, first_name{f}#28, gender{f}#29, height{f}#30, height.float{f}#31, height.half_float{f}#32, height.scaled_float{f}#33, hire_date{f}#34, is_rehired{f}#35, job_positions{f}#36, languages{f}#37, languages.byte{f}#38, languages.long{f}#39, languages.short{f}#40, last_name{f}#41, salary{f}#42, salary_change{f}#43, salary_change.int{f}#44, salary_change.keyword{f}#45, salary_change.long{f}#46, still_hired{f}#47, language_code{r}#48, does_not_exist{r}#49]] + |_Project[[avg_worked_seconds{f(EsField)}#25, birth_date{f(DateEsField)}#26, emp_no{f(EsField)}#27, first_name{f(KeywordEsField)}#28, gender{f(KeywordEsField)}#29, height{f(EsField)}#30, height.float{f(EsField)}#31, height.half_float{f(EsField)}#32, height.scaled_float{f(EsField)}#33, hire_date{f(DateEsField)}#34, is_rehired{f(EsField)}#35, job_positions{f(KeywordEsField)}#36, languages{f(EsField)}#37, languages.byte{f(EsField)}#38, languages.long{f(EsField)}#39, languages.short{f(EsField)}#40, last_name{f(KeywordEsField)}#41, salary{f(EsField)}#42, salary_change{f(EsField)}#43, salary_change.int{f(EsField)}#44, salary_change.keyword{f(KeywordEsField)}#45, salary_change.long{f(EsField)}#46, still_hired{f(EsField)}#47, language_code{r}#48, does_not_exist{r}#49]] | \_Eval[[null[INTEGER] AS language_code#48, null[KEYWORD] AS does_not_exist#49]] | \_EsRelation[employees][avg_worked_seconds{f}#25, birth_date{f}#26, emp_no{f}#27, first_name{f}#28, gender{f}#29, height{f}#30, height.float{f}#31, height.half_float{f}#32, height.scaled_float{f}#33, hire_date{f}#34, is_rehired{f}#35, job_positions{f}#36, languages{f}#37, languages.byte{f}#38, languages.long{f}#39, languages.short{f}#40, last_name{f}#41, salary{f}#42, salary_change{f}#43, salary_change.int{f}#44, salary_change.keyword{f}#45, salary_change.long{f}#46, still_hired{f}#47] - \_Project[[avg_worked_seconds{r}#50, birth_date{r}#51, emp_no{r}#52, first_name{r}#53, gender{r}#54, height{r}#55, height.float{r}#56, height.half_float{r}#57, height.scaled_float{r}#58, hire_date{r}#59, is_rehired{r}#60, job_positions{r}#61, languages{r}#62, languages.byte{r}#63, languages.long{r}#64, languages.short{r}#65, last_name{r}#66, salary{r}#67, salary_change{r}#68, salary_change.int{r}#69, salary_change.keyword{r}#70, salary_change.long{r}#71, still_hired{r}#72, language_code{f}#73, does_not_exist{f}#74]] + \_Project[[avg_worked_seconds{r}#50, birth_date{r}#51, emp_no{r}#52, first_name{r}#53, gender{r}#54, height{r}#55, height.float{r}#56, height.half_float{r}#57, height.scaled_float{r}#58, hire_date{r}#59, is_rehired{r}#60, job_positions{r}#61, languages{r}#62, languages.byte{r}#63, languages.long{r}#64, languages.short{r}#65, last_name{r}#66, salary{r}#67, salary_change{r}#68, salary_change.int{r}#69, salary_change.keyword{r}#70, salary_change.long{r}#71, still_hired{r}#72, language_code{f(EsField)}#73, does_not_exist{f(PotentiallyUnmappedKeywordEsField)}#74]] \_Eval[[null[LONG] AS avg_worked_seconds#50, null[DATETIME] AS birth_date#51, null[INTEGER] AS emp_no#52, null[KEYWORD] AS first_name#53, null[KEYWORD] AS gender#54, null[DOUBLE] AS height#55, null[DOUBLE] AS height.float#56, null[DOUBLE] AS height.half_float#57, null[DOUBLE] AS height.scaled_float#58, null[DATETIME] AS hire_date#59, null[BOOLEAN] AS is_rehired#60, null[KEYWORD] AS job_positions#61, null[INTEGER] AS languages#62, null[INTEGER] AS languages.byte#63, null[LONG] AS languages.long#64, null[INTEGER] AS languages.short#65, null[KEYWORD] AS last_name#66, null[INTEGER] AS salary#67, null[DOUBLE] AS salary_change#68, null[INTEGER] AS salary_change.int#69, null[KEYWORD] AS salary_change.keyword#70, null[LONG] AS salary_change.long#71, null[BOOLEAN] AS still_hired#72]] \_Subquery[] - \_Project[[language_code{f}#73, does_not_exist{f}#74]] + \_Project[[language_code{f(EsField)}#73, does_not_exist{f(PotentiallyUnmappedKeywordEsField)}#74]] \_EsRelation[languages][language_code{f}#73, language_name{f}#75, does_not_exist{f}#74] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testSubqueryKeepUnmapped/nullify/analysis.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testSubqueryKeepUnmapped/nullify/analysis.expected index 37e20fe2c90c4..6efd06cbbc7de 100644 --- a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testSubqueryKeepUnmapped/nullify/analysis.expected +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testSubqueryKeepUnmapped/nullify/analysis.expected @@ -1,12 +1,12 @@ Limit[1000[INTEGER],false,false] \_Project[[emp_no{r}#0, language_code{r}#1, does_not_exist{r}#2]] \_UnionAll[[avg_worked_seconds{r}#3, birth_date{r}#4, emp_no{r}#0, first_name{r}#5, gender{r}#6, height{r}#7, height.float{r}#8, height.half_float{r}#9, height.scaled_float{r}#10, hire_date{r}#11, is_rehired{r}#12, job_positions{r}#13, languages{r}#14, languages.byte{r}#15, languages.long{r}#16, languages.short{r}#17, last_name{r}#18, salary{r}#19, salary_change{r}#20, salary_change.int{r}#21, salary_change.keyword{r}#22, salary_change.long{r}#23, still_hired{r}#24, language_code{r}#1, does_not_exist{r}#2]] - |_Project[[avg_worked_seconds{f}#25, birth_date{f}#26, emp_no{f}#27, first_name{f}#28, gender{f}#29, height{f}#30, height.float{f}#31, height.half_float{f}#32, height.scaled_float{f}#33, hire_date{f}#34, is_rehired{f}#35, job_positions{f}#36, languages{f}#37, languages.byte{f}#38, languages.long{f}#39, languages.short{f}#40, last_name{f}#41, salary{f}#42, salary_change{f}#43, salary_change.int{f}#44, salary_change.keyword{f}#45, salary_change.long{f}#46, still_hired{f}#47, language_code{r}#48, does_not_exist{r}#49]] + |_Project[[avg_worked_seconds{f(EsField)}#25, birth_date{f(DateEsField)}#26, emp_no{f(EsField)}#27, first_name{f(KeywordEsField)}#28, gender{f(KeywordEsField)}#29, height{f(EsField)}#30, height.float{f(EsField)}#31, height.half_float{f(EsField)}#32, height.scaled_float{f(EsField)}#33, hire_date{f(DateEsField)}#34, is_rehired{f(EsField)}#35, job_positions{f(KeywordEsField)}#36, languages{f(EsField)}#37, languages.byte{f(EsField)}#38, languages.long{f(EsField)}#39, languages.short{f(EsField)}#40, last_name{f(KeywordEsField)}#41, salary{f(EsField)}#42, salary_change{f(EsField)}#43, salary_change.int{f(EsField)}#44, salary_change.keyword{f(KeywordEsField)}#45, salary_change.long{f(EsField)}#46, still_hired{f(EsField)}#47, language_code{r}#48, does_not_exist{r}#49]] | \_Eval[[null[INTEGER] AS language_code#48, null[NULL] AS does_not_exist#49]] | \_EsRelation[employees][avg_worked_seconds{f}#25, birth_date{f}#26, emp_no{f}#27, first_name{f}#28, gender{f}#29, height{f}#30, height.float{f}#31, height.half_float{f}#32, height.scaled_float{f}#33, hire_date{f}#34, is_rehired{f}#35, job_positions{f}#36, languages{f}#37, languages.byte{f}#38, languages.long{f}#39, languages.short{f}#40, last_name{f}#41, salary{f}#42, salary_change{f}#43, salary_change.int{f}#44, salary_change.keyword{f}#45, salary_change.long{f}#46, still_hired{f}#47] - \_Project[[avg_worked_seconds{r}#50, birth_date{r}#51, emp_no{r}#52, first_name{r}#53, gender{r}#54, height{r}#55, height.float{r}#56, height.half_float{r}#57, height.scaled_float{r}#58, hire_date{r}#59, is_rehired{r}#60, job_positions{r}#61, languages{r}#62, languages.byte{r}#63, languages.long{r}#64, languages.short{r}#65, last_name{r}#66, salary{r}#67, salary_change{r}#68, salary_change.int{r}#69, salary_change.keyword{r}#70, salary_change.long{r}#71, still_hired{r}#72, language_code{f}#73, does_not_exist{r}#74]] + \_Project[[avg_worked_seconds{r}#50, birth_date{r}#51, emp_no{r}#52, first_name{r}#53, gender{r}#54, height{r}#55, height.float{r}#56, height.half_float{r}#57, height.scaled_float{r}#58, hire_date{r}#59, is_rehired{r}#60, job_positions{r}#61, languages{r}#62, languages.byte{r}#63, languages.long{r}#64, languages.short{r}#65, last_name{r}#66, salary{r}#67, salary_change{r}#68, salary_change.int{r}#69, salary_change.keyword{r}#70, salary_change.long{r}#71, still_hired{r}#72, language_code{f(EsField)}#73, does_not_exist{r}#74]] \_Eval[[null[LONG] AS avg_worked_seconds#50, null[DATETIME] AS birth_date#51, null[INTEGER] AS emp_no#52, null[KEYWORD] AS first_name#53, null[KEYWORD] AS gender#54, null[DOUBLE] AS height#55, null[DOUBLE] AS height.float#56, null[DOUBLE] AS height.half_float#57, null[DOUBLE] AS height.scaled_float#58, null[DATETIME] AS hire_date#59, null[BOOLEAN] AS is_rehired#60, null[KEYWORD] AS job_positions#61, null[INTEGER] AS languages#62, null[INTEGER] AS languages.byte#63, null[LONG] AS languages.long#64, null[INTEGER] AS languages.short#65, null[KEYWORD] AS last_name#66, null[INTEGER] AS salary#67, null[DOUBLE] AS salary_change#68, null[INTEGER] AS salary_change.int#69, null[KEYWORD] AS salary_change.keyword#70, null[LONG] AS salary_change.long#71, null[BOOLEAN] AS still_hired#72]] \_Subquery[] - \_Project[[language_code{f}#73, does_not_exist{r}#74]] + \_Project[[language_code{f(EsField)}#73, does_not_exist{r}#74]] \_Eval[[null[NULL] AS does_not_exist#74]] \_EsRelation[languages][language_code{f}#73, language_name{f}#75] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testSubqueryWithStats/load/analysis.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testSubqueryWithStats/load/analysis.expected index 48317bbb23980..d7d41100c00dc 100644 --- a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testSubqueryWithStats/load/analysis.expected +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testSubqueryWithStats/load/analysis.expected @@ -1,11 +1,11 @@ Limit[1000[INTEGER],false,false] \_Project[[emp_no{r}#0, max_ts{r}#1, does_not_exist{r}#2]] \_UnionAll[[avg_worked_seconds{r}#3, birth_date{r}#4, emp_no{r}#0, first_name{r}#5, gender{r}#6, height{r}#7, height.float{r}#8, height.half_float{r}#9, height.scaled_float{r}#10, hire_date{r}#11, is_rehired{r}#12, job_positions{r}#13, languages{r}#14, languages.byte{r}#15, languages.long{r}#16, languages.short{r}#17, last_name{r}#18, salary{r}#19, salary_change{r}#20, salary_change.int{r}#21, salary_change.keyword{r}#22, salary_change.long{r}#23, still_hired{r}#24, max_ts{r}#1, does_not_exist{r}#2]] - |_Project[[avg_worked_seconds{f}#25, birth_date{f}#26, emp_no{f}#27, first_name{f}#28, gender{f}#29, height{f}#30, height.float{f}#31, height.half_float{f}#32, height.scaled_float{f}#33, hire_date{f}#34, is_rehired{f}#35, job_positions{f}#36, languages{f}#37, languages.byte{f}#38, languages.long{f}#39, languages.short{f}#40, last_name{f}#41, salary{f}#42, salary_change{f}#43, salary_change.int{f}#44, salary_change.keyword{f}#45, salary_change.long{f}#46, still_hired{f}#47, max_ts{r}#48, does_not_exist{r}#49]] + |_Project[[avg_worked_seconds{f(EsField)}#25, birth_date{f(DateEsField)}#26, emp_no{f(EsField)}#27, first_name{f(KeywordEsField)}#28, gender{f(KeywordEsField)}#29, height{f(EsField)}#30, height.float{f(EsField)}#31, height.half_float{f(EsField)}#32, height.scaled_float{f(EsField)}#33, hire_date{f(DateEsField)}#34, is_rehired{f(EsField)}#35, job_positions{f(KeywordEsField)}#36, languages{f(EsField)}#37, languages.byte{f(EsField)}#38, languages.long{f(EsField)}#39, languages.short{f(EsField)}#40, last_name{f(KeywordEsField)}#41, salary{f(EsField)}#42, salary_change{f(EsField)}#43, salary_change.int{f(EsField)}#44, salary_change.keyword{f(KeywordEsField)}#45, salary_change.long{f(EsField)}#46, still_hired{f(EsField)}#47, max_ts{r}#48, does_not_exist{r}#49]] | \_Eval[[null[DATETIME] AS max_ts#48, null[KEYWORD] AS does_not_exist#49]] | \_EsRelation[employees][avg_worked_seconds{f}#25, birth_date{f}#26, emp_no{f}#27, first_name{f}#28, gender{f}#29, height{f}#30, height.float{f}#31, height.half_float{f}#32, height.scaled_float{f}#33, hire_date{f}#34, is_rehired{f}#35, job_positions{f}#36, languages{f}#37, languages.byte{f}#38, languages.long{f}#39, languages.short{f}#40, last_name{f}#41, salary{f}#42, salary_change{f}#43, salary_change.int{f}#44, salary_change.keyword{f}#45, salary_change.long{f}#46, still_hired{f}#47] - \_Project[[avg_worked_seconds{r}#50, birth_date{r}#51, emp_no{r}#52, first_name{r}#53, gender{r}#54, height{r}#55, height.float{r}#56, height.half_float{r}#57, height.scaled_float{r}#58, hire_date{r}#59, is_rehired{r}#60, job_positions{r}#61, languages{r}#62, languages.byte{r}#63, languages.long{r}#64, languages.short{r}#65, last_name{r}#66, salary{r}#67, salary_change{r}#68, salary_change.int{r}#69, salary_change.keyword{r}#70, salary_change.long{r}#71, still_hired{r}#72, max_ts{r}#73, does_not_exist{f}#74]] + \_Project[[avg_worked_seconds{r}#50, birth_date{r}#51, emp_no{r}#52, first_name{r}#53, gender{r}#54, height{r}#55, height.float{r}#56, height.half_float{r}#57, height.scaled_float{r}#58, hire_date{r}#59, is_rehired{r}#60, job_positions{r}#61, languages{r}#62, languages.byte{r}#63, languages.long{r}#64, languages.short{r}#65, last_name{r}#66, salary{r}#67, salary_change{r}#68, salary_change.int{r}#69, salary_change.keyword{r}#70, salary_change.long{r}#71, still_hired{r}#72, max_ts{r}#73, does_not_exist{f(PotentiallyUnmappedKeywordEsField)}#74]] \_Eval[[null[LONG] AS avg_worked_seconds#50, null[DATETIME] AS birth_date#51, null[INTEGER] AS emp_no#52, null[KEYWORD] AS first_name#53, null[KEYWORD] AS gender#54, null[DOUBLE] AS height#55, null[DOUBLE] AS height.float#56, null[DOUBLE] AS height.half_float#57, null[DOUBLE] AS height.scaled_float#58, null[DATETIME] AS hire_date#59, null[BOOLEAN] AS is_rehired#60, null[KEYWORD] AS job_positions#61, null[INTEGER] AS languages#62, null[INTEGER] AS languages.byte#63, null[LONG] AS languages.long#64, null[INTEGER] AS languages.short#65, null[KEYWORD] AS last_name#66, null[INTEGER] AS salary#67, null[DOUBLE] AS salary_change#68, null[INTEGER] AS salary_change.int#69, null[KEYWORD] AS salary_change.keyword#70, null[LONG] AS salary_change.long#71, null[BOOLEAN] AS still_hired#72]] \_Subquery[] - \_Aggregate[[does_not_exist{f}#74],[MAX(@timestamp{f}#75,true[BOOLEAN],PT0S[TIME_DURATION]) AS max_ts#73, does_not_exist{f}#74]] + \_Aggregate[[does_not_exist{f(PotentiallyUnmappedKeywordEsField)}#74],[MAX(@timestamp{f(DateEsField)}#75,true[BOOLEAN],PT0S[TIME_DURATION]) AS max_ts#73, does_not_exist{f(PotentiallyUnmappedKeywordEsField)}#74]] \_EsRelation[sample_data][@timestamp{f}#75, client_ip{f}#76, event_duration{f}#77, message{f}#78, does_not_exist{f}#74] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testSubqueryWithStats/nullify/analysis.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testSubqueryWithStats/nullify/analysis.expected index 1def35de13537..45949bb3dc895 100644 --- a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testSubqueryWithStats/nullify/analysis.expected +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testSubqueryWithStats/nullify/analysis.expected @@ -1,12 +1,12 @@ Limit[1000[INTEGER],false,false] \_Project[[emp_no{r}#0, max_ts{r}#1, does_not_exist{r}#2]] \_UnionAll[[avg_worked_seconds{r}#3, birth_date{r}#4, emp_no{r}#0, first_name{r}#5, gender{r}#6, height{r}#7, height.float{r}#8, height.half_float{r}#9, height.scaled_float{r}#10, hire_date{r}#11, is_rehired{r}#12, job_positions{r}#13, languages{r}#14, languages.byte{r}#15, languages.long{r}#16, languages.short{r}#17, last_name{r}#18, salary{r}#19, salary_change{r}#20, salary_change.int{r}#21, salary_change.keyword{r}#22, salary_change.long{r}#23, still_hired{r}#24, max_ts{r}#1, does_not_exist{r}#2]] - |_Project[[avg_worked_seconds{f}#25, birth_date{f}#26, emp_no{f}#27, first_name{f}#28, gender{f}#29, height{f}#30, height.float{f}#31, height.half_float{f}#32, height.scaled_float{f}#33, hire_date{f}#34, is_rehired{f}#35, job_positions{f}#36, languages{f}#37, languages.byte{f}#38, languages.long{f}#39, languages.short{f}#40, last_name{f}#41, salary{f}#42, salary_change{f}#43, salary_change.int{f}#44, salary_change.keyword{f}#45, salary_change.long{f}#46, still_hired{f}#47, max_ts{r}#48, does_not_exist{r}#49]] + |_Project[[avg_worked_seconds{f(EsField)}#25, birth_date{f(DateEsField)}#26, emp_no{f(EsField)}#27, first_name{f(KeywordEsField)}#28, gender{f(KeywordEsField)}#29, height{f(EsField)}#30, height.float{f(EsField)}#31, height.half_float{f(EsField)}#32, height.scaled_float{f(EsField)}#33, hire_date{f(DateEsField)}#34, is_rehired{f(EsField)}#35, job_positions{f(KeywordEsField)}#36, languages{f(EsField)}#37, languages.byte{f(EsField)}#38, languages.long{f(EsField)}#39, languages.short{f(EsField)}#40, last_name{f(KeywordEsField)}#41, salary{f(EsField)}#42, salary_change{f(EsField)}#43, salary_change.int{f(EsField)}#44, salary_change.keyword{f(KeywordEsField)}#45, salary_change.long{f(EsField)}#46, still_hired{f(EsField)}#47, max_ts{r}#48, does_not_exist{r}#49]] | \_Eval[[null[DATETIME] AS max_ts#48, null[NULL] AS does_not_exist#49]] | \_EsRelation[employees][avg_worked_seconds{f}#25, birth_date{f}#26, emp_no{f}#27, first_name{f}#28, gender{f}#29, height{f}#30, height.float{f}#31, height.half_float{f}#32, height.scaled_float{f}#33, hire_date{f}#34, is_rehired{f}#35, job_positions{f}#36, languages{f}#37, languages.byte{f}#38, languages.long{f}#39, languages.short{f}#40, last_name{f}#41, salary{f}#42, salary_change{f}#43, salary_change.int{f}#44, salary_change.keyword{f}#45, salary_change.long{f}#46, still_hired{f}#47] \_Project[[avg_worked_seconds{r}#50, birth_date{r}#51, emp_no{r}#52, first_name{r}#53, gender{r}#54, height{r}#55, height.float{r}#56, height.half_float{r}#57, height.scaled_float{r}#58, hire_date{r}#59, is_rehired{r}#60, job_positions{r}#61, languages{r}#62, languages.byte{r}#63, languages.long{r}#64, languages.short{r}#65, last_name{r}#66, salary{r}#67, salary_change{r}#68, salary_change.int{r}#69, salary_change.keyword{r}#70, salary_change.long{r}#71, still_hired{r}#72, max_ts{r}#73, does_not_exist{r}#74]] \_Eval[[null[LONG] AS avg_worked_seconds#50, null[DATETIME] AS birth_date#51, null[INTEGER] AS emp_no#52, null[KEYWORD] AS first_name#53, null[KEYWORD] AS gender#54, null[DOUBLE] AS height#55, null[DOUBLE] AS height.float#56, null[DOUBLE] AS height.half_float#57, null[DOUBLE] AS height.scaled_float#58, null[DATETIME] AS hire_date#59, null[BOOLEAN] AS is_rehired#60, null[KEYWORD] AS job_positions#61, null[INTEGER] AS languages#62, null[INTEGER] AS languages.byte#63, null[LONG] AS languages.long#64, null[INTEGER] AS languages.short#65, null[KEYWORD] AS last_name#66, null[INTEGER] AS salary#67, null[DOUBLE] AS salary_change#68, null[INTEGER] AS salary_change.int#69, null[KEYWORD] AS salary_change.keyword#70, null[LONG] AS salary_change.long#71, null[BOOLEAN] AS still_hired#72]] \_Subquery[] - \_Aggregate[[does_not_exist{r}#74],[MAX(@timestamp{f}#75,true[BOOLEAN],PT0S[TIME_DURATION]) AS max_ts#73, does_not_exist{r}#74]] + \_Aggregate[[does_not_exist{r}#74],[MAX(@timestamp{f(DateEsField)}#75,true[BOOLEAN],PT0S[TIME_DURATION]) AS max_ts#73, does_not_exist{r}#74]] \_Eval[[null[NULL] AS does_not_exist#74]] \_EsRelation[sample_data][@timestamp{f}#75, client_ip{f}#76, event_duration{f}#77, message{f}#78] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testTBucketAggregateUnmapped/load/analysis.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testTBucketAggregateUnmapped/load/analysis.expected index 5dc208a9d01de..370b360a7f332 100644 --- a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testTBucketAggregateUnmapped/load/analysis.expected +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testTBucketAggregateUnmapped/load/analysis.expected @@ -1,3 +1,3 @@ Limit[1000[INTEGER],false,false] -\_Aggregate[[TBUCKET(P1D[DATE_PERIOD],@timestamp{f}#0) AS tbucket(1 day)#1],[SUM(TODOUBLE(does_not_exist{f}#2),true[BOOLEAN],PT0S[TIME_DURATION],compensated[KEYWORD]) AS s#3, COUNT(*[KEYWORD],true[BOOLEAN],PT0S[TIME_DURATION]) AS c#4, tbucket(1 day){r}#1]] +\_Aggregate[[TBUCKET(P1D[DATE_PERIOD],@timestamp{f(DateEsField)}#0) AS tbucket(1 day)#1],[SUM(TODOUBLE(does_not_exist{f(PotentiallyUnmappedKeywordEsField)}#2),true[BOOLEAN],PT0S[TIME_DURATION],compensated[KEYWORD]) AS s#3, COUNT(*[KEYWORD],true[BOOLEAN],PT0S[TIME_DURATION]) AS c#4, tbucket(1 day){r}#1]] \_EsRelation[sample_data][@timestamp{f}#0, client_ip{f}#5, event_duration{f}#6, message{f}#7, does_not_exist{f}#2] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testTBucketAggregateUnmapped/nullify/analysis.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testTBucketAggregateUnmapped/nullify/analysis.expected index 630cfad99e1d9..a606b9204678f 100644 --- a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testTBucketAggregateUnmapped/nullify/analysis.expected +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testTBucketAggregateUnmapped/nullify/analysis.expected @@ -1,4 +1,4 @@ Limit[1000[INTEGER],false,false] -\_Aggregate[[TBUCKET(P1D[DATE_PERIOD],@timestamp{f}#0) AS tbucket(1 day)#1],[SUM(TODOUBLE(does_not_exist{r}#2),true[BOOLEAN],PT0S[TIME_DURATION],compensated[KEYWORD]) AS s#3, COUNT(*[KEYWORD],true[BOOLEAN],PT0S[TIME_DURATION]) AS c#4, tbucket(1 day){r}#1]] +\_Aggregate[[TBUCKET(P1D[DATE_PERIOD],@timestamp{f(DateEsField)}#0) AS tbucket(1 day)#1],[SUM(TODOUBLE(does_not_exist{r}#2),true[BOOLEAN],PT0S[TIME_DURATION],compensated[KEYWORD]) AS s#3, COUNT(*[KEYWORD],true[BOOLEAN],PT0S[TIME_DURATION]) AS c#4, tbucket(1 day){r}#1]] \_Eval[[null[NULL] AS does_not_exist#2]] \_EsRelation[sample_data][@timestamp{f}#0, client_ip{f}#5, event_duration{f}#6, message{f}#7] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testTBucketGroupByUnmapped/load/analysis.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testTBucketGroupByUnmapped/load/analysis.expected index 0a5930587890d..50bd7d1993840 100644 --- a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testTBucketGroupByUnmapped/load/analysis.expected +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testTBucketGroupByUnmapped/load/analysis.expected @@ -1,3 +1,3 @@ Limit[1000[INTEGER],false,false] -\_Aggregate[[TBUCKET(PT1H[TIME_DURATION],@timestamp{f}#0) AS tbucket(1 hour)#1, does_not_exist{f}#2],[COUNT(*[KEYWORD],true[BOOLEAN],PT0S[TIME_DURATION]) AS c#3, tbucket(1 hour){r}#1, does_not_exist{f}#2]] +\_Aggregate[[TBUCKET(PT1H[TIME_DURATION],@timestamp{f(DateEsField)}#0) AS tbucket(1 hour)#1, does_not_exist{f(PotentiallyUnmappedKeywordEsField)}#2],[COUNT(*[KEYWORD],true[BOOLEAN],PT0S[TIME_DURATION]) AS c#3, tbucket(1 hour){r}#1, does_not_exist{f(PotentiallyUnmappedKeywordEsField)}#2]] \_EsRelation[sample_data][@timestamp{f}#0, client_ip{f}#4, event_duration{f}#5, message{f}#6, does_not_exist{f}#2] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testTBucketGroupByUnmapped/nullify/analysis.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testTBucketGroupByUnmapped/nullify/analysis.expected index 0ddcf7afa969d..fa9425fdce85b 100644 --- a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testTBucketGroupByUnmapped/nullify/analysis.expected +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testTBucketGroupByUnmapped/nullify/analysis.expected @@ -1,4 +1,4 @@ Limit[1000[INTEGER],false,false] -\_Aggregate[[TBUCKET(PT1H[TIME_DURATION],@timestamp{f}#0) AS tbucket(1 hour)#1, does_not_exist{r}#2],[COUNT(*[KEYWORD],true[BOOLEAN],PT0S[TIME_DURATION]) AS c#3, tbucket(1 hour){r}#1, does_not_exist{r}#2]] +\_Aggregate[[TBUCKET(PT1H[TIME_DURATION],@timestamp{f(DateEsField)}#0) AS tbucket(1 hour)#1, does_not_exist{r}#2],[COUNT(*[KEYWORD],true[BOOLEAN],PT0S[TIME_DURATION]) AS c#3, tbucket(1 hour){r}#1, does_not_exist{r}#2]] \_Eval[[null[NULL] AS does_not_exist#2]] \_EsRelation[sample_data][@timestamp{f}#0, client_ip{f}#4, event_duration{f}#5, message{f}#6] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testTimeSeriesFirstOverTimeUnmapped/load/analysis.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testTimeSeriesFirstOverTimeUnmapped/load/analysis.expected index a53ba9b57e55d..71e224132f7cd 100644 --- a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testTimeSeriesFirstOverTimeUnmapped/load/analysis.expected +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testTimeSeriesFirstOverTimeUnmapped/load/analysis.expected @@ -1,3 +1,3 @@ Limit[1000000[INTEGER],false,false] -\_TimeSeriesAggregate[[_timeseries{f}#0, TBUCKET(PT1H[TIME_DURATION],@timestamp{f}#1) AS tbucket(1 hour)#2],[VALUES(FIRSTOVERTIME(TODOUBLE(does_not_exist{f}#3),true[BOOLEAN],PT0S[TIME_DURATION],@timestamp{f}#1),true[BOOLEAN],PT0S[TIME_DURATION]) AS f#4, tbucket(1 hour){r}#2],null,@timestamp{f}#1] +\_TimeSeriesAggregate[[_timeseries{f(EsField)}#0, TBUCKET(PT1H[TIME_DURATION],@timestamp{f(DateEsField)}#1) AS tbucket(1 hour)#2],[VALUES(FIRSTOVERTIME(TODOUBLE(does_not_exist{f(PotentiallyUnmappedKeywordEsField)}#3),true[BOOLEAN],PT0S[TIME_DURATION],@timestamp{f(DateEsField)}#1),true[BOOLEAN],PT0S[TIME_DURATION]) AS f#4, tbucket(1 hour){r}#2],null,@timestamp{f(DateEsField)}#1] \_EsRelation[k8s][TIME_SERIES][@timestamp{f}#1, client.ip{f}#5, cluster{f}#6, event{f}#7, event_city{f}#8, event_city_boundary{f}#9, event_location{f}#10, event_log{f}#11, event_shape{f}#12, events_received{f}#13, network.bytes_in{f}#14, network.cost{f}#15, network.eth0.currently_connected_clients{f}#16, network.eth0.firmware_version{f}#17, network.eth0.last_up{f}#18, network.eth0.rx{f}#19, network.eth0.tx{f}#20, network.eth0.up{f}#21, network.total_bytes_in{f}#22, network.total_bytes_out{f}#23, network.total_cost{f}#24, pod{f}#25, region{f}#26, _timeseries{f}#0, does_not_exist{f}#3] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testTimeSeriesFirstOverTimeUnmapped/nullify/analysis.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testTimeSeriesFirstOverTimeUnmapped/nullify/analysis.expected index f5b122a261793..98c91207aa550 100644 --- a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testTimeSeriesFirstOverTimeUnmapped/nullify/analysis.expected +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testTimeSeriesFirstOverTimeUnmapped/nullify/analysis.expected @@ -1,4 +1,4 @@ Limit[1000000[INTEGER],false,false] -\_TimeSeriesAggregate[[_timeseries{f}#0, TBUCKET(PT1H[TIME_DURATION],@timestamp{f}#1) AS tbucket(1 hour)#2],[VALUES(FIRSTOVERTIME(TODOUBLE(does_not_exist{r}#3),true[BOOLEAN],PT0S[TIME_DURATION],@timestamp{f}#1),true[BOOLEAN],PT0S[TIME_DURATION]) AS f#4, tbucket(1 hour){r}#2],null,@timestamp{f}#1] +\_TimeSeriesAggregate[[_timeseries{f(EsField)}#0, TBUCKET(PT1H[TIME_DURATION],@timestamp{f(DateEsField)}#1) AS tbucket(1 hour)#2],[VALUES(FIRSTOVERTIME(TODOUBLE(does_not_exist{r}#3),true[BOOLEAN],PT0S[TIME_DURATION],@timestamp{f(DateEsField)}#1),true[BOOLEAN],PT0S[TIME_DURATION]) AS f#4, tbucket(1 hour){r}#2],null,@timestamp{f(DateEsField)}#1] \_Eval[[null[NULL] AS does_not_exist#3]] \_EsRelation[k8s][TIME_SERIES][@timestamp{f}#1, client.ip{f}#5, cluster{f}#6, event{f}#7, event_city{f}#8, event_city_boundary{f}#9, event_location{f}#10, event_log{f}#11, event_shape{f}#12, events_received{f}#13, network.bytes_in{f}#14, network.cost{f}#15, network.eth0.currently_connected_clients{f}#16, network.eth0.firmware_version{f}#17, network.eth0.last_up{f}#18, network.eth0.rx{f}#19, network.eth0.tx{f}#20, network.eth0.up{f}#21, network.total_bytes_in{f}#22, network.total_bytes_out{f}#23, network.total_cost{f}#24, pod{f}#25, region{f}#26, _timeseries{f}#0] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testTimeSeriesRateUnmapped/nullify/analysis.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testTimeSeriesRateUnmapped/nullify/analysis.expected index 41c760dcac978..359c8bd55b39d 100644 --- a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testTimeSeriesRateUnmapped/nullify/analysis.expected +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testTimeSeriesRateUnmapped/nullify/analysis.expected @@ -1,4 +1,4 @@ Limit[1000000[INTEGER],false,false] -\_TimeSeriesAggregate[[_timeseries{f}#0, TBUCKET(PT1H[TIME_DURATION],@timestamp{f}#1) AS tbucket(1 hour)#2],[VALUES(RATE(does_not_exist{r}#3,true[BOOLEAN],PT0S[TIME_DURATION],@timestamp{f}#1),true[BOOLEAN],PT0S[TIME_DURATION]) AS r#4, tbucket(1 hour){r}#2],null,@timestamp{f}#1] +\_TimeSeriesAggregate[[_timeseries{f(EsField)}#0, TBUCKET(PT1H[TIME_DURATION],@timestamp{f(DateEsField)}#1) AS tbucket(1 hour)#2],[VALUES(RATE(does_not_exist{r}#3,true[BOOLEAN],PT0S[TIME_DURATION],@timestamp{f(DateEsField)}#1),true[BOOLEAN],PT0S[TIME_DURATION]) AS r#4, tbucket(1 hour){r}#2],null,@timestamp{f(DateEsField)}#1] \_Eval[[null[NULL] AS does_not_exist#3]] \_EsRelation[k8s][TIME_SERIES][@timestamp{f}#1, client.ip{f}#5, cluster{f}#6, event{f}#7, event_city{f}#8, event_city_boundary{f}#9, event_location{f}#10, event_log{f}#11, event_shape{f}#12, events_received{f}#13, network.bytes_in{f}#14, network.cost{f}#15, network.eth0.currently_connected_clients{f}#16, network.eth0.firmware_version{f}#17, network.eth0.last_up{f}#18, network.eth0.rx{f}#19, network.eth0.tx{f}#20, network.eth0.up{f}#21, network.total_bytes_in{f}#22, network.total_bytes_out{f}#23, network.total_cost{f}#24, pod{f}#25, region{f}#26, _timeseries{f}#0] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testDateTruncBucketNotTransformToQueryAndTagsWithFork/bucket/local_physical_optimization.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testDateTruncBucketNotTransformToQueryAndTagsWithFork/bucket/local_physical_optimization.expected index 504e54c3064ee..e8673db3d1c8d 100644 --- a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testDateTruncBucketNotTransformToQueryAndTagsWithFork/bucket/local_physical_optimization.expected +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testDateTruncBucketNotTransformToQueryAndTagsWithFork/bucket/local_physical_optimization.expected @@ -2,10 +2,10 @@ LimitExec[1000[INTEGER],null] \_AggregateExec[[x{r}#0],[COUNT(*[KEYWORD],true[BOOLEAN],PT0S[TIME_DURATION]) AS count(*)#1, x{r}#0],SINGLE,[x{r}#0, $$count(*)$count{r}#2, $$count(*)$seen{r}#3],null] \_EvalExec[[BUCKET(date{r}#4,P1D[DATE_PERIOD]) AS x#0]] \_MergeExec[[date{r}#4]] - |_ProjectExec[[date{f}#5]] + |_ProjectExec[[date{f(DateEsField)}#5]] | \_LimitExec[1000[INTEGER],null] - | \_ExchangeExec[[date{f}#5],false] - | \_ProjectExec[[date{f}#5]] + | \_ExchangeExec[[date{f(DateEsField)}#5],false] + | \_ProjectExec[[date{f(DateEsField)}#5]] | \_FieldExtractExec[date{f}#5]<[],[]> | \_EsQueryExec[all_types], indexMode[standard], [_doc{f}#6], limit[1000], sort[] estimatedRowSize[12] queryBuilderAndTags [[QueryBuilderAndTags[query={ "esql_single_value" : { @@ -21,10 +21,10 @@ LimitExec[1000[INTEGER],null] "source" : "integer > 100@2:15" } }, tags=[]]]] - \_ProjectExec[[date{f}#7]] + \_ProjectExec[[date{f(DateEsField)}#7]] \_LimitExec[1000[INTEGER],null] - \_ExchangeExec[[date{f}#7],false] - \_ProjectExec[[date{f}#7]] + \_ExchangeExec[[date{f(DateEsField)}#7],false] + \_ProjectExec[[date{f(DateEsField)}#7]] \_FieldExtractExec[date{f}#7]<[],[]> \_EsQueryExec[all_types], indexMode[standard], [_doc{f}#8], limit[1000], sort[] estimatedRowSize[12] queryBuilderAndTags [[QueryBuilderAndTags[query={ "match" : { diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testDateTruncBucketNotTransformToQueryAndTagsWithFork/date_trunc/local_physical_optimization.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testDateTruncBucketNotTransformToQueryAndTagsWithFork/date_trunc/local_physical_optimization.expected index 72dbdcc974f68..5375b59ec8cef 100644 --- a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testDateTruncBucketNotTransformToQueryAndTagsWithFork/date_trunc/local_physical_optimization.expected +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testDateTruncBucketNotTransformToQueryAndTagsWithFork/date_trunc/local_physical_optimization.expected @@ -2,10 +2,10 @@ LimitExec[1000[INTEGER],null] \_AggregateExec[[x{r}#0],[COUNT(*[KEYWORD],true[BOOLEAN],PT0S[TIME_DURATION]) AS count(*)#1, x{r}#0],SINGLE,[x{r}#0, $$count(*)$count{r}#2, $$count(*)$seen{r}#3],null] \_EvalExec[[DATETRUNC(P1D[DATE_PERIOD],date{r}#4) AS x#0]] \_MergeExec[[date{r}#4]] - |_ProjectExec[[date{f}#5]] + |_ProjectExec[[date{f(DateEsField)}#5]] | \_LimitExec[1000[INTEGER],null] - | \_ExchangeExec[[date{f}#5],false] - | \_ProjectExec[[date{f}#5]] + | \_ExchangeExec[[date{f(DateEsField)}#5],false] + | \_ProjectExec[[date{f(DateEsField)}#5]] | \_FieldExtractExec[date{f}#5]<[],[]> | \_EsQueryExec[all_types], indexMode[standard], [_doc{f}#6], limit[1000], sort[] estimatedRowSize[12] queryBuilderAndTags [[QueryBuilderAndTags[query={ "esql_single_value" : { @@ -21,10 +21,10 @@ LimitExec[1000[INTEGER],null] "source" : "integer > 100@2:15" } }, tags=[]]]] - \_ProjectExec[[date{f}#7]] + \_ProjectExec[[date{f(DateEsField)}#7]] \_LimitExec[1000[INTEGER],null] - \_ExchangeExec[[date{f}#7],false] - \_ProjectExec[[date{f}#7]] + \_ExchangeExec[[date{f(DateEsField)}#7],false] + \_ProjectExec[[date{f(DateEsField)}#7]] \_FieldExtractExec[date{f}#7]<[],[]> \_EsQueryExec[all_types], indexMode[standard], [_doc{f}#8], limit[1000], sort[] estimatedRowSize[12] queryBuilderAndTags [[QueryBuilderAndTags[query={ "match" : { diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testDateTruncBucketNotTransformToQueryAndTagsWithFork/round_to/local_physical_optimization.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testDateTruncBucketNotTransformToQueryAndTagsWithFork/round_to/local_physical_optimization.expected index 5c5cb8da952c2..0ba82653fa90c 100644 --- a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testDateTruncBucketNotTransformToQueryAndTagsWithFork/round_to/local_physical_optimization.expected +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testDateTruncBucketNotTransformToQueryAndTagsWithFork/round_to/local_physical_optimization.expected @@ -2,10 +2,10 @@ LimitExec[1000[INTEGER],null] \_AggregateExec[[x{r}#0],[COUNT(*[KEYWORD],true[BOOLEAN],PT0S[TIME_DURATION]) AS count(*)#1, x{r}#0],SINGLE,[x{r}#0, $$count(*)$count{r}#2, $$count(*)$seen{r}#3],null] \_EvalExec[[ROUNDTO(date{r}#4,1697760000000[DATETIME],1697846400000[DATETIME],1697932800000[DATETIME],1698019200000[DATETIME]) AS x#0]] \_MergeExec[[date{r}#4]] - |_ProjectExec[[date{f}#5]] + |_ProjectExec[[date{f(DateEsField)}#5]] | \_LimitExec[1000[INTEGER],null] - | \_ExchangeExec[[date{f}#5],false] - | \_ProjectExec[[date{f}#5]] + | \_ExchangeExec[[date{f(DateEsField)}#5],false] + | \_ProjectExec[[date{f(DateEsField)}#5]] | \_FieldExtractExec[date{f}#5]<[],[]> | \_EsQueryExec[all_types], indexMode[standard], [_doc{f}#6], limit[1000], sort[] estimatedRowSize[12] queryBuilderAndTags [[QueryBuilderAndTags[query={ "esql_single_value" : { @@ -21,10 +21,10 @@ LimitExec[1000[INTEGER],null] "source" : "integer > 100@2:15" } }, tags=[]]]] - \_ProjectExec[[date{f}#7]] + \_ProjectExec[[date{f(DateEsField)}#7]] \_LimitExec[1000[INTEGER],null] - \_ExchangeExec[[date{f}#7],false] - \_ProjectExec[[date{f}#7]] + \_ExchangeExec[[date{f(DateEsField)}#7],false] + \_ProjectExec[[date{f(DateEsField)}#7]] \_FieldExtractExec[date{f}#7]<[],[]> \_EsQueryExec[all_types], indexMode[standard], [_doc{f}#8], limit[1000], sort[] estimatedRowSize[12] queryBuilderAndTags [[QueryBuilderAndTags[query={ "match" : { diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testDateTruncBucketNotTransformToQueryAndTagsWithLookupJoin/bucket/local_physical_optimization.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testDateTruncBucketNotTransformToQueryAndTagsWithLookupJoin/bucket/local_physical_optimization.expected index 37d5c04ccc89b..48ca6656e3cd0 100644 --- a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testDateTruncBucketNotTransformToQueryAndTagsWithLookupJoin/bucket/local_physical_optimization.expected +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testDateTruncBucketNotTransformToQueryAndTagsWithLookupJoin/bucket/local_physical_optimization.expected @@ -2,9 +2,9 @@ LimitExec[1000[INTEGER],null] \_AggregateExec[[x{r}#0],[COUNT(*[KEYWORD],true[BOOLEAN],PT0S[TIME_DURATION]) AS count(*)#1, x{r}#0],FINAL,[x{r}#0, $$count(*)$count{r}#2, $$count(*)$seen{r}#3],null] \_ExchangeExec[[x{r}#0, $$count(*)$count{r}#2, $$count(*)$seen{r}#3],true] \_AggregateExec[[x{r}#0],[COUNT(*[KEYWORD],true[BOOLEAN],PT0S[TIME_DURATION]) AS count(*)#1, x{r}#0],INITIAL,[x{r}#0, $$count(*)$count{r}#4, $$count(*)$seen{r}#5],16] - \_EvalExec[[ROUNDTO(date{f}#6,1697760000000[DATETIME],1697846400000[DATETIME],1697932800000[DATETIME],1698019200000[DATETIME]) AS x#0]] + \_EvalExec[[ROUNDTO(date{f(DateEsField)}#6,1697760000000[DATETIME],1697846400000[DATETIME],1697932800000[DATETIME],1698019200000[DATETIME]) AS x#0]] \_FieldExtractExec[date{f}#6]<[],[]> - \_LookupJoinExec[[integer{f}#7],[language_code{f}#8],[],null] + \_LookupJoinExec[[integer{f(EsField)}#7],[language_code{f(EsField)}#8],[],null] |_FieldExtractExec[integer{f}#7]<[],[]> | \_EsQueryExec[all_types], indexMode[standard], [_doc{f}#9], limit[], sort[] estimatedRowSize[24] queryBuilderAndTags [[QueryBuilderAndTags[query=null, tags=[]]]] \_FragmentExec[filter=null, estimatedRowSize=0, reducer=[], fragment=[<> diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testDateTruncBucketNotTransformToQueryAndTagsWithLookupJoin/date_trunc/local_physical_optimization.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testDateTruncBucketNotTransformToQueryAndTagsWithLookupJoin/date_trunc/local_physical_optimization.expected index 37d5c04ccc89b..48ca6656e3cd0 100644 --- a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testDateTruncBucketNotTransformToQueryAndTagsWithLookupJoin/date_trunc/local_physical_optimization.expected +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testDateTruncBucketNotTransformToQueryAndTagsWithLookupJoin/date_trunc/local_physical_optimization.expected @@ -2,9 +2,9 @@ LimitExec[1000[INTEGER],null] \_AggregateExec[[x{r}#0],[COUNT(*[KEYWORD],true[BOOLEAN],PT0S[TIME_DURATION]) AS count(*)#1, x{r}#0],FINAL,[x{r}#0, $$count(*)$count{r}#2, $$count(*)$seen{r}#3],null] \_ExchangeExec[[x{r}#0, $$count(*)$count{r}#2, $$count(*)$seen{r}#3],true] \_AggregateExec[[x{r}#0],[COUNT(*[KEYWORD],true[BOOLEAN],PT0S[TIME_DURATION]) AS count(*)#1, x{r}#0],INITIAL,[x{r}#0, $$count(*)$count{r}#4, $$count(*)$seen{r}#5],16] - \_EvalExec[[ROUNDTO(date{f}#6,1697760000000[DATETIME],1697846400000[DATETIME],1697932800000[DATETIME],1698019200000[DATETIME]) AS x#0]] + \_EvalExec[[ROUNDTO(date{f(DateEsField)}#6,1697760000000[DATETIME],1697846400000[DATETIME],1697932800000[DATETIME],1698019200000[DATETIME]) AS x#0]] \_FieldExtractExec[date{f}#6]<[],[]> - \_LookupJoinExec[[integer{f}#7],[language_code{f}#8],[],null] + \_LookupJoinExec[[integer{f(EsField)}#7],[language_code{f(EsField)}#8],[],null] |_FieldExtractExec[integer{f}#7]<[],[]> | \_EsQueryExec[all_types], indexMode[standard], [_doc{f}#9], limit[], sort[] estimatedRowSize[24] queryBuilderAndTags [[QueryBuilderAndTags[query=null, tags=[]]]] \_FragmentExec[filter=null, estimatedRowSize=0, reducer=[], fragment=[<> diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testDateTruncBucketNotTransformToQueryAndTagsWithLookupJoin/round_to/local_physical_optimization.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testDateTruncBucketNotTransformToQueryAndTagsWithLookupJoin/round_to/local_physical_optimization.expected index 37d5c04ccc89b..48ca6656e3cd0 100644 --- a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testDateTruncBucketNotTransformToQueryAndTagsWithLookupJoin/round_to/local_physical_optimization.expected +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testDateTruncBucketNotTransformToQueryAndTagsWithLookupJoin/round_to/local_physical_optimization.expected @@ -2,9 +2,9 @@ LimitExec[1000[INTEGER],null] \_AggregateExec[[x{r}#0],[COUNT(*[KEYWORD],true[BOOLEAN],PT0S[TIME_DURATION]) AS count(*)#1, x{r}#0],FINAL,[x{r}#0, $$count(*)$count{r}#2, $$count(*)$seen{r}#3],null] \_ExchangeExec[[x{r}#0, $$count(*)$count{r}#2, $$count(*)$seen{r}#3],true] \_AggregateExec[[x{r}#0],[COUNT(*[KEYWORD],true[BOOLEAN],PT0S[TIME_DURATION]) AS count(*)#1, x{r}#0],INITIAL,[x{r}#0, $$count(*)$count{r}#4, $$count(*)$seen{r}#5],16] - \_EvalExec[[ROUNDTO(date{f}#6,1697760000000[DATETIME],1697846400000[DATETIME],1697932800000[DATETIME],1698019200000[DATETIME]) AS x#0]] + \_EvalExec[[ROUNDTO(date{f(DateEsField)}#6,1697760000000[DATETIME],1697846400000[DATETIME],1697932800000[DATETIME],1698019200000[DATETIME]) AS x#0]] \_FieldExtractExec[date{f}#6]<[],[]> - \_LookupJoinExec[[integer{f}#7],[language_code{f}#8],[],null] + \_LookupJoinExec[[integer{f(EsField)}#7],[language_code{f(EsField)}#8],[],null] |_FieldExtractExec[integer{f}#7]<[],[]> | \_EsQueryExec[all_types], indexMode[standard], [_doc{f}#9], limit[], sort[] estimatedRowSize[24] queryBuilderAndTags [[QueryBuilderAndTags[query=null, tags=[]]]] \_FragmentExec[filter=null, estimatedRowSize=0, reducer=[], fragment=[<> diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testDateTruncBucketTransformToQueryAndTagsWithMultipleAggregates/bucket/local_physical_optimization.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testDateTruncBucketTransformToQueryAndTagsWithMultipleAggregates/bucket/local_physical_optimization.expected index 9bed443f7dbca..4b49127073688 100644 --- a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testDateTruncBucketTransformToQueryAndTagsWithMultipleAggregates/bucket/local_physical_optimization.expected +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testDateTruncBucketTransformToQueryAndTagsWithMultipleAggregates/bucket/local_physical_optimization.expected @@ -1,9 +1,9 @@ LimitExec[1000[INTEGER],null] -\_AggregateExec[[x{r}#0],[SUM(long{f}#1,true[BOOLEAN],PT0S[TIME_DURATION],compensated[KEYWORD]) AS sum(long)#2, COUNT(*[KEYWORD],true[BOOLEAN],PT0S[TIME_DURATION]) AS count(*)#3, x{r}#0],FINAL,[x{r}#0, $$sum(long)$sum{r}#4, $$sum(long)$seen{r}#5, $$count(*)$count{r}#6, $$count(*)$seen{r}#7],null] +\_AggregateExec[[x{r}#0],[SUM(long{f(EsField)}#1,true[BOOLEAN],PT0S[TIME_DURATION],compensated[KEYWORD]) AS sum(long)#2, COUNT(*[KEYWORD],true[BOOLEAN],PT0S[TIME_DURATION]) AS count(*)#3, x{r}#0],FINAL,[x{r}#0, $$sum(long)$sum{r}#4, $$sum(long)$seen{r}#5, $$count(*)$count{r}#6, $$count(*)$seen{r}#7],null] \_ExchangeExec[[x{r}#0, $$sum(long)$sum{r}#4, $$sum(long)$seen{r}#5, $$count(*)$count{r}#6, $$count(*)$seen{r}#7],true] - \_AggregateExec[[x{r}#0],[SUM(long{f}#1,true[BOOLEAN],PT0S[TIME_DURATION],compensated[KEYWORD]) AS sum(long)#2, COUNT(*[KEYWORD],true[BOOLEAN],PT0S[TIME_DURATION]) AS count(*)#3, x{r}#0],INITIAL,[x{r}#0, $$sum(long)$sum{r}#8, $$sum(long)$seen{r}#9, $$count(*)$count{r}#10, $$count(*)$seen{r}#11],24] + \_AggregateExec[[x{r}#0],[SUM(long{f(EsField)}#1,true[BOOLEAN],PT0S[TIME_DURATION],compensated[KEYWORD]) AS sum(long)#2, COUNT(*[KEYWORD],true[BOOLEAN],PT0S[TIME_DURATION]) AS count(*)#3, x{r}#0],INITIAL,[x{r}#0, $$sum(long)$sum{r}#8, $$sum(long)$seen{r}#9, $$count(*)$count{r}#10, $$count(*)$seen{r}#11],24] \_FieldExtractExec[long{f}#1]<[],[]> - \_EvalExec[[$$date$round_to$datetime{f}#12 AS x#0]] + \_EvalExec[[$$date$round_to$datetime{f(EsField)}#12 AS x#0]] \_EsQueryExec[all_types], indexMode[standard], [_doc{f}#13, $$date$round_to$datetime{f}#12], limit[], sort[] estimatedRowSize[20] queryBuilderAndTags [[QueryBuilderAndTags[query={ "esql_single_value" : { "field" : "date", diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testDateTruncBucketTransformToQueryAndTagsWithMultipleAggregates/date_trunc/local_physical_optimization.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testDateTruncBucketTransformToQueryAndTagsWithMultipleAggregates/date_trunc/local_physical_optimization.expected index 8a37befcc7c7e..bc224463f20da 100644 --- a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testDateTruncBucketTransformToQueryAndTagsWithMultipleAggregates/date_trunc/local_physical_optimization.expected +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testDateTruncBucketTransformToQueryAndTagsWithMultipleAggregates/date_trunc/local_physical_optimization.expected @@ -1,9 +1,9 @@ LimitExec[1000[INTEGER],null] -\_AggregateExec[[x{r}#0],[SUM(long{f}#1,true[BOOLEAN],PT0S[TIME_DURATION],compensated[KEYWORD]) AS sum(long)#2, COUNT(*[KEYWORD],true[BOOLEAN],PT0S[TIME_DURATION]) AS count(*)#3, x{r}#0],FINAL,[x{r}#0, $$sum(long)$sum{r}#4, $$sum(long)$seen{r}#5, $$count(*)$count{r}#6, $$count(*)$seen{r}#7],null] +\_AggregateExec[[x{r}#0],[SUM(long{f(EsField)}#1,true[BOOLEAN],PT0S[TIME_DURATION],compensated[KEYWORD]) AS sum(long)#2, COUNT(*[KEYWORD],true[BOOLEAN],PT0S[TIME_DURATION]) AS count(*)#3, x{r}#0],FINAL,[x{r}#0, $$sum(long)$sum{r}#4, $$sum(long)$seen{r}#5, $$count(*)$count{r}#6, $$count(*)$seen{r}#7],null] \_ExchangeExec[[x{r}#0, $$sum(long)$sum{r}#4, $$sum(long)$seen{r}#5, $$count(*)$count{r}#6, $$count(*)$seen{r}#7],true] - \_AggregateExec[[x{r}#0],[SUM(long{f}#1,true[BOOLEAN],PT0S[TIME_DURATION],compensated[KEYWORD]) AS sum(long)#2, COUNT(*[KEYWORD],true[BOOLEAN],PT0S[TIME_DURATION]) AS count(*)#3, x{r}#0],INITIAL,[x{r}#0, $$sum(long)$sum{r}#8, $$sum(long)$seen{r}#9, $$count(*)$count{r}#10, $$count(*)$seen{r}#11],24] + \_AggregateExec[[x{r}#0],[SUM(long{f(EsField)}#1,true[BOOLEAN],PT0S[TIME_DURATION],compensated[KEYWORD]) AS sum(long)#2, COUNT(*[KEYWORD],true[BOOLEAN],PT0S[TIME_DURATION]) AS count(*)#3, x{r}#0],INITIAL,[x{r}#0, $$sum(long)$sum{r}#8, $$sum(long)$seen{r}#9, $$count(*)$count{r}#10, $$count(*)$seen{r}#11],24] \_FieldExtractExec[long{f}#1]<[],[]> - \_EvalExec[[$$date$round_to$datetime{f}#12 AS x#0]] + \_EvalExec[[$$date$round_to$datetime{f(EsField)}#12 AS x#0]] \_EsQueryExec[all_types], indexMode[standard], [_doc{f}#13, $$date$round_to$datetime{f}#12], limit[], sort[] estimatedRowSize[20] queryBuilderAndTags [[QueryBuilderAndTags[query={ "esql_single_value" : { "field" : "date", diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testDateTruncBucketTransformToQueryAndTagsWithMultipleAggregates/round_to/local_physical_optimization.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testDateTruncBucketTransformToQueryAndTagsWithMultipleAggregates/round_to/local_physical_optimization.expected index dd6350bd70a36..45bd1357a9060 100644 --- a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testDateTruncBucketTransformToQueryAndTagsWithMultipleAggregates/round_to/local_physical_optimization.expected +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testDateTruncBucketTransformToQueryAndTagsWithMultipleAggregates/round_to/local_physical_optimization.expected @@ -1,9 +1,9 @@ LimitExec[1000[INTEGER],null] -\_AggregateExec[[x{r}#0],[SUM(long{f}#1,true[BOOLEAN],PT0S[TIME_DURATION],compensated[KEYWORD]) AS sum(long)#2, COUNT(*[KEYWORD],true[BOOLEAN],PT0S[TIME_DURATION]) AS count(*)#3, x{r}#0],FINAL,[x{r}#0, $$sum(long)$sum{r}#4, $$sum(long)$seen{r}#5, $$count(*)$count{r}#6, $$count(*)$seen{r}#7],null] +\_AggregateExec[[x{r}#0],[SUM(long{f(EsField)}#1,true[BOOLEAN],PT0S[TIME_DURATION],compensated[KEYWORD]) AS sum(long)#2, COUNT(*[KEYWORD],true[BOOLEAN],PT0S[TIME_DURATION]) AS count(*)#3, x{r}#0],FINAL,[x{r}#0, $$sum(long)$sum{r}#4, $$sum(long)$seen{r}#5, $$count(*)$count{r}#6, $$count(*)$seen{r}#7],null] \_ExchangeExec[[x{r}#0, $$sum(long)$sum{r}#4, $$sum(long)$seen{r}#5, $$count(*)$count{r}#6, $$count(*)$seen{r}#7],true] - \_AggregateExec[[x{r}#0],[SUM(long{f}#1,true[BOOLEAN],PT0S[TIME_DURATION],compensated[KEYWORD]) AS sum(long)#2, COUNT(*[KEYWORD],true[BOOLEAN],PT0S[TIME_DURATION]) AS count(*)#3, x{r}#0],INITIAL,[x{r}#0, $$sum(long)$sum{r}#8, $$sum(long)$seen{r}#9, $$count(*)$count{r}#10, $$count(*)$seen{r}#11],24] + \_AggregateExec[[x{r}#0],[SUM(long{f(EsField)}#1,true[BOOLEAN],PT0S[TIME_DURATION],compensated[KEYWORD]) AS sum(long)#2, COUNT(*[KEYWORD],true[BOOLEAN],PT0S[TIME_DURATION]) AS count(*)#3, x{r}#0],INITIAL,[x{r}#0, $$sum(long)$sum{r}#8, $$sum(long)$seen{r}#9, $$count(*)$count{r}#10, $$count(*)$seen{r}#11],24] \_FieldExtractExec[long{f}#1]<[],[]> - \_EvalExec[[$$date$round_to$datetime{f}#12 AS x#0]] + \_EvalExec[[$$date$round_to$datetime{f(EsField)}#12 AS x#0]] \_EsQueryExec[all_types], indexMode[standard], [_doc{f}#13, $$date$round_to$datetime{f}#12], limit[], sort[] estimatedRowSize[20] queryBuilderAndTags [[QueryBuilderAndTags[query={ "esql_single_value" : { "field" : "date", diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testDateTruncBucketTransformToQueryAndTagsWithOtherPushdownFunctions/bucket/keyword_equality/local_physical_optimization.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testDateTruncBucketTransformToQueryAndTagsWithOtherPushdownFunctions/bucket/keyword_equality/local_physical_optimization.expected index 8b039c4db5c27..9e5e8117ad64c 100644 --- a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testDateTruncBucketTransformToQueryAndTagsWithOtherPushdownFunctions/bucket/keyword_equality/local_physical_optimization.expected +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testDateTruncBucketTransformToQueryAndTagsWithOtherPushdownFunctions/bucket/keyword_equality/local_physical_optimization.expected @@ -2,7 +2,7 @@ LimitExec[1000[INTEGER],null] \_AggregateExec[[x{r}#0],[COUNT(*[KEYWORD],true[BOOLEAN],PT0S[TIME_DURATION]) AS count(*)#1, x{r}#0],FINAL,[x{r}#0, $$count(*)$count{r}#2, $$count(*)$seen{r}#3],null] \_ExchangeExec[[x{r}#0, $$count(*)$count{r}#2, $$count(*)$seen{r}#3],true] \_AggregateExec[[x{r}#0],[COUNT(*[KEYWORD],true[BOOLEAN],PT0S[TIME_DURATION]) AS count(*)#1, x{r}#0],INITIAL,[x{r}#0, $$count(*)$count{r}#4, $$count(*)$seen{r}#5],16] - \_EvalExec[[$$date$round_to$datetime{f}#6 AS x#0]] + \_EvalExec[[$$date$round_to$datetime{f(EsField)}#6 AS x#0]] \_EsQueryExec[all_types], indexMode[standard], [_doc{f}#7, $$date$round_to$datetime{f}#6], limit[], sort[] estimatedRowSize[12] queryBuilderAndTags [[QueryBuilderAndTags[query={ "bool" : { "filter" : [ diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testDateTruncBucketTransformToQueryAndTagsWithOtherPushdownFunctions/bucket/keyword_match/local_physical_optimization.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testDateTruncBucketTransformToQueryAndTagsWithOtherPushdownFunctions/bucket/keyword_match/local_physical_optimization.expected index 1783e8bca9fb9..1844a19d493e8 100644 --- a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testDateTruncBucketTransformToQueryAndTagsWithOtherPushdownFunctions/bucket/keyword_match/local_physical_optimization.expected +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testDateTruncBucketTransformToQueryAndTagsWithOtherPushdownFunctions/bucket/keyword_match/local_physical_optimization.expected @@ -2,7 +2,7 @@ LimitExec[1000[INTEGER],null] \_AggregateExec[[x{r}#0],[COUNT(*[KEYWORD],true[BOOLEAN],PT0S[TIME_DURATION]) AS count(*)#1, x{r}#0],FINAL,[x{r}#0, $$count(*)$count{r}#2, $$count(*)$seen{r}#3],null] \_ExchangeExec[[x{r}#0, $$count(*)$count{r}#2, $$count(*)$seen{r}#3],true] \_AggregateExec[[x{r}#0],[COUNT(*[KEYWORD],true[BOOLEAN],PT0S[TIME_DURATION]) AS count(*)#1, x{r}#0],INITIAL,[x{r}#0, $$count(*)$count{r}#4, $$count(*)$seen{r}#5],16] - \_EvalExec[[$$date$round_to$datetime{f}#6 AS x#0]] + \_EvalExec[[$$date$round_to$datetime{f(EsField)}#6 AS x#0]] \_EsQueryExec[all_types], indexMode[standard], [_doc{f}#7, $$date$round_to$datetime{f}#6], limit[], sort[] estimatedRowSize[12] queryBuilderAndTags [[QueryBuilderAndTags[query={ "bool" : { "filter" : [ diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testDateTruncBucketTransformToQueryAndTagsWithOtherPushdownFunctions/date_trunc/keyword_equality/local_physical_optimization.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testDateTruncBucketTransformToQueryAndTagsWithOtherPushdownFunctions/date_trunc/keyword_equality/local_physical_optimization.expected index 741c5cc853d00..e4c62c4a8e048 100644 --- a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testDateTruncBucketTransformToQueryAndTagsWithOtherPushdownFunctions/date_trunc/keyword_equality/local_physical_optimization.expected +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testDateTruncBucketTransformToQueryAndTagsWithOtherPushdownFunctions/date_trunc/keyword_equality/local_physical_optimization.expected @@ -2,7 +2,7 @@ LimitExec[1000[INTEGER],null] \_AggregateExec[[x{r}#0],[COUNT(*[KEYWORD],true[BOOLEAN],PT0S[TIME_DURATION]) AS count(*)#1, x{r}#0],FINAL,[x{r}#0, $$count(*)$count{r}#2, $$count(*)$seen{r}#3],null] \_ExchangeExec[[x{r}#0, $$count(*)$count{r}#2, $$count(*)$seen{r}#3],true] \_AggregateExec[[x{r}#0],[COUNT(*[KEYWORD],true[BOOLEAN],PT0S[TIME_DURATION]) AS count(*)#1, x{r}#0],INITIAL,[x{r}#0, $$count(*)$count{r}#4, $$count(*)$seen{r}#5],16] - \_EvalExec[[$$date$round_to$datetime{f}#6 AS x#0]] + \_EvalExec[[$$date$round_to$datetime{f(EsField)}#6 AS x#0]] \_EsQueryExec[all_types], indexMode[standard], [_doc{f}#7, $$date$round_to$datetime{f}#6], limit[], sort[] estimatedRowSize[12] queryBuilderAndTags [[QueryBuilderAndTags[query={ "bool" : { "filter" : [ diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testDateTruncBucketTransformToQueryAndTagsWithOtherPushdownFunctions/date_trunc/keyword_match/local_physical_optimization.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testDateTruncBucketTransformToQueryAndTagsWithOtherPushdownFunctions/date_trunc/keyword_match/local_physical_optimization.expected index ba745f8603cf2..06e902b264e67 100644 --- a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testDateTruncBucketTransformToQueryAndTagsWithOtherPushdownFunctions/date_trunc/keyword_match/local_physical_optimization.expected +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testDateTruncBucketTransformToQueryAndTagsWithOtherPushdownFunctions/date_trunc/keyword_match/local_physical_optimization.expected @@ -2,7 +2,7 @@ LimitExec[1000[INTEGER],null] \_AggregateExec[[x{r}#0],[COUNT(*[KEYWORD],true[BOOLEAN],PT0S[TIME_DURATION]) AS count(*)#1, x{r}#0],FINAL,[x{r}#0, $$count(*)$count{r}#2, $$count(*)$seen{r}#3],null] \_ExchangeExec[[x{r}#0, $$count(*)$count{r}#2, $$count(*)$seen{r}#3],true] \_AggregateExec[[x{r}#0],[COUNT(*[KEYWORD],true[BOOLEAN],PT0S[TIME_DURATION]) AS count(*)#1, x{r}#0],INITIAL,[x{r}#0, $$count(*)$count{r}#4, $$count(*)$seen{r}#5],16] - \_EvalExec[[$$date$round_to$datetime{f}#6 AS x#0]] + \_EvalExec[[$$date$round_to$datetime{f(EsField)}#6 AS x#0]] \_EsQueryExec[all_types], indexMode[standard], [_doc{f}#7, $$date$round_to$datetime{f}#6], limit[], sort[] estimatedRowSize[12] queryBuilderAndTags [[QueryBuilderAndTags[query={ "bool" : { "filter" : [ diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testDateTruncBucketTransformToQueryAndTagsWithOtherPushdownFunctions/round_to/keyword_equality/local_physical_optimization.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testDateTruncBucketTransformToQueryAndTagsWithOtherPushdownFunctions/round_to/keyword_equality/local_physical_optimization.expected index 3bb91af178169..7ee987d4dd704 100644 --- a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testDateTruncBucketTransformToQueryAndTagsWithOtherPushdownFunctions/round_to/keyword_equality/local_physical_optimization.expected +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testDateTruncBucketTransformToQueryAndTagsWithOtherPushdownFunctions/round_to/keyword_equality/local_physical_optimization.expected @@ -2,7 +2,7 @@ LimitExec[1000[INTEGER],null] \_AggregateExec[[x{r}#0],[COUNT(*[KEYWORD],true[BOOLEAN],PT0S[TIME_DURATION]) AS count(*)#1, x{r}#0],FINAL,[x{r}#0, $$count(*)$count{r}#2, $$count(*)$seen{r}#3],null] \_ExchangeExec[[x{r}#0, $$count(*)$count{r}#2, $$count(*)$seen{r}#3],true] \_AggregateExec[[x{r}#0],[COUNT(*[KEYWORD],true[BOOLEAN],PT0S[TIME_DURATION]) AS count(*)#1, x{r}#0],INITIAL,[x{r}#0, $$count(*)$count{r}#4, $$count(*)$seen{r}#5],16] - \_EvalExec[[$$date$round_to$datetime{f}#6 AS x#0]] + \_EvalExec[[$$date$round_to$datetime{f(EsField)}#6 AS x#0]] \_EsQueryExec[all_types], indexMode[standard], [_doc{f}#7, $$date$round_to$datetime{f}#6], limit[], sort[] estimatedRowSize[12] queryBuilderAndTags [[QueryBuilderAndTags[query={ "bool" : { "filter" : [ diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testDateTruncBucketTransformToQueryAndTagsWithOtherPushdownFunctions/round_to/keyword_match/local_physical_optimization.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testDateTruncBucketTransformToQueryAndTagsWithOtherPushdownFunctions/round_to/keyword_match/local_physical_optimization.expected index 0adf9b4716949..717191ed291d6 100644 --- a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testDateTruncBucketTransformToQueryAndTagsWithOtherPushdownFunctions/round_to/keyword_match/local_physical_optimization.expected +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testDateTruncBucketTransformToQueryAndTagsWithOtherPushdownFunctions/round_to/keyword_match/local_physical_optimization.expected @@ -2,7 +2,7 @@ LimitExec[1000[INTEGER],null] \_AggregateExec[[x{r}#0],[COUNT(*[KEYWORD],true[BOOLEAN],PT0S[TIME_DURATION]) AS count(*)#1, x{r}#0],FINAL,[x{r}#0, $$count(*)$count{r}#2, $$count(*)$seen{r}#3],null] \_ExchangeExec[[x{r}#0, $$count(*)$count{r}#2, $$count(*)$seen{r}#3],true] \_AggregateExec[[x{r}#0],[COUNT(*[KEYWORD],true[BOOLEAN],PT0S[TIME_DURATION]) AS count(*)#1, x{r}#0],INITIAL,[x{r}#0, $$count(*)$count{r}#4, $$count(*)$seen{r}#5],16] - \_EvalExec[[$$date$round_to$datetime{f}#6 AS x#0]] + \_EvalExec[[$$date$round_to$datetime{f(EsField)}#6 AS x#0]] \_EsQueryExec[all_types], indexMode[standard], [_doc{f}#7, $$date$round_to$datetime{f}#6], limit[], sort[] estimatedRowSize[12] queryBuilderAndTags [[QueryBuilderAndTags[query={ "bool" : { "filter" : [ diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testDateTruncBucketTransformToQueryAndTagsWithWhereInsideAggregation/bucket/local_physical_optimization.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testDateTruncBucketTransformToQueryAndTagsWithWhereInsideAggregation/bucket/local_physical_optimization.expected index 54ec4005471fb..4b9a4f78f2b83 100644 --- a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testDateTruncBucketTransformToQueryAndTagsWithWhereInsideAggregation/bucket/local_physical_optimization.expected +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testDateTruncBucketTransformToQueryAndTagsWithWhereInsideAggregation/bucket/local_physical_optimization.expected @@ -3,7 +3,7 @@ LimitExec[1000[INTEGER],null] \_ExchangeExec[[x{r}#0, $$count(*) where long > 10$count{r}#3, $$count(*) where long > 10$seen{r}#4],true] \_AggregateExec[[x{r}#0],[COUNT(*[KEYWORD],long{f}#1 > 10[INTEGER],PT0S[TIME_DURATION]) AS count(*) where long > 10#2, x{r}#0],INITIAL,[x{r}#0, $$count(*) where long > 10$count{r}#5, $$count(*) where long > 10$seen{r}#6],16] \_FieldExtractExec[long{f}#1]<[],[]> - \_EvalExec[[$$date$round_to$datetime{f}#7 AS x#0]] + \_EvalExec[[$$date$round_to$datetime{f(EsField)}#7 AS x#0]] \_EsQueryExec[all_types], indexMode[standard], [_doc{f}#8, $$date$round_to$datetime{f}#7], limit[], sort[] estimatedRowSize[20] queryBuilderAndTags [[QueryBuilderAndTags[query={ "esql_single_value" : { "field" : "date", diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testDateTruncBucketTransformToQueryAndTagsWithWhereInsideAggregation/date_trunc/local_physical_optimization.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testDateTruncBucketTransformToQueryAndTagsWithWhereInsideAggregation/date_trunc/local_physical_optimization.expected index 8665d69bc4af1..fad943e8cfcc5 100644 --- a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testDateTruncBucketTransformToQueryAndTagsWithWhereInsideAggregation/date_trunc/local_physical_optimization.expected +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testDateTruncBucketTransformToQueryAndTagsWithWhereInsideAggregation/date_trunc/local_physical_optimization.expected @@ -3,7 +3,7 @@ LimitExec[1000[INTEGER],null] \_ExchangeExec[[x{r}#0, $$count(*) where long > 10$count{r}#3, $$count(*) where long > 10$seen{r}#4],true] \_AggregateExec[[x{r}#0],[COUNT(*[KEYWORD],long{f}#1 > 10[INTEGER],PT0S[TIME_DURATION]) AS count(*) where long > 10#2, x{r}#0],INITIAL,[x{r}#0, $$count(*) where long > 10$count{r}#5, $$count(*) where long > 10$seen{r}#6],16] \_FieldExtractExec[long{f}#1]<[],[]> - \_EvalExec[[$$date$round_to$datetime{f}#7 AS x#0]] + \_EvalExec[[$$date$round_to$datetime{f(EsField)}#7 AS x#0]] \_EsQueryExec[all_types], indexMode[standard], [_doc{f}#8, $$date$round_to$datetime{f}#7], limit[], sort[] estimatedRowSize[20] queryBuilderAndTags [[QueryBuilderAndTags[query={ "esql_single_value" : { "field" : "date", diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testDateTruncBucketTransformToQueryAndTagsWithWhereInsideAggregation/round_to/local_physical_optimization.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testDateTruncBucketTransformToQueryAndTagsWithWhereInsideAggregation/round_to/local_physical_optimization.expected index d59fd1a30f5dc..266ce4e2b05d7 100644 --- a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testDateTruncBucketTransformToQueryAndTagsWithWhereInsideAggregation/round_to/local_physical_optimization.expected +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testDateTruncBucketTransformToQueryAndTagsWithWhereInsideAggregation/round_to/local_physical_optimization.expected @@ -3,7 +3,7 @@ LimitExec[1000[INTEGER],null] \_ExchangeExec[[x{r}#0, $$count(*) where long > 10$count{r}#3, $$count(*) where long > 10$seen{r}#4],true] \_AggregateExec[[x{r}#0],[COUNT(*[KEYWORD],long{f}#1 > 10[INTEGER],PT0S[TIME_DURATION]) AS count(*) where long > 10#2, x{r}#0],INITIAL,[x{r}#0, $$count(*) where long > 10$count{r}#5, $$count(*) where long > 10$seen{r}#6],16] \_FieldExtractExec[long{f}#1]<[],[]> - \_EvalExec[[$$date$round_to$datetime{f}#7 AS x#0]] + \_EvalExec[[$$date$round_to$datetime{f(EsField)}#7 AS x#0]] \_EsQueryExec[all_types], indexMode[standard], [_doc{f}#8, $$date$round_to$datetime{f}#7], limit[], sort[] estimatedRowSize[20] queryBuilderAndTags [[QueryBuilderAndTags[query={ "esql_single_value" : { "field" : "date", diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testDateTruncNotTransformToQueryAndTags/date_trunc/local_physical_optimization.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testDateTruncNotTransformToQueryAndTags/date_trunc/local_physical_optimization.expected index f4aec5a235e42..930a27274aec3 100644 --- a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testDateTruncNotTransformToQueryAndTags/date_trunc/local_physical_optimization.expected +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testDateTruncNotTransformToQueryAndTags/date_trunc/local_physical_optimization.expected @@ -1,8 +1,8 @@ -ProjectExec[[!alias_integer, date{f}#0, x{r}#1]] -\_TopNExec[[Order[date{f}#0,ASC,LAST]],5[INTEGER],null] - \_ExchangeExec[[!alias_integer, date{f}#0, x{r}#1],false] - \_ProjectExec[[!alias_integer, date{f}#0, x{r}#1]] +ProjectExec[[!alias_integer, date{f(DateEsField)}#0, x{r}#1]] +\_TopNExec[[Order[date{f(DateEsField)}#0,ASC,LAST]],5[INTEGER],null] + \_ExchangeExec[[!alias_integer, date{f(DateEsField)}#0, x{r}#1],false] + \_ProjectExec[[!alias_integer, date{f(DateEsField)}#0, x{r}#1]] \_FieldExtractExec[!alias_integer]<[],[]> - \_EvalExec[[ROUNDTO(date{f}#0,1697760000000[DATETIME],1697846400000[DATETIME],1697932800000[DATETIME],1698019200000[DATETIME]) AS x#1]] + \_EvalExec[[ROUNDTO(date{f(DateEsField)}#0,1697760000000[DATETIME],1697846400000[DATETIME],1697932800000[DATETIME],1698019200000[DATETIME]) AS x#1]] \_FieldExtractExec[date{f}#0]<[],[]> \_EsQueryExec[all_types], indexMode[standard], [_doc{f}#2], limit[5], sort[[FieldSort[field=date{f}#0, direction=ASC, nulls=LAST]]] estimatedRowSize[1056] queryBuilderAndTags [[QueryBuilderAndTags[query=null, tags=[]]]] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testDateTruncNotTransformToQueryAndTags/round_to/local_physical_optimization.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testDateTruncNotTransformToQueryAndTags/round_to/local_physical_optimization.expected index f4aec5a235e42..930a27274aec3 100644 --- a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testDateTruncNotTransformToQueryAndTags/round_to/local_physical_optimization.expected +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testDateTruncNotTransformToQueryAndTags/round_to/local_physical_optimization.expected @@ -1,8 +1,8 @@ -ProjectExec[[!alias_integer, date{f}#0, x{r}#1]] -\_TopNExec[[Order[date{f}#0,ASC,LAST]],5[INTEGER],null] - \_ExchangeExec[[!alias_integer, date{f}#0, x{r}#1],false] - \_ProjectExec[[!alias_integer, date{f}#0, x{r}#1]] +ProjectExec[[!alias_integer, date{f(DateEsField)}#0, x{r}#1]] +\_TopNExec[[Order[date{f(DateEsField)}#0,ASC,LAST]],5[INTEGER],null] + \_ExchangeExec[[!alias_integer, date{f(DateEsField)}#0, x{r}#1],false] + \_ProjectExec[[!alias_integer, date{f(DateEsField)}#0, x{r}#1]] \_FieldExtractExec[!alias_integer]<[],[]> - \_EvalExec[[ROUNDTO(date{f}#0,1697760000000[DATETIME],1697846400000[DATETIME],1697932800000[DATETIME],1698019200000[DATETIME]) AS x#1]] + \_EvalExec[[ROUNDTO(date{f(DateEsField)}#0,1697760000000[DATETIME],1697846400000[DATETIME],1697932800000[DATETIME],1698019200000[DATETIME]) AS x#1]] \_FieldExtractExec[date{f}#0]<[],[]> \_EsQueryExec[all_types], indexMode[standard], [_doc{f}#2], limit[5], sort[[FieldSort[field=date{f}#0, direction=ASC, nulls=LAST]]] estimatedRowSize[1056] queryBuilderAndTags [[QueryBuilderAndTags[query=null, tags=[]]]] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testForkWithStatsCountStarDateTrunc/local_physical_optimization.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testForkWithStatsCountStarDateTrunc/local_physical_optimization.expected index d6af15a5d5b6f..ef73b853c3e12 100644 --- a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testForkWithStatsCountStarDateTrunc/local_physical_optimization.expected +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testForkWithStatsCountStarDateTrunc/local_physical_optimization.expected @@ -3,11 +3,11 @@ LimitExec[1000[INTEGER],null] |_ProjectExec[[x{r}#4, y{r}#5, hd{r}#6, _fork{r}#7]] | \_EvalExec[[fork1[KEYWORD] AS _fork#7]] | \_LimitExec[1000[INTEGER],null] - | \_AggregateExec[[hd{r}#6],[COUNT(*[KEYWORD],true[BOOLEAN],PT0S[TIME_DURATION]) AS x#4, MAX(long{f}#8,true[BOOLEAN],PT0S[TIME_DURATION]) AS y#5, hd{r}#6],FINAL,[hd{r}#6, $$x$count{r}#9, $$x$seen{r}#10, $$y$max{r}#11, $$y$seen{r}#12],null] + | \_AggregateExec[[hd{r}#6],[COUNT(*[KEYWORD],true[BOOLEAN],PT0S[TIME_DURATION]) AS x#4, MAX(long{f(EsField)}#8,true[BOOLEAN],PT0S[TIME_DURATION]) AS y#5, hd{r}#6],FINAL,[hd{r}#6, $$x$count{r}#9, $$x$seen{r}#10, $$y$max{r}#11, $$y$seen{r}#12],null] | \_ExchangeExec[[hd{r}#6, $$x$count{r}#9, $$x$seen{r}#10, $$y$max{r}#11, $$y$seen{r}#12],true] - | \_AggregateExec[[hd{r}#6],[COUNT(*[KEYWORD],true[BOOLEAN],PT0S[TIME_DURATION]) AS x#4, MAX(long{f}#8,true[BOOLEAN],PT0S[TIME_DURATION]) AS y#5, hd{r}#6],INITIAL,[hd{r}#6, $$x$count{r}#13, $$x$seen{r}#14, $$y$max{r}#15, $$y$seen{r}#16],24] + | \_AggregateExec[[hd{r}#6],[COUNT(*[KEYWORD],true[BOOLEAN],PT0S[TIME_DURATION]) AS x#4, MAX(long{f(EsField)}#8,true[BOOLEAN],PT0S[TIME_DURATION]) AS y#5, hd{r}#6],INITIAL,[hd{r}#6, $$x$count{r}#13, $$x$seen{r}#14, $$y$max{r}#15, $$y$seen{r}#16],24] | \_FieldExtractExec[long{f}#8]<[],[]> - | \_EvalExec[[$$date$round_to$datetime{f}#17 AS hd#6]] + | \_EvalExec[[$$date$round_to$datetime{f(EsField)}#17 AS hd#6]] | \_EsQueryExec[all_types], indexMode[standard], [_doc{f}#18, $$date$round_to$datetime{f}#17], limit[], sort[] estimatedRowSize[20] queryBuilderAndTags [[QueryBuilderAndTags[query={ "esql_single_value" : { "field" : "date", @@ -86,10 +86,10 @@ LimitExec[1000[INTEGER],null] \_ProjectExec[[x{r}#19, y{r}#20, hd{r}#21, _fork{r}#7]] \_EvalExec[[fork2[KEYWORD] AS _fork#7]] \_LimitExec[1000[INTEGER],null] - \_AggregateExec[[hd{r}#21],[COUNT(*[KEYWORD],true[BOOLEAN],PT0S[TIME_DURATION]) AS x#19, MIN(long{f}#22,true[BOOLEAN],PT0S[TIME_DURATION]) AS y#20, hd{r}#21],FINAL,[hd{r}#21, $$x$count{r}#23, $$x$seen{r}#24, $$y$min{r}#25, $$y$seen{r}#26],null] + \_AggregateExec[[hd{r}#21],[COUNT(*[KEYWORD],true[BOOLEAN],PT0S[TIME_DURATION]) AS x#19, MIN(long{f(EsField)}#22,true[BOOLEAN],PT0S[TIME_DURATION]) AS y#20, hd{r}#21],FINAL,[hd{r}#21, $$x$count{r}#23, $$x$seen{r}#24, $$y$min{r}#25, $$y$seen{r}#26],null] \_ExchangeExec[[hd{r}#21, $$x$count{r}#23, $$x$seen{r}#24, $$y$min{r}#25, $$y$seen{r}#26],true] - \_AggregateExec[[hd{r}#21],[COUNT(*[KEYWORD],true[BOOLEAN],PT0S[TIME_DURATION]) AS x#19, MIN(long{f}#22,true[BOOLEAN],PT0S[TIME_DURATION]) AS y#20, hd{r}#21],INITIAL,[hd{r}#21, $$x$count{r}#27, $$x$seen{r}#28, $$y$min{r}#29, $$y$seen{r}#30],24] + \_AggregateExec[[hd{r}#21],[COUNT(*[KEYWORD],true[BOOLEAN],PT0S[TIME_DURATION]) AS x#19, MIN(long{f(EsField)}#22,true[BOOLEAN],PT0S[TIME_DURATION]) AS y#20, hd{r}#21],INITIAL,[hd{r}#21, $$x$count{r}#27, $$x$seen{r}#28, $$y$min{r}#29, $$y$seen{r}#30],24] \_FieldExtractExec[long{f}#22]<[],[]> - \_EvalExec[[DATETRUNC(P2D[DATE_PERIOD],date{f}#31) AS hd#21]] + \_EvalExec[[DATETRUNC(P2D[DATE_PERIOD],date{f(DateEsField)}#31) AS hd#21]] \_FieldExtractExec[date{f}#31]<[],[]> \_EsQueryExec[all_types], indexMode[standard], [_doc{f}#32], limit[], sort[] estimatedRowSize[28] queryBuilderAndTags [[QueryBuilderAndTags[query=null, tags=[]]]] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testSubqueryWithCountStarAndDateTrunc/local_physical_optimization.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testSubqueryWithCountStarAndDateTrunc/local_physical_optimization.expected index 9f3fe63e4a21f..97b2db7cb91bf 100644 --- a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testSubqueryWithCountStarAndDateTrunc/local_physical_optimization.expected +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/golden_tests/SubstituteRoundToGoldenTests/testSubqueryWithCountStarAndDateTrunc/local_physical_optimization.expected @@ -1,8 +1,8 @@ ProjectExec[[x{r}#0, cnt{r}#1, date{r}#2]] \_LimitExec[1000[INTEGER],null] \_MergeExec[[alias_integer{r}#3, boolean{r}#4, byte{r}#5, constant_keyword-foo{r}#6, date{r}#2, date_nanos{r}#7, dense_vector{r}#8, double{r}#9, float{r}#10, half_float{r}#11, integer{r}#12, ip{r}#13, keyword{r}#14, long{r}#15, scaled_float{r}#16, semantic_text{r}#17, short{r}#18, text{r}#19, unsigned_long{r}#20, version{r}#21, wildcard{r}#22, cnt{r}#1, x{r}#0]] - |_ExchangeExec[[alias_integer{r}#23, boolean{f}#24, byte{f}#25, constant_keyword-foo{f}#26, date{f}#27, date_nanos{f}#28, dense_vector{f}#29, double{f}#30, float{f}#31, half_float{f}#32, integer{f}#33, ip{f}#34, keyword{f}#35, long{f}#36, scaled_float{f}#37, semantic_text{f}#38, short{f}#39, text{f}#40, unsigned_long{f}#41, version{f}#42, wildcard{f}#43, cnt{r}#44, x{r}#45],false] - | \_ProjectExec[[alias_integer{r}#23, boolean{f}#24, byte{f}#25, constant_keyword-foo{f}#26, date{f}#27, date_nanos{f}#28, dense_vector{f}#29, double{f}#30, float{f}#31, half_float{f}#32, integer{f}#33, ip{f}#34, keyword{f}#35, long{f}#36, scaled_float{f}#37, semantic_text{f}#38, short{f}#39, text{f}#40, unsigned_long{f}#41, version{f}#42, wildcard{f}#43, cnt{r}#44, x{r}#45]] + |_ExchangeExec[[alias_integer{r}#23, boolean{f(EsField)}#24, byte{f(EsField)}#25, constant_keyword-foo{f(KeywordEsField)}#26, date{f(DateEsField)}#27, date_nanos{f(EsField)}#28, dense_vector{f(EsField)}#29, double{f(EsField)}#30, float{f(EsField)}#31, half_float{f(EsField)}#32, integer{f(EsField)}#33, ip{f(EsField)}#34, keyword{f(KeywordEsField)}#35, long{f(EsField)}#36, scaled_float{f(EsField)}#37, semantic_text{f(TextEsField)}#38, short{f(EsField)}#39, text{f(TextEsField)}#40, unsigned_long{f(EsField)}#41, version{f(EsField)}#42, wildcard{f(KeywordEsField)}#43, cnt{r}#44, x{r}#45],false] + | \_ProjectExec[[alias_integer{r}#23, boolean{f(EsField)}#24, byte{f(EsField)}#25, constant_keyword-foo{f(KeywordEsField)}#26, date{f(DateEsField)}#27, date_nanos{f(EsField)}#28, dense_vector{f(EsField)}#29, double{f(EsField)}#30, float{f(EsField)}#31, half_float{f(EsField)}#32, integer{f(EsField)}#33, ip{f(EsField)}#34, keyword{f(KeywordEsField)}#35, long{f(EsField)}#36, scaled_float{f(EsField)}#37, semantic_text{f(TextEsField)}#38, short{f(EsField)}#39, text{f(TextEsField)}#40, unsigned_long{f(EsField)}#41, version{f(EsField)}#42, wildcard{f(KeywordEsField)}#43, cnt{r}#44, x{r}#45]] | \_FieldExtractExec[boolean{f}#24, byte{f}#25, constant_keyword-foo{f}#26, date{f}#27, date_nanos{f}#28, dense_vector{f}#29, double{f}#30, float{f}#31, half_float{f}#32, integer{f}#33, ip{f}#34, keyword{f}#35, long{f}#36, scaled_float{f}#37, semantic_text{f}#38, short{f}#39, text{f}#40, unsigned_long{f}#41, version{f}#42, wildcard{f}#43]<[],[]> | \_EvalExec[[null[LONG] AS cnt#44, null[DATETIME] AS x#45, null[KEYWORD] AS alias_integer#23]] | \_EsQueryExec[all_types], indexMode[standard], [_doc{f}#46], limit[], sort[] estimatedRowSize[6472] queryBuilderAndTags [[QueryBuilderAndTags[query=null, tags=[]]]] diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testBasicTopNLateMaterialization/local_reduce_physical_optimization_data_driver.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testBasicTopNLateMaterialization/local_reduce_physical_optimization_data_driver.expected index 71c01677f83a5..535953e39d9cf 100644 --- a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testBasicTopNLateMaterialization/local_reduce_physical_optimization_data_driver.expected +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testBasicTopNLateMaterialization/local_reduce_physical_optimization_data_driver.expected @@ -1,4 +1,4 @@ -ExchangeSinkExec[[emp_no{f}#0, hire_date{f}#1, salary{f}#2],false] -\_ProjectExec[[_doc{f}#3, hire_date{f}#1]] +ExchangeSinkExec[[emp_no{f(EsField)}#0, hire_date{f(DateEsField)}#1, salary{f(EsField)}#2],false] +\_ProjectExec[[_doc{f(EsField)}#3, hire_date{f(DateEsField)}#1]] \_FieldExtractExec[hire_date{f}#1]<[],[]> \_EsQueryExec[employees], indexMode[standard], [_doc{f}#3], limit[20], sort[[FieldSort[field=hire_date{f}#1, direction=ASC, nulls=LAST]]] estimatedRowSize[24] queryBuilderAndTags [[QueryBuilderAndTags[query=null, tags=[]]]] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testBasicTopNLateMaterialization/local_reduce_planned_data_driver.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testBasicTopNLateMaterialization/local_reduce_planned_data_driver.expected index fc4d011c9a8fb..6b9bd659d3727 100644 --- a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testBasicTopNLateMaterialization/local_reduce_planned_data_driver.expected +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testBasicTopNLateMaterialization/local_reduce_planned_data_driver.expected @@ -1,5 +1,5 @@ -ExchangeSinkExec[[emp_no{f}#0, hire_date{f}#1, salary{f}#2],false] +ExchangeSinkExec[[emp_no{f(EsField)}#0, hire_date{f(DateEsField)}#1, salary{f(EsField)}#2],false] \_FragmentExec[filter=null, estimatedRowSize=0, reducer=[], fragment=[<> -Project[[_doc{f}#3, hire_date{f}#1]] -\_TopN[[Order[hire_date{f}#1,ASC,LAST]],20[INTEGER],false] +Project[[_doc{f(EsField)}#3, hire_date{f(DateEsField)}#1]] +\_TopN[[Order[hire_date{f(DateEsField)}#1,ASC,LAST]],20[INTEGER],false] \_EsRelation[employees][_doc{f}#3, avg_worked_seconds{f}#4, birth_date{f}#5, emp_no{f}#0, first_name{f}#6, gender{f}#7, height{f}#8, height.float{f}#9, height.half_float{f}#10, height.scaled_float{f}#11, hire_date{f}#1, is_rehired{f}#12, job_positions{f}#13, languages{f}#14, languages.byte{f}#15, languages.long{f}#16, languages.short{f}#17, last_name{f}#18, salary{f}#2, salary_change{f}#19, salary_change.int{f}#20, salary_change.keyword{f}#21, salary_change.long{f}#22, still_hired{f}#23]<>]] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testBasicTopNLateMaterialization/local_reduce_planned_reduce_driver.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testBasicTopNLateMaterialization/local_reduce_planned_reduce_driver.expected index 4b4fc0c891ac1..b4351eb176c15 100644 --- a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testBasicTopNLateMaterialization/local_reduce_planned_reduce_driver.expected +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testBasicTopNLateMaterialization/local_reduce_planned_reduce_driver.expected @@ -1,5 +1,5 @@ -ExchangeSinkExec[[emp_no{f}#0, hire_date{f}#1, salary{f}#2],false] -\_ProjectExec[[emp_no{f}#0, hire_date{f}#1, salary{f}#2]] +ExchangeSinkExec[[emp_no{f(EsField)}#0, hire_date{f(DateEsField)}#1, salary{f(EsField)}#2],false] +\_ProjectExec[[emp_no{f(EsField)}#0, hire_date{f(DateEsField)}#1, salary{f(EsField)}#2]] \_FieldExtractExec[emp_no{f}#0, salary{f}#2]<[],[]> - \_TopNExec[[Order[hire_date{f}#1,ASC,LAST]],20[INTEGER],36] - \_ExchangeSourceExec[[_doc{f}#3, hire_date{f}#1],false] \ No newline at end of file + \_TopNExec[[Order[hire_date{f(DateEsField)}#1,ASC,LAST]],20[INTEGER],36] + \_ExchangeSourceExec[[_doc{f(EsField)}#3, hire_date{f(DateEsField)}#1],false] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testBasicTopNLateMaterialization/physical_optimization.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testBasicTopNLateMaterialization/physical_optimization.expected index 84b502cae4e25..fac7b0beb280e 100644 --- a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testBasicTopNLateMaterialization/physical_optimization.expected +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testBasicTopNLateMaterialization/physical_optimization.expected @@ -1,7 +1,7 @@ -ProjectExec[[hire_date{f}#0, salary{f}#1, emp_no{f}#2]] -\_TopNExec[[Order[hire_date{f}#0,ASC,LAST]],20[INTEGER],null] - \_ExchangeExec[[emp_no{f}#2, hire_date{f}#0, salary{f}#1],false] +ProjectExec[[hire_date{f(DateEsField)}#0, salary{f(EsField)}#1, emp_no{f(EsField)}#2]] +\_TopNExec[[Order[hire_date{f(DateEsField)}#0,ASC,LAST]],20[INTEGER],null] + \_ExchangeExec[[emp_no{f(EsField)}#2, hire_date{f(DateEsField)}#0, salary{f(EsField)}#1],false] \_FragmentExec[filter=null, estimatedRowSize=0, reducer=[], fragment=[<> -Project[[emp_no{f}#2, hire_date{f}#0, salary{f}#1]] -\_TopN[[Order[hire_date{f}#0,ASC,LAST]],20[INTEGER],false] +Project[[emp_no{f(EsField)}#2, hire_date{f(DateEsField)}#0, salary{f(EsField)}#1]] +\_TopN[[Order[hire_date{f(DateEsField)}#0,ASC,LAST]],20[INTEGER],false] \_EsRelation[employees][avg_worked_seconds{f}#3, birth_date{f}#4, emp_no{f}#2, first_name{f}#5, gender{f}#6, height{f}#7, height.float{f}#8, height.half_float{f}#9, height.scaled_float{f}#10, hire_date{f}#0, is_rehired{f}#11, job_positions{f}#12, languages{f}#13, languages.byte{f}#14, languages.long{f}#15, languages.short{f}#16, last_name{f}#17, salary{f}#1, salary_change{f}#18, salary_change.int{f}#19, salary_change.keyword{f}#20, salary_change.long{f}#21, still_hired{f}#22]<>]] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testExpressionSortTopNKeepAfterSort/local_reduce_physical_optimization_data_driver.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testExpressionSortTopNKeepAfterSort/local_reduce_physical_optimization_data_driver.expected index 8f49d89b830ce..bb3e478910242 100644 --- a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testExpressionSortTopNKeepAfterSort/local_reduce_physical_optimization_data_driver.expected +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testExpressionSortTopNKeepAfterSort/local_reduce_physical_optimization_data_driver.expected @@ -1,5 +1,5 @@ -ExchangeSinkExec[[hire_date{f}#0, $$order_by$0{r}#1],false] -\_ProjectExec[[_doc{f}#2, $$order_by$0{r}#1]] +ExchangeSinkExec[[hire_date{f(DateEsField)}#0, $$order_by$0{r}#1],false] +\_ProjectExec[[_doc{f(EsField)}#2, $$order_by$0{r}#1]] \_TopNExec[[Order[$$order_by$0{r}#1,ASC,LAST]],20[INTEGER],36] \_EvalExec[[SIN(height{f}#3) * 2[INTEGER] AS $$order_by$0#1]] \_FieldExtractExec[height{f}#3]<[],[]> diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testExpressionSortTopNKeepAfterSort/local_reduce_planned_data_driver.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testExpressionSortTopNKeepAfterSort/local_reduce_planned_data_driver.expected index 9ce3f748778c1..3155ade77bff9 100644 --- a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testExpressionSortTopNKeepAfterSort/local_reduce_planned_data_driver.expected +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testExpressionSortTopNKeepAfterSort/local_reduce_planned_data_driver.expected @@ -1,6 +1,6 @@ -ExchangeSinkExec[[hire_date{f}#0, $$order_by$0{r}#1],false] +ExchangeSinkExec[[hire_date{f(DateEsField)}#0, $$order_by$0{r}#1],false] \_FragmentExec[filter=null, estimatedRowSize=0, reducer=[], fragment=[<> -Project[[_doc{f}#2, $$order_by$0{r}#1]] +Project[[_doc{f(EsField)}#2, $$order_by$0{r}#1]] \_TopN[[Order[$$order_by$0{r}#1,ASC,LAST]],20[INTEGER],false] \_Eval[[SIN(height{f}#3) * 2[INTEGER] AS $$order_by$0#1]] \_EsRelation[employees][_doc{f}#2, avg_worked_seconds{f}#4, birth_date{f}#5, emp_no{f}#6, first_name{f}#7, gender{f}#8, height{f}#3, height.float{f}#9, height.half_float{f}#10, height.scaled_float{f}#11, hire_date{f}#0, is_rehired{f}#12, job_positions{f}#13, languages{f}#14, languages.byte{f}#15, languages.long{f}#16, languages.short{f}#17, last_name{f}#18, salary{f}#19, salary_change{f}#20, salary_change.int{f}#21, salary_change.keyword{f}#22, salary_change.long{f}#23, still_hired{f}#24]<>]] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testExpressionSortTopNKeepAfterSort/local_reduce_planned_reduce_driver.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testExpressionSortTopNKeepAfterSort/local_reduce_planned_reduce_driver.expected index d2459818c5588..8a01de5d8a548 100644 --- a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testExpressionSortTopNKeepAfterSort/local_reduce_planned_reduce_driver.expected +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testExpressionSortTopNKeepAfterSort/local_reduce_planned_reduce_driver.expected @@ -1,5 +1,5 @@ -ExchangeSinkExec[[hire_date{f}#0, $$order_by$0{r}#1],false] -\_ProjectExec[[hire_date{f}#0, $$order_by$0{r}#1]] +ExchangeSinkExec[[hire_date{f(DateEsField)}#0, $$order_by$0{r}#1],false] +\_ProjectExec[[hire_date{f(DateEsField)}#0, $$order_by$0{r}#1]] \_FieldExtractExec[hire_date{f}#0]<[],[]> \_TopNExec[[Order[$$order_by$0{r}#1,ASC,LAST]],20[INTEGER],36] - \_ExchangeSourceExec[[_doc{f}#2, $$order_by$0{r}#1],false] \ No newline at end of file + \_ExchangeSourceExec[[_doc{f(EsField)}#2, $$order_by$0{r}#1],false] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testExpressionSortTopNKeepAfterSort/physical_optimization.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testExpressionSortTopNKeepAfterSort/physical_optimization.expected index 71abdab6b07fe..1d2b47bd3d1a2 100644 --- a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testExpressionSortTopNKeepAfterSort/physical_optimization.expected +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testExpressionSortTopNKeepAfterSort/physical_optimization.expected @@ -1,8 +1,8 @@ -ProjectExec[[hire_date{f}#0]] +ProjectExec[[hire_date{f(DateEsField)}#0]] \_TopNExec[[Order[$$order_by$0{r}#1,ASC,LAST]],20[INTEGER],null] - \_ExchangeExec[[hire_date{f}#0, $$order_by$0{r}#1],false] + \_ExchangeExec[[hire_date{f(DateEsField)}#0, $$order_by$0{r}#1],false] \_FragmentExec[filter=null, estimatedRowSize=0, reducer=[], fragment=[<> -Project[[hire_date{f}#0, $$order_by$0{r}#1]] +Project[[hire_date{f(DateEsField)}#0, $$order_by$0{r}#1]] \_TopN[[Order[$$order_by$0{r}#1,ASC,LAST]],20[INTEGER],false] \_Eval[[SIN(height{f}#2) * 2[INTEGER] AS $$order_by$0#1]] \_EsRelation[employees][avg_worked_seconds{f}#3, birth_date{f}#4, emp_no{f}#5, first_name{f}#6, gender{f}#7, height{f}#2, height.float{f}#8, height.half_float{f}#9, height.scaled_float{f}#10, hire_date{f}#0, is_rehired{f}#11, job_positions{f}#12, languages{f}#13, languages.byte{f}#14, languages.long{f}#15, languages.short{f}#16, last_name{f}#17, salary{f}#18, salary_change{f}#19, salary_change.int{f}#20, salary_change.keyword{f}#21, salary_change.long{f}#22, still_hired{f}#23]<>]] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testExpressionSortTopNKeepBeforeSort/local_reduce_physical_optimization_data_driver.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testExpressionSortTopNKeepBeforeSort/local_reduce_physical_optimization_data_driver.expected index 460cbcab3451e..fa8fc973f782f 100644 --- a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testExpressionSortTopNKeepBeforeSort/local_reduce_physical_optimization_data_driver.expected +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testExpressionSortTopNKeepBeforeSort/local_reduce_physical_optimization_data_driver.expected @@ -1,5 +1,5 @@ -ExchangeSinkExec[[height{f}#0, hire_date{f}#1, $$order_by$0{r}#2],false] -\_ProjectExec[[_doc{f}#3, height{f}#0, $$order_by$0{r}#2]] +ExchangeSinkExec[[height{f(EsField)}#0, hire_date{f(DateEsField)}#1, $$order_by$0{r}#2],false] +\_ProjectExec[[_doc{f(EsField)}#3, height{f(EsField)}#0, $$order_by$0{r}#2]] \_TopNExec[[Order[$$order_by$0{r}#2,ASC,LAST]],20[INTEGER],36] \_EvalExec[[SIN(height{f}#0) * 2[INTEGER] AS $$order_by$0#2]] \_FieldExtractExec[height{f}#0]<[],[]> diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testExpressionSortTopNKeepBeforeSort/local_reduce_planned_data_driver.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testExpressionSortTopNKeepBeforeSort/local_reduce_planned_data_driver.expected index 932c4834e7e80..d650ee04b817e 100644 --- a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testExpressionSortTopNKeepBeforeSort/local_reduce_planned_data_driver.expected +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testExpressionSortTopNKeepBeforeSort/local_reduce_planned_data_driver.expected @@ -1,6 +1,6 @@ -ExchangeSinkExec[[height{f}#0, hire_date{f}#1, $$order_by$0{r}#2],false] +ExchangeSinkExec[[height{f(EsField)}#0, hire_date{f(DateEsField)}#1, $$order_by$0{r}#2],false] \_FragmentExec[filter=null, estimatedRowSize=0, reducer=[], fragment=[<> -Project[[_doc{f}#3, height{f}#0, $$order_by$0{r}#2]] +Project[[_doc{f(EsField)}#3, height{f(EsField)}#0, $$order_by$0{r}#2]] \_TopN[[Order[$$order_by$0{r}#2,ASC,LAST]],20[INTEGER],false] \_Eval[[SIN(height{f}#0) * 2[INTEGER] AS $$order_by$0#2]] \_EsRelation[employees][_doc{f}#3, avg_worked_seconds{f}#4, birth_date{f}#5, emp_no{f}#6, first_name{f}#7, gender{f}#8, height{f}#0, height.float{f}#9, height.half_float{f}#10, height.scaled_float{f}#11, hire_date{f}#1, is_rehired{f}#12, job_positions{f}#13, languages{f}#14, languages.byte{f}#15, languages.long{f}#16, languages.short{f}#17, last_name{f}#18, salary{f}#19, salary_change{f}#20, salary_change.int{f}#21, salary_change.keyword{f}#22, salary_change.long{f}#23, still_hired{f}#24]<>]] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testExpressionSortTopNKeepBeforeSort/local_reduce_planned_reduce_driver.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testExpressionSortTopNKeepBeforeSort/local_reduce_planned_reduce_driver.expected index 88c85960c5dd2..ecc7f70c306ad 100644 --- a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testExpressionSortTopNKeepBeforeSort/local_reduce_planned_reduce_driver.expected +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testExpressionSortTopNKeepBeforeSort/local_reduce_planned_reduce_driver.expected @@ -1,5 +1,5 @@ -ExchangeSinkExec[[height{f}#0, hire_date{f}#1, $$order_by$0{r}#2],false] -\_ProjectExec[[height{f}#0, hire_date{f}#1, $$order_by$0{r}#2]] +ExchangeSinkExec[[height{f(EsField)}#0, hire_date{f(DateEsField)}#1, $$order_by$0{r}#2],false] +\_ProjectExec[[height{f(EsField)}#0, hire_date{f(DateEsField)}#1, $$order_by$0{r}#2]] \_FieldExtractExec[hire_date{f}#1]<[],[]> \_TopNExec[[Order[$$order_by$0{r}#2,ASC,LAST]],20[INTEGER],44] - \_ExchangeSourceExec[[_doc{f}#3, height{f}#0, $$order_by$0{r}#2],false] \ No newline at end of file + \_ExchangeSourceExec[[_doc{f(EsField)}#3, height{f(EsField)}#0, $$order_by$0{r}#2],false] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testExpressionSortTopNKeepBeforeSort/physical_optimization.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testExpressionSortTopNKeepBeforeSort/physical_optimization.expected index b3fbad771e03e..56453d62cad8f 100644 --- a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testExpressionSortTopNKeepBeforeSort/physical_optimization.expected +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testExpressionSortTopNKeepBeforeSort/physical_optimization.expected @@ -1,8 +1,8 @@ -ProjectExec[[hire_date{f}#0, height{f}#1]] +ProjectExec[[hire_date{f(DateEsField)}#0, height{f(EsField)}#1]] \_TopNExec[[Order[$$order_by$0{r}#2,ASC,LAST]],20[INTEGER],null] - \_ExchangeExec[[height{f}#1, hire_date{f}#0, $$order_by$0{r}#2],false] + \_ExchangeExec[[height{f(EsField)}#1, hire_date{f(DateEsField)}#0, $$order_by$0{r}#2],false] \_FragmentExec[filter=null, estimatedRowSize=0, reducer=[], fragment=[<> -Project[[height{f}#1, hire_date{f}#0, $$order_by$0{r}#2]] +Project[[height{f(EsField)}#1, hire_date{f(DateEsField)}#0, $$order_by$0{r}#2]] \_TopN[[Order[$$order_by$0{r}#2,ASC,LAST]],20[INTEGER],false] \_Eval[[SIN(height{f}#1) * 2[INTEGER] AS $$order_by$0#2]] \_EsRelation[employees][avg_worked_seconds{f}#3, birth_date{f}#4, emp_no{f}#5, first_name{f}#6, gender{f}#7, height{f}#1, height.float{f}#8, height.half_float{f}#9, height.scaled_float{f}#10, hire_date{f}#0, is_rehired{f}#11, job_positions{f}#12, languages{f}#13, languages.byte{f}#14, languages.long{f}#15, languages.short{f}#16, last_name{f}#17, salary{f}#18, salary_change{f}#19, salary_change.int{f}#20, salary_change.keyword{f}#21, salary_change.long{f}#22, still_hired{f}#23]<>]] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testLookupJoinOnDataNode/local_reduce_physical_optimization_data_driver.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testLookupJoinOnDataNode/local_reduce_physical_optimization_data_driver.expected index ebbbae1cfcc6d..ea2943054fab9 100644 --- a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testLookupJoinOnDataNode/local_reduce_physical_optimization_data_driver.expected +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testLookupJoinOnDataNode/local_reduce_physical_optimization_data_driver.expected @@ -1,9 +1,9 @@ -ExchangeSinkExec[[avg_worked_seconds{f}#0, birth_date{f}#1, emp_no{f}#2, first_name{f}#3, gender{f}#4, height{f}#5, height.float{f}#6, height.half_float{f}#7, height.scaled_float{f}#8, hire_date{f}#9, is_rehired{f}#10, job_positions{f}#11, languages{f}#12, languages.byte{f}#13, languages.long{f}#14, languages.short{f}#15, last_name{f}#16, salary{f}#17, salary_change{f}#18, salary_change.int{f}#19, salary_change.keyword{f}#20, salary_change.long{f}#21, still_hired{f}#22, language_code{r}#23, language_name{f}#24],false] -\_ProjectExec[[_doc{f}#25, emp_no{f}#2, languages{f}#12, language_code{r}#23, language_name{f}#24]] - \_TopNExec[[Order[emp_no{f}#2,ASC,LAST]],20[INTEGER],82] +ExchangeSinkExec[[avg_worked_seconds{f(EsField)}#0, birth_date{f(DateEsField)}#1, emp_no{f(EsField)}#2, first_name{f(KeywordEsField)}#3, gender{f(KeywordEsField)}#4, height{f(EsField)}#5, height.float{f(EsField)}#6, height.half_float{f(EsField)}#7, height.scaled_float{f(EsField)}#8, hire_date{f(DateEsField)}#9, is_rehired{f(EsField)}#10, job_positions{f(KeywordEsField)}#11, languages{f(EsField)}#12, languages.byte{f(EsField)}#13, languages.long{f(EsField)}#14, languages.short{f(EsField)}#15, last_name{f(KeywordEsField)}#16, salary{f(EsField)}#17, salary_change{f(EsField)}#18, salary_change.int{f(EsField)}#19, salary_change.keyword{f(KeywordEsField)}#20, salary_change.long{f(EsField)}#21, still_hired{f(EsField)}#22, language_code{r}#23, language_name{f(KeywordEsField)}#24],false] +\_ProjectExec[[_doc{f(EsField)}#25, emp_no{f(EsField)}#2, languages{f(EsField)}#12, language_code{r}#23, language_name{f(KeywordEsField)}#24]] + \_TopNExec[[Order[emp_no{f(EsField)}#2,ASC,LAST]],20[INTEGER],82] \_FieldExtractExec[emp_no{f}#2]<[],[]> - \_LookupJoinExec[[language_code{r}#23],[language_code{f}#26],[language_name{f}#24],null] - |_EvalExec[[languages{f}#12 AS language_code#23]] + \_LookupJoinExec[[language_code{r}#23],[language_code{f(EsField)}#26],[language_name{f(KeywordEsField)}#24],null] + |_EvalExec[[languages{f(EsField)}#12 AS language_code#23]] | \_FieldExtractExec[languages{f}#12]<[],[]> | \_EsQueryExec[employees], indexMode[standard], [_doc{f}#25], limit[], sort[] estimatedRowSize[66] queryBuilderAndTags [[QueryBuilderAndTags[query={ "esql_single_value" : { diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testLookupJoinOnDataNode/local_reduce_planned_data_driver.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testLookupJoinOnDataNode/local_reduce_planned_data_driver.expected index 7ff68ac134d83..35c83372e097e 100644 --- a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testLookupJoinOnDataNode/local_reduce_planned_data_driver.expected +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testLookupJoinOnDataNode/local_reduce_planned_data_driver.expected @@ -1,9 +1,9 @@ -ExchangeSinkExec[[avg_worked_seconds{f}#0, birth_date{f}#1, emp_no{f}#2, first_name{f}#3, gender{f}#4, height{f}#5, height.float{f}#6, height.half_float{f}#7, height.scaled_float{f}#8, hire_date{f}#9, is_rehired{f}#10, job_positions{f}#11, languages{f}#12, languages.byte{f}#13, languages.long{f}#14, languages.short{f}#15, last_name{f}#16, salary{f}#17, salary_change{f}#18, salary_change.int{f}#19, salary_change.keyword{f}#20, salary_change.long{f}#21, still_hired{f}#22, language_code{r}#23, language_name{f}#24],false] +ExchangeSinkExec[[avg_worked_seconds{f(EsField)}#0, birth_date{f(DateEsField)}#1, emp_no{f(EsField)}#2, first_name{f(KeywordEsField)}#3, gender{f(KeywordEsField)}#4, height{f(EsField)}#5, height.float{f(EsField)}#6, height.half_float{f(EsField)}#7, height.scaled_float{f(EsField)}#8, hire_date{f(DateEsField)}#9, is_rehired{f(EsField)}#10, job_positions{f(KeywordEsField)}#11, languages{f(EsField)}#12, languages.byte{f(EsField)}#13, languages.long{f(EsField)}#14, languages.short{f(EsField)}#15, last_name{f(KeywordEsField)}#16, salary{f(EsField)}#17, salary_change{f(EsField)}#18, salary_change.int{f(EsField)}#19, salary_change.keyword{f(KeywordEsField)}#20, salary_change.long{f(EsField)}#21, still_hired{f(EsField)}#22, language_code{r}#23, language_name{f(KeywordEsField)}#24],false] \_FragmentExec[filter=null, estimatedRowSize=0, reducer=[], fragment=[<> -Project[[_doc{f}#25, emp_no{f}#2, languages{f}#12, language_code{r}#23, language_name{f}#24]] -\_TopN[[Order[emp_no{f}#2,ASC,LAST]],20[INTEGER],false] - \_Join[LEFT,[language_code{r}#23],[language_code{f}#26],null] - |_Eval[[languages{f}#12 AS language_code#23]] +Project[[_doc{f(EsField)}#25, emp_no{f(EsField)}#2, languages{f(EsField)}#12, language_code{r}#23, language_name{f(KeywordEsField)}#24]] +\_TopN[[Order[emp_no{f(EsField)}#2,ASC,LAST]],20[INTEGER],false] + \_Join[LEFT,[language_code{r}#23],[language_code{f(EsField)}#26],null] + |_Eval[[languages{f(EsField)}#12 AS language_code#23]] | \_Filter[emp_no{f}#2 >= 10091[INTEGER] AND emp_no{f}#2 < 10094[INTEGER]] | \_EsRelation[employees][_doc{f}#25, avg_worked_seconds{f}#0, birth_date{f}#1, emp_no{f}#2, first_name{f}#3, gender{f}#4, height{f}#5, height.float{f}#6, height.half_float{f}#7, height.scaled_float{f}#8, hire_date{f}#9, is_rehired{f}#10, job_positions{f}#11, languages{f}#12, languages.byte{f}#13, languages.long{f}#14, languages.short{f}#15, last_name{f}#16, salary{f}#17, salary_change{f}#18, salary_change.int{f}#19, salary_change.keyword{f}#20, salary_change.long{f}#21, still_hired{f}#22] \_EsRelation[languages_lookup][LOOKUP][language_code{f}#26, language_name{f}#24]<>]] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testLookupJoinOnDataNode/local_reduce_planned_reduce_driver.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testLookupJoinOnDataNode/local_reduce_planned_reduce_driver.expected index 19c98b1780f37..d6ecc720cbde4 100644 --- a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testLookupJoinOnDataNode/local_reduce_planned_reduce_driver.expected +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testLookupJoinOnDataNode/local_reduce_planned_reduce_driver.expected @@ -1,5 +1,5 @@ -ExchangeSinkExec[[avg_worked_seconds{f}#0, birth_date{f}#1, emp_no{f}#2, first_name{f}#3, gender{f}#4, height{f}#5, height.float{f}#6, height.half_float{f}#7, height.scaled_float{f}#8, hire_date{f}#9, is_rehired{f}#10, job_positions{f}#11, languages{f}#12, languages.byte{f}#13, languages.long{f}#14, languages.short{f}#15, last_name{f}#16, salary{f}#17, salary_change{f}#18, salary_change.int{f}#19, salary_change.keyword{f}#20, salary_change.long{f}#21, still_hired{f}#22, language_code{r}#23, language_name{f}#24],false] -\_ProjectExec[[avg_worked_seconds{f}#0, birth_date{f}#1, emp_no{f}#2, first_name{f}#3, gender{f}#4, height{f}#5, height.float{f}#6, height.half_float{f}#7, height.scaled_float{f}#8, hire_date{f}#9, is_rehired{f}#10, job_positions{f}#11, languages{f}#12, languages.byte{f}#13, languages.long{f}#14, languages.short{f}#15, last_name{f}#16, salary{f}#17, salary_change{f}#18, salary_change.int{f}#19, salary_change.keyword{f}#20, salary_change.long{f}#21, still_hired{f}#22, language_code{r}#23, language_name{f}#24]] +ExchangeSinkExec[[avg_worked_seconds{f(EsField)}#0, birth_date{f(DateEsField)}#1, emp_no{f(EsField)}#2, first_name{f(KeywordEsField)}#3, gender{f(KeywordEsField)}#4, height{f(EsField)}#5, height.float{f(EsField)}#6, height.half_float{f(EsField)}#7, height.scaled_float{f(EsField)}#8, hire_date{f(DateEsField)}#9, is_rehired{f(EsField)}#10, job_positions{f(KeywordEsField)}#11, languages{f(EsField)}#12, languages.byte{f(EsField)}#13, languages.long{f(EsField)}#14, languages.short{f(EsField)}#15, last_name{f(KeywordEsField)}#16, salary{f(EsField)}#17, salary_change{f(EsField)}#18, salary_change.int{f(EsField)}#19, salary_change.keyword{f(KeywordEsField)}#20, salary_change.long{f(EsField)}#21, still_hired{f(EsField)}#22, language_code{r}#23, language_name{f(KeywordEsField)}#24],false] +\_ProjectExec[[avg_worked_seconds{f(EsField)}#0, birth_date{f(DateEsField)}#1, emp_no{f(EsField)}#2, first_name{f(KeywordEsField)}#3, gender{f(KeywordEsField)}#4, height{f(EsField)}#5, height.float{f(EsField)}#6, height.half_float{f(EsField)}#7, height.scaled_float{f(EsField)}#8, hire_date{f(DateEsField)}#9, is_rehired{f(EsField)}#10, job_positions{f(KeywordEsField)}#11, languages{f(EsField)}#12, languages.byte{f(EsField)}#13, languages.long{f(EsField)}#14, languages.short{f(EsField)}#15, last_name{f(KeywordEsField)}#16, salary{f(EsField)}#17, salary_change{f(EsField)}#18, salary_change.int{f(EsField)}#19, salary_change.keyword{f(KeywordEsField)}#20, salary_change.long{f(EsField)}#21, still_hired{f(EsField)}#22, language_code{r}#23, language_name{f(KeywordEsField)}#24]] \_FieldExtractExec[avg_worked_seconds{f}#0, birth_date{f}#1, first_name{f}#3, gender{f}#4, height{f}#5, height.float{f}#6, height.half_float{f}#7, height.scaled_float{f}#8, hire_date{f}#9, is_rehired{f}#10, job_positions{f}#11, languages.byte{f}#13, languages.long{f}#14, languages.short{f}#15, last_name{f}#16, salary{f}#17, salary_change{f}#18, salary_change.int{f}#19, salary_change.keyword{f}#20, salary_change.long{f}#21, still_hired{f}#22]<[],[]> - \_TopNExec[[Order[emp_no{f}#2,ASC,LAST]],20[INTEGER],430] - \_ExchangeSourceExec[[_doc{f}#25, emp_no{f}#2, languages{f}#12, language_code{r}#23, language_name{f}#24],false] \ No newline at end of file + \_TopNExec[[Order[emp_no{f(EsField)}#2,ASC,LAST]],20[INTEGER],430] + \_ExchangeSourceExec[[_doc{f(EsField)}#25, emp_no{f(EsField)}#2, languages{f(EsField)}#12, language_code{r}#23, language_name{f(KeywordEsField)}#24],false] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testLookupJoinOnDataNode/physical_optimization.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testLookupJoinOnDataNode/physical_optimization.expected index 438c1c6d34382..dcc47c1a23fed 100644 --- a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testLookupJoinOnDataNode/physical_optimization.expected +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testLookupJoinOnDataNode/physical_optimization.expected @@ -1,10 +1,10 @@ -TopNExec[[Order[emp_no{f}#0,ASC,LAST]],20[INTEGER],null] -\_ExchangeExec[[avg_worked_seconds{f}#1, birth_date{f}#2, emp_no{f}#0, first_name{f}#3, gender{f}#4, height{f}#5, height.float{f}#6, height.half_float{f}#7, height.scaled_float{f}#8, hire_date{f}#9, is_rehired{f}#10, job_positions{f}#11, languages{f}#12, languages.byte{f}#13, languages.long{f}#14, languages.short{f}#15, last_name{f}#16, salary{f}#17, salary_change{f}#18, salary_change.int{f}#19, salary_change.keyword{f}#20, salary_change.long{f}#21, still_hired{f}#22, language_code{r}#23, language_name{f}#24],false] +TopNExec[[Order[emp_no{f(EsField)}#0,ASC,LAST]],20[INTEGER],null] +\_ExchangeExec[[avg_worked_seconds{f(EsField)}#1, birth_date{f(DateEsField)}#2, emp_no{f(EsField)}#0, first_name{f(KeywordEsField)}#3, gender{f(KeywordEsField)}#4, height{f(EsField)}#5, height.float{f(EsField)}#6, height.half_float{f(EsField)}#7, height.scaled_float{f(EsField)}#8, hire_date{f(DateEsField)}#9, is_rehired{f(EsField)}#10, job_positions{f(KeywordEsField)}#11, languages{f(EsField)}#12, languages.byte{f(EsField)}#13, languages.long{f(EsField)}#14, languages.short{f(EsField)}#15, last_name{f(KeywordEsField)}#16, salary{f(EsField)}#17, salary_change{f(EsField)}#18, salary_change.int{f(EsField)}#19, salary_change.keyword{f(KeywordEsField)}#20, salary_change.long{f(EsField)}#21, still_hired{f(EsField)}#22, language_code{r}#23, language_name{f(KeywordEsField)}#24],false] \_FragmentExec[filter=null, estimatedRowSize=0, reducer=[], fragment=[<> -Project[[avg_worked_seconds{f}#1, birth_date{f}#2, emp_no{f}#0, first_name{f}#3, gender{f}#4, height{f}#5, height.float{f}#6, height.half_float{f}#7, height.scaled_float{f}#8, hire_date{f}#9, is_rehired{f}#10, job_positions{f}#11, languages{f}#12, languages.byte{f}#13, languages.long{f}#14, languages.short{f}#15, last_name{f}#16, salary{f}#17, salary_change{f}#18, salary_change.int{f}#19, salary_change.keyword{f}#20, salary_change.long{f}#21, still_hired{f}#22, language_code{r}#23, language_name{f}#24]] -\_TopN[[Order[emp_no{f}#0,ASC,LAST]],20[INTEGER],false] - \_Join[LEFT,[language_code{r}#23],[language_code{f}#25],null] - |_Eval[[languages{f}#12 AS language_code#23]] +Project[[avg_worked_seconds{f(EsField)}#1, birth_date{f(DateEsField)}#2, emp_no{f(EsField)}#0, first_name{f(KeywordEsField)}#3, gender{f(KeywordEsField)}#4, height{f(EsField)}#5, height.float{f(EsField)}#6, height.half_float{f(EsField)}#7, height.scaled_float{f(EsField)}#8, hire_date{f(DateEsField)}#9, is_rehired{f(EsField)}#10, job_positions{f(KeywordEsField)}#11, languages{f(EsField)}#12, languages.byte{f(EsField)}#13, languages.long{f(EsField)}#14, languages.short{f(EsField)}#15, last_name{f(KeywordEsField)}#16, salary{f(EsField)}#17, salary_change{f(EsField)}#18, salary_change.int{f(EsField)}#19, salary_change.keyword{f(KeywordEsField)}#20, salary_change.long{f(EsField)}#21, still_hired{f(EsField)}#22, language_code{r}#23, language_name{f(KeywordEsField)}#24]] +\_TopN[[Order[emp_no{f(EsField)}#0,ASC,LAST]],20[INTEGER],false] + \_Join[LEFT,[language_code{r}#23],[language_code{f(EsField)}#25],null] + |_Eval[[languages{f(EsField)}#12 AS language_code#23]] | \_Filter[emp_no{f}#0 >= 10091[INTEGER] AND emp_no{f}#0 < 10094[INTEGER]] | \_EsRelation[employees][avg_worked_seconds{f}#1, birth_date{f}#2, emp_no{f}#0, first_name{f}#3, gender{f}#4, height{f}#5, height.float{f}#6, height.half_float{f}#7, height.scaled_float{f}#8, hire_date{f}#9, is_rehired{f}#10, job_positions{f}#11, languages{f}#12, languages.byte{f}#13, languages.long{f}#14, languages.short{f}#15, last_name{f}#16, salary{f}#17, salary_change{f}#18, salary_change.int{f}#19, salary_change.keyword{f}#20, salary_change.long{f}#21, still_hired{f}#22] \_EsRelation[languages_lookup][LOOKUP][language_code{f}#25, language_name{f}#24]<>]] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testMultipleFieldSortTopN/local_reduce_physical_optimization_data_driver.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testMultipleFieldSortTopN/local_reduce_physical_optimization_data_driver.expected index e5de0b72a7705..f7582a56ce920 100644 --- a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testMultipleFieldSortTopN/local_reduce_physical_optimization_data_driver.expected +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testMultipleFieldSortTopN/local_reduce_physical_optimization_data_driver.expected @@ -1,4 +1,4 @@ -ExchangeSinkExec[[emp_no{f}#0, height{f}#1, hire_date{f}#2],false] -\_ProjectExec[[_doc{f}#3, hire_date{f}#2, height{f}#1]] +ExchangeSinkExec[[emp_no{f(EsField)}#0, height{f(EsField)}#1, hire_date{f(DateEsField)}#2],false] +\_ProjectExec[[_doc{f(EsField)}#3, hire_date{f(DateEsField)}#2, height{f(EsField)}#1]] \_FieldExtractExec[hire_date{f}#2, height{f}#1]<[],[]> \_EsQueryExec[employees], indexMode[standard], [_doc{f}#3], limit[20], sort[[FieldSort[field=hire_date{f}#2, direction=ASC, nulls=LAST], FieldSort[field=height{f}#1, direction=ASC, nulls=LAST]]] estimatedRowSize[32] queryBuilderAndTags [[QueryBuilderAndTags[query=null, tags=[]]]] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testMultipleFieldSortTopN/local_reduce_planned_data_driver.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testMultipleFieldSortTopN/local_reduce_planned_data_driver.expected index 4866ac15c30c3..b003dc8e5c04a 100644 --- a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testMultipleFieldSortTopN/local_reduce_planned_data_driver.expected +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testMultipleFieldSortTopN/local_reduce_planned_data_driver.expected @@ -1,5 +1,5 @@ -ExchangeSinkExec[[emp_no{f}#0, height{f}#1, hire_date{f}#2],false] +ExchangeSinkExec[[emp_no{f(EsField)}#0, height{f(EsField)}#1, hire_date{f(DateEsField)}#2],false] \_FragmentExec[filter=null, estimatedRowSize=0, reducer=[], fragment=[<> -Project[[_doc{f}#3, hire_date{f}#2, height{f}#1]] -\_TopN[[Order[hire_date{f}#2,ASC,LAST], Order[height{f}#1,ASC,LAST]],20[INTEGER],false] +Project[[_doc{f(EsField)}#3, hire_date{f(DateEsField)}#2, height{f(EsField)}#1]] +\_TopN[[Order[hire_date{f(DateEsField)}#2,ASC,LAST], Order[height{f(EsField)}#1,ASC,LAST]],20[INTEGER],false] \_EsRelation[employees][_doc{f}#3, avg_worked_seconds{f}#4, birth_date{f}#5, emp_no{f}#0, first_name{f}#6, gender{f}#7, height{f}#1, height.float{f}#8, height.half_float{f}#9, height.scaled_float{f}#10, hire_date{f}#2, is_rehired{f}#11, job_positions{f}#12, languages{f}#13, languages.byte{f}#14, languages.long{f}#15, languages.short{f}#16, last_name{f}#17, salary{f}#18, salary_change{f}#19, salary_change.int{f}#20, salary_change.keyword{f}#21, salary_change.long{f}#22, still_hired{f}#23]<>]] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testMultipleFieldSortTopN/local_reduce_planned_reduce_driver.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testMultipleFieldSortTopN/local_reduce_planned_reduce_driver.expected index ab96def3b448c..c9edf368a9a02 100644 --- a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testMultipleFieldSortTopN/local_reduce_planned_reduce_driver.expected +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testMultipleFieldSortTopN/local_reduce_planned_reduce_driver.expected @@ -1,5 +1,5 @@ -ExchangeSinkExec[[emp_no{f}#0, height{f}#1, hire_date{f}#2],false] -\_ProjectExec[[emp_no{f}#0, height{f}#1, hire_date{f}#2]] +ExchangeSinkExec[[emp_no{f(EsField)}#0, height{f(EsField)}#1, hire_date{f(DateEsField)}#2],false] +\_ProjectExec[[emp_no{f(EsField)}#0, height{f(EsField)}#1, hire_date{f(DateEsField)}#2]] \_FieldExtractExec[emp_no{f}#0]<[],[]> - \_TopNExec[[Order[hire_date{f}#2,ASC,LAST], Order[height{f}#1,ASC,LAST]],20[INTEGER],40] - \_ExchangeSourceExec[[_doc{f}#3, hire_date{f}#2, height{f}#1],false] \ No newline at end of file + \_TopNExec[[Order[hire_date{f(DateEsField)}#2,ASC,LAST], Order[height{f(EsField)}#1,ASC,LAST]],20[INTEGER],40] + \_ExchangeSourceExec[[_doc{f(EsField)}#3, hire_date{f(DateEsField)}#2, height{f(EsField)}#1],false] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testMultipleFieldSortTopN/physical_optimization.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testMultipleFieldSortTopN/physical_optimization.expected index 64df823ba0bbf..c2f87bb079ce4 100644 --- a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testMultipleFieldSortTopN/physical_optimization.expected +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testMultipleFieldSortTopN/physical_optimization.expected @@ -1,7 +1,7 @@ -ProjectExec[[hire_date{f}#0, emp_no{f}#1, height{f}#2]] -\_TopNExec[[Order[hire_date{f}#0,ASC,LAST], Order[height{f}#2,ASC,LAST]],20[INTEGER],null] - \_ExchangeExec[[emp_no{f}#1, height{f}#2, hire_date{f}#0],false] +ProjectExec[[hire_date{f(DateEsField)}#0, emp_no{f(EsField)}#1, height{f(EsField)}#2]] +\_TopNExec[[Order[hire_date{f(DateEsField)}#0,ASC,LAST], Order[height{f(EsField)}#2,ASC,LAST]],20[INTEGER],null] + \_ExchangeExec[[emp_no{f(EsField)}#1, height{f(EsField)}#2, hire_date{f(DateEsField)}#0],false] \_FragmentExec[filter=null, estimatedRowSize=0, reducer=[], fragment=[<> -Project[[emp_no{f}#1, height{f}#2, hire_date{f}#0]] -\_TopN[[Order[hire_date{f}#0,ASC,LAST], Order[height{f}#2,ASC,LAST]],20[INTEGER],false] +Project[[emp_no{f(EsField)}#1, height{f(EsField)}#2, hire_date{f(DateEsField)}#0]] +\_TopN[[Order[hire_date{f(DateEsField)}#0,ASC,LAST], Order[height{f(EsField)}#2,ASC,LAST]],20[INTEGER],false] \_EsRelation[employees][avg_worked_seconds{f}#3, birth_date{f}#4, emp_no{f}#1, first_name{f}#5, gender{f}#6, height{f}#2, height.float{f}#7, height.half_float{f}#8, height.scaled_float{f}#9, hire_date{f}#0, is_rehired{f}#10, job_positions{f}#11, languages{f}#12, languages.byte{f}#13, languages.long{f}#14, languages.short{f}#15, last_name{f}#16, salary{f}#17, salary_change{f}#18, salary_change.int{f}#19, salary_change.keyword{f}#20, salary_change.long{f}#21, still_hired{f}#22]<>]] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testMultipleTopN/local_reduce_physical_optimization_data_driver.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testMultipleTopN/local_reduce_physical_optimization_data_driver.expected index 71c01677f83a5..535953e39d9cf 100644 --- a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testMultipleTopN/local_reduce_physical_optimization_data_driver.expected +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testMultipleTopN/local_reduce_physical_optimization_data_driver.expected @@ -1,4 +1,4 @@ -ExchangeSinkExec[[emp_no{f}#0, hire_date{f}#1, salary{f}#2],false] -\_ProjectExec[[_doc{f}#3, hire_date{f}#1]] +ExchangeSinkExec[[emp_no{f(EsField)}#0, hire_date{f(DateEsField)}#1, salary{f(EsField)}#2],false] +\_ProjectExec[[_doc{f(EsField)}#3, hire_date{f(DateEsField)}#1]] \_FieldExtractExec[hire_date{f}#1]<[],[]> \_EsQueryExec[employees], indexMode[standard], [_doc{f}#3], limit[20], sort[[FieldSort[field=hire_date{f}#1, direction=ASC, nulls=LAST]]] estimatedRowSize[24] queryBuilderAndTags [[QueryBuilderAndTags[query=null, tags=[]]]] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testMultipleTopN/local_reduce_planned_data_driver.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testMultipleTopN/local_reduce_planned_data_driver.expected index fc4d011c9a8fb..6b9bd659d3727 100644 --- a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testMultipleTopN/local_reduce_planned_data_driver.expected +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testMultipleTopN/local_reduce_planned_data_driver.expected @@ -1,5 +1,5 @@ -ExchangeSinkExec[[emp_no{f}#0, hire_date{f}#1, salary{f}#2],false] +ExchangeSinkExec[[emp_no{f(EsField)}#0, hire_date{f(DateEsField)}#1, salary{f(EsField)}#2],false] \_FragmentExec[filter=null, estimatedRowSize=0, reducer=[], fragment=[<> -Project[[_doc{f}#3, hire_date{f}#1]] -\_TopN[[Order[hire_date{f}#1,ASC,LAST]],20[INTEGER],false] +Project[[_doc{f(EsField)}#3, hire_date{f(DateEsField)}#1]] +\_TopN[[Order[hire_date{f(DateEsField)}#1,ASC,LAST]],20[INTEGER],false] \_EsRelation[employees][_doc{f}#3, avg_worked_seconds{f}#4, birth_date{f}#5, emp_no{f}#0, first_name{f}#6, gender{f}#7, height{f}#8, height.float{f}#9, height.half_float{f}#10, height.scaled_float{f}#11, hire_date{f}#1, is_rehired{f}#12, job_positions{f}#13, languages{f}#14, languages.byte{f}#15, languages.long{f}#16, languages.short{f}#17, last_name{f}#18, salary{f}#2, salary_change{f}#19, salary_change.int{f}#20, salary_change.keyword{f}#21, salary_change.long{f}#22, still_hired{f}#23]<>]] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testMultipleTopN/local_reduce_planned_reduce_driver.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testMultipleTopN/local_reduce_planned_reduce_driver.expected index 4b4fc0c891ac1..b4351eb176c15 100644 --- a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testMultipleTopN/local_reduce_planned_reduce_driver.expected +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testMultipleTopN/local_reduce_planned_reduce_driver.expected @@ -1,5 +1,5 @@ -ExchangeSinkExec[[emp_no{f}#0, hire_date{f}#1, salary{f}#2],false] -\_ProjectExec[[emp_no{f}#0, hire_date{f}#1, salary{f}#2]] +ExchangeSinkExec[[emp_no{f(EsField)}#0, hire_date{f(DateEsField)}#1, salary{f(EsField)}#2],false] +\_ProjectExec[[emp_no{f(EsField)}#0, hire_date{f(DateEsField)}#1, salary{f(EsField)}#2]] \_FieldExtractExec[emp_no{f}#0, salary{f}#2]<[],[]> - \_TopNExec[[Order[hire_date{f}#1,ASC,LAST]],20[INTEGER],36] - \_ExchangeSourceExec[[_doc{f}#3, hire_date{f}#1],false] \ No newline at end of file + \_TopNExec[[Order[hire_date{f(DateEsField)}#1,ASC,LAST]],20[INTEGER],36] + \_ExchangeSourceExec[[_doc{f(EsField)}#3, hire_date{f(DateEsField)}#1],false] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testMultipleTopN/physical_optimization.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testMultipleTopN/physical_optimization.expected index 92cf16635a7dc..8cf112d600609 100644 --- a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testMultipleTopN/physical_optimization.expected +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testMultipleTopN/physical_optimization.expected @@ -1,8 +1,8 @@ -ProjectExec[[hire_date{f}#0, salary{f}#1, emp_no{f}#2]] -\_TopNExec[[Order[salary{f}#1,ASC,LAST]],10[INTEGER],null] - \_TopNExec[[Order[hire_date{f}#0,ASC,LAST]],20[INTEGER],null] - \_ExchangeExec[[emp_no{f}#2, hire_date{f}#0, salary{f}#1],false] +ProjectExec[[hire_date{f(DateEsField)}#0, salary{f(EsField)}#1, emp_no{f(EsField)}#2]] +\_TopNExec[[Order[salary{f(EsField)}#1,ASC,LAST]],10[INTEGER],null] + \_TopNExec[[Order[hire_date{f(DateEsField)}#0,ASC,LAST]],20[INTEGER],null] + \_ExchangeExec[[emp_no{f(EsField)}#2, hire_date{f(DateEsField)}#0, salary{f(EsField)}#1],false] \_FragmentExec[filter=null, estimatedRowSize=0, reducer=[], fragment=[<> -Project[[emp_no{f}#2, hire_date{f}#0, salary{f}#1]] -\_TopN[[Order[hire_date{f}#0,ASC,LAST]],20[INTEGER],false] +Project[[emp_no{f(EsField)}#2, hire_date{f(DateEsField)}#0, salary{f(EsField)}#1]] +\_TopN[[Order[hire_date{f(DateEsField)}#0,ASC,LAST]],20[INTEGER],false] \_EsRelation[employees][avg_worked_seconds{f}#3, birth_date{f}#4, emp_no{f}#2, first_name{f}#5, gender{f}#6, height{f}#7, height.float{f}#8, height.half_float{f}#9, height.scaled_float{f}#10, hire_date{f}#0, is_rehired{f}#11, job_positions{f}#12, languages{f}#13, languages.byte{f}#14, languages.long{f}#15, languages.short{f}#16, last_name{f}#17, salary{f}#1, salary_change{f}#18, salary_change.int{f}#19, salary_change.keyword{f}#20, salary_change.long{f}#21, still_hired{f}#22]<>]] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testMvExpandBeforeTopN/local_reduce_physical_optimization_data_driver.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testMvExpandBeforeTopN/local_reduce_physical_optimization_data_driver.expected index f0d827b7d0c99..17985e6fc7ff0 100644 --- a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testMvExpandBeforeTopN/local_reduce_physical_optimization_data_driver.expected +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testMvExpandBeforeTopN/local_reduce_physical_optimization_data_driver.expected @@ -1,7 +1,7 @@ -ExchangeSinkExec[[emp_no{f}#0, job_positions{r}#1, salary{f}#2],false] -\_ProjectExec[[emp_no{f}#0, job_positions{r}#1, salary{f}#2]] - \_TopNExec[[Order[salary{f}#2,ASC,LAST]],20[INTEGER],58] - \_MvExpandExec[job_positions{f}#3,job_positions{r}#1] - \_ProjectExec[[emp_no{f}#0, job_positions{f}#3, salary{f}#2]] +ExchangeSinkExec[[emp_no{f(EsField)}#0, job_positions{r}#1, salary{f(EsField)}#2],false] +\_ProjectExec[[emp_no{f(EsField)}#0, job_positions{r}#1, salary{f(EsField)}#2]] + \_TopNExec[[Order[salary{f(EsField)}#2,ASC,LAST]],20[INTEGER],58] + \_MvExpandExec[job_positions{f(KeywordEsField)}#3,job_positions{r}#1] + \_ProjectExec[[emp_no{f(EsField)}#0, job_positions{f(KeywordEsField)}#3, salary{f(EsField)}#2]] \_FieldExtractExec[emp_no{f}#0, job_positions{f}#3, salary{f}#2]<[],[]> \_EsQueryExec[employees], indexMode[standard], [_doc{f}#4], limit[], sort[] estimatedRowSize[62] queryBuilderAndTags [[QueryBuilderAndTags[query=null, tags=[]]]] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testMvExpandBeforeTopN/local_reduce_physical_optimization_reduce_driver.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testMvExpandBeforeTopN/local_reduce_physical_optimization_reduce_driver.expected index a9639e399dec8..5932932aa8946 100644 --- a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testMvExpandBeforeTopN/local_reduce_physical_optimization_reduce_driver.expected +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testMvExpandBeforeTopN/local_reduce_physical_optimization_reduce_driver.expected @@ -1,3 +1,3 @@ -ExchangeSinkExec[[emp_no{f}#0, job_positions{r}#1, salary{f}#2],false] -\_TopNExec[[Order[salary{f}#2,ASC,LAST]],20[INTEGER],58] - \_ExchangeSourceExec[[emp_no{f}#0, job_positions{r}#1, salary{f}#2],false] \ No newline at end of file +ExchangeSinkExec[[emp_no{f(EsField)}#0, job_positions{r}#1, salary{f(EsField)}#2],false] +\_TopNExec[[Order[salary{f(EsField)}#2,ASC,LAST]],20[INTEGER],58] + \_ExchangeSourceExec[[emp_no{f(EsField)}#0, job_positions{r}#1, salary{f(EsField)}#2],false] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testMvExpandBeforeTopN/local_reduce_planned_data_driver.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testMvExpandBeforeTopN/local_reduce_planned_data_driver.expected index baf5e66932990..5f94092df9787 100644 --- a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testMvExpandBeforeTopN/local_reduce_planned_data_driver.expected +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testMvExpandBeforeTopN/local_reduce_planned_data_driver.expected @@ -1,7 +1,7 @@ -ExchangeSinkExec[[emp_no{f}#0, job_positions{r}#1, salary{f}#2],false] +ExchangeSinkExec[[emp_no{f(EsField)}#0, job_positions{r}#1, salary{f(EsField)}#2],false] \_FragmentExec[filter=null, estimatedRowSize=0, reducer=[], fragment=[<> -Project[[emp_no{f}#0, job_positions{r}#1, salary{f}#2]] -\_TopN[[Order[salary{f}#2,ASC,LAST]],20[INTEGER],false] - \_MvExpand[job_positions{f}#3,job_positions{r}#1] - \_Project[[emp_no{f}#0, job_positions{f}#3, salary{f}#2]] +Project[[emp_no{f(EsField)}#0, job_positions{r}#1, salary{f(EsField)}#2]] +\_TopN[[Order[salary{f(EsField)}#2,ASC,LAST]],20[INTEGER],false] + \_MvExpand[job_positions{f(KeywordEsField)}#3,job_positions{r}#1] + \_Project[[emp_no{f(EsField)}#0, job_positions{f(KeywordEsField)}#3, salary{f(EsField)}#2]] \_EsRelation[employees][avg_worked_seconds{f}#4, birth_date{f}#5, emp_no{f}#0, first_name{f}#6, gender{f}#7, height{f}#8, height.float{f}#9, height.half_float{f}#10, height.scaled_float{f}#11, hire_date{f}#12, is_rehired{f}#13, job_positions{f}#3, languages{f}#14, languages.byte{f}#15, languages.long{f}#16, languages.short{f}#17, last_name{f}#18, salary{f}#2, salary_change{f}#19, salary_change.int{f}#20, salary_change.keyword{f}#21, salary_change.long{f}#22, still_hired{f}#23]<>]] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testMvExpandBeforeTopN/local_reduce_planned_reduce_driver.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testMvExpandBeforeTopN/local_reduce_planned_reduce_driver.expected index a9639e399dec8..5932932aa8946 100644 --- a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testMvExpandBeforeTopN/local_reduce_planned_reduce_driver.expected +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testMvExpandBeforeTopN/local_reduce_planned_reduce_driver.expected @@ -1,3 +1,3 @@ -ExchangeSinkExec[[emp_no{f}#0, job_positions{r}#1, salary{f}#2],false] -\_TopNExec[[Order[salary{f}#2,ASC,LAST]],20[INTEGER],58] - \_ExchangeSourceExec[[emp_no{f}#0, job_positions{r}#1, salary{f}#2],false] \ No newline at end of file +ExchangeSinkExec[[emp_no{f(EsField)}#0, job_positions{r}#1, salary{f(EsField)}#2],false] +\_TopNExec[[Order[salary{f(EsField)}#2,ASC,LAST]],20[INTEGER],58] + \_ExchangeSourceExec[[emp_no{f(EsField)}#0, job_positions{r}#1, salary{f(EsField)}#2],false] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testMvExpandBeforeTopN/physical_optimization.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testMvExpandBeforeTopN/physical_optimization.expected index 7bd205fddb3bd..5f66a7ee4c49f 100644 --- a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testMvExpandBeforeTopN/physical_optimization.expected +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testMvExpandBeforeTopN/physical_optimization.expected @@ -1,8 +1,8 @@ -TopNExec[[Order[salary{f}#0,ASC,LAST]],20[INTEGER],null] -\_ExchangeExec[[emp_no{f}#1, job_positions{r}#2, salary{f}#0],false] +TopNExec[[Order[salary{f(EsField)}#0,ASC,LAST]],20[INTEGER],null] +\_ExchangeExec[[emp_no{f(EsField)}#1, job_positions{r}#2, salary{f(EsField)}#0],false] \_FragmentExec[filter=null, estimatedRowSize=0, reducer=[], fragment=[<> -Project[[emp_no{f}#1, job_positions{r}#2, salary{f}#0]] -\_TopN[[Order[salary{f}#0,ASC,LAST]],20[INTEGER],false] - \_MvExpand[job_positions{f}#3,job_positions{r}#2] - \_Project[[emp_no{f}#1, job_positions{f}#3, salary{f}#0]] +Project[[emp_no{f(EsField)}#1, job_positions{r}#2, salary{f(EsField)}#0]] +\_TopN[[Order[salary{f(EsField)}#0,ASC,LAST]],20[INTEGER],false] + \_MvExpand[job_positions{f(KeywordEsField)}#3,job_positions{r}#2] + \_Project[[emp_no{f(EsField)}#1, job_positions{f(KeywordEsField)}#3, salary{f(EsField)}#0]] \_EsRelation[employees][avg_worked_seconds{f}#4, birth_date{f}#5, emp_no{f}#1, first_name{f}#6, gender{f}#7, height{f}#8, height.float{f}#9, height.half_float{f}#10, height.scaled_float{f}#11, hire_date{f}#12, is_rehired{f}#13, job_positions{f}#3, languages{f}#14, languages.byte{f}#15, languages.long{f}#16, languages.short{f}#17, last_name{f}#18, salary{f}#0, salary_change{f}#19, salary_change.int{f}#20, salary_change.keyword{f}#21, salary_change.long{f}#22, still_hired{f}#23]<>]] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testPushedDownTopN/local_reduce_physical_optimization_data_driver.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testPushedDownTopN/local_reduce_physical_optimization_data_driver.expected index cebf3f704c28d..1a1dccc05bae7 100644 --- a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testPushedDownTopN/local_reduce_physical_optimization_data_driver.expected +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testPushedDownTopN/local_reduce_physical_optimization_data_driver.expected @@ -1,4 +1,4 @@ -ExchangeSinkExec[[emp_no{f}#0, height{f}#1],false] -\_ProjectExec[[_doc{f}#2, height{f}#1]] +ExchangeSinkExec[[emp_no{f(EsField)}#0, height{f(EsField)}#1],false] +\_ProjectExec[[_doc{f(EsField)}#2, height{f(EsField)}#1]] \_FieldExtractExec[height{f}#1]<[],[]> \_EsQueryExec[employees], indexMode[standard], [_doc{f}#2], limit[20], sort[[FieldSort[field=height{f}#1, direction=ASC, nulls=LAST]]] estimatedRowSize[24] queryBuilderAndTags [[QueryBuilderAndTags[query=null, tags=[]]]] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testPushedDownTopN/local_reduce_planned_data_driver.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testPushedDownTopN/local_reduce_planned_data_driver.expected index b2913dbdf505b..65dae554c74ef 100644 --- a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testPushedDownTopN/local_reduce_planned_data_driver.expected +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testPushedDownTopN/local_reduce_planned_data_driver.expected @@ -1,5 +1,5 @@ -ExchangeSinkExec[[emp_no{f}#0, height{f}#1],false] +ExchangeSinkExec[[emp_no{f(EsField)}#0, height{f(EsField)}#1],false] \_FragmentExec[filter=null, estimatedRowSize=0, reducer=[], fragment=[<> -Project[[_doc{f}#2, height{f}#1]] -\_TopN[[Order[height{f}#1,ASC,LAST]],20[INTEGER],false] +Project[[_doc{f(EsField)}#2, height{f(EsField)}#1]] +\_TopN[[Order[height{f(EsField)}#1,ASC,LAST]],20[INTEGER],false] \_EsRelation[employees][_doc{f}#2, avg_worked_seconds{f}#3, birth_date{f}#4, emp_no{f}#0, first_name{f}#5, gender{f}#6, height{f}#1, height.float{f}#7, height.half_float{f}#8, height.scaled_float{f}#9, hire_date{f}#10, is_rehired{f}#11, job_positions{f}#12, languages{f}#13, languages.byte{f}#14, languages.long{f}#15, languages.short{f}#16, last_name{f}#17, salary{f}#18, salary_change{f}#19, salary_change.int{f}#20, salary_change.keyword{f}#21, salary_change.long{f}#22, still_hired{f}#23]<>]] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testPushedDownTopN/local_reduce_planned_reduce_driver.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testPushedDownTopN/local_reduce_planned_reduce_driver.expected index 3425364e715c1..3633dfb6c48db 100644 --- a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testPushedDownTopN/local_reduce_planned_reduce_driver.expected +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testPushedDownTopN/local_reduce_planned_reduce_driver.expected @@ -1,5 +1,5 @@ -ExchangeSinkExec[[emp_no{f}#0, height{f}#1],false] -\_ProjectExec[[emp_no{f}#0, height{f}#1]] +ExchangeSinkExec[[emp_no{f(EsField)}#0, height{f(EsField)}#1],false] +\_ProjectExec[[emp_no{f(EsField)}#0, height{f(EsField)}#1]] \_FieldExtractExec[emp_no{f}#0]<[],[]> - \_TopNExec[[Order[height{f}#1,ASC,LAST]],20[INTEGER],32] - \_ExchangeSourceExec[[_doc{f}#2, height{f}#1],false] \ No newline at end of file + \_TopNExec[[Order[height{f(EsField)}#1,ASC,LAST]],20[INTEGER],32] + \_ExchangeSourceExec[[_doc{f(EsField)}#2, height{f(EsField)}#1],false] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testPushedDownTopN/physical_optimization.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testPushedDownTopN/physical_optimization.expected index e659e9ce08d64..66a0e8e8c2995 100644 --- a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testPushedDownTopN/physical_optimization.expected +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testPushedDownTopN/physical_optimization.expected @@ -1,7 +1,7 @@ -ProjectExec[[emp_no{f}#0, height{f}#1]] -\_TopNExec[[Order[height{f}#1,ASC,LAST]],20[INTEGER],null] - \_ExchangeExec[[emp_no{f}#0, height{f}#1],false] +ProjectExec[[emp_no{f(EsField)}#0, height{f(EsField)}#1]] +\_TopNExec[[Order[height{f(EsField)}#1,ASC,LAST]],20[INTEGER],null] + \_ExchangeExec[[emp_no{f(EsField)}#0, height{f(EsField)}#1],false] \_FragmentExec[filter=null, estimatedRowSize=0, reducer=[], fragment=[<> -Project[[emp_no{f}#0, height{f}#1]] -\_TopN[[Order[height{f}#1,ASC,LAST]],20[INTEGER],false] +Project[[emp_no{f(EsField)}#0, height{f(EsField)}#1]] +\_TopN[[Order[height{f(EsField)}#1,ASC,LAST]],20[INTEGER],false] \_EsRelation[employees][avg_worked_seconds{f}#2, birth_date{f}#3, emp_no{f}#0, first_name{f}#4, gender{f}#5, height{f}#1, height.float{f}#6, height.half_float{f}#7, height.scaled_float{f}#8, hire_date{f}#9, is_rehired{f}#10, job_positions{f}#11, languages{f}#12, languages.byte{f}#13, languages.long{f}#14, languages.short{f}#15, last_name{f}#16, salary{f}#17, salary_change{f}#18, salary_change.int{f}#19, salary_change.keyword{f}#20, salary_change.long{f}#21, still_hired{f}#22]<>]] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testSomeFieldsNeededBeforeLateMaterialization/local_reduce_physical_optimization_data_driver.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testSomeFieldsNeededBeforeLateMaterialization/local_reduce_physical_optimization_data_driver.expected index 91fa3beaa5567..2bf1f8cfb7f44 100644 --- a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testSomeFieldsNeededBeforeLateMaterialization/local_reduce_physical_optimization_data_driver.expected +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testSomeFieldsNeededBeforeLateMaterialization/local_reduce_physical_optimization_data_driver.expected @@ -1,5 +1,5 @@ -ExchangeSinkExec[[emp_no{f}#0, hire_date{f}#1, salary{f}#2],false] -\_ProjectExec[[_doc{f}#3, salary{f}#2, hire_date{f}#1]] +ExchangeSinkExec[[emp_no{f(EsField)}#0, hire_date{f(DateEsField)}#1, salary{f(EsField)}#2],false] +\_ProjectExec[[_doc{f(EsField)}#3, salary{f(EsField)}#2, hire_date{f(DateEsField)}#1]] \_FieldExtractExec[salary{f}#2, hire_date{f}#1]<[],[]> \_EsQueryExec[employees], indexMode[standard], [_doc{f}#3], limit[20], sort[[FieldSort[field=hire_date{f}#1, direction=ASC, nulls=LAST]]] estimatedRowSize[28] queryBuilderAndTags [[QueryBuilderAndTags[query={ "esql_single_value" : { diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testSomeFieldsNeededBeforeLateMaterialization/local_reduce_planned_data_driver.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testSomeFieldsNeededBeforeLateMaterialization/local_reduce_planned_data_driver.expected index 1e90a18573c7c..54d4c418762b0 100644 --- a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testSomeFieldsNeededBeforeLateMaterialization/local_reduce_planned_data_driver.expected +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testSomeFieldsNeededBeforeLateMaterialization/local_reduce_planned_data_driver.expected @@ -1,6 +1,6 @@ -ExchangeSinkExec[[emp_no{f}#0, hire_date{f}#1, salary{f}#2],false] +ExchangeSinkExec[[emp_no{f(EsField)}#0, hire_date{f(DateEsField)}#1, salary{f(EsField)}#2],false] \_FragmentExec[filter=null, estimatedRowSize=0, reducer=[], fragment=[<> -Project[[_doc{f}#3, salary{f}#2, hire_date{f}#1]] -\_TopN[[Order[hire_date{f}#1,ASC,LAST]],20[INTEGER],false] +Project[[_doc{f(EsField)}#3, salary{f(EsField)}#2, hire_date{f(DateEsField)}#1]] +\_TopN[[Order[hire_date{f(DateEsField)}#1,ASC,LAST]],20[INTEGER],false] \_Filter[salary{f}#2 > 10000[INTEGER]] \_EsRelation[employees][_doc{f}#3, avg_worked_seconds{f}#4, birth_date{f}#5, emp_no{f}#0, first_name{f}#6, gender{f}#7, height{f}#8, height.float{f}#9, height.half_float{f}#10, height.scaled_float{f}#11, hire_date{f}#1, is_rehired{f}#12, job_positions{f}#13, languages{f}#14, languages.byte{f}#15, languages.long{f}#16, languages.short{f}#17, last_name{f}#18, salary{f}#2, salary_change{f}#19, salary_change.int{f}#20, salary_change.keyword{f}#21, salary_change.long{f}#22, still_hired{f}#23]<>]] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testSomeFieldsNeededBeforeLateMaterialization/local_reduce_planned_reduce_driver.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testSomeFieldsNeededBeforeLateMaterialization/local_reduce_planned_reduce_driver.expected index 178d31ccc5dc1..22b9264fc278a 100644 --- a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testSomeFieldsNeededBeforeLateMaterialization/local_reduce_planned_reduce_driver.expected +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testSomeFieldsNeededBeforeLateMaterialization/local_reduce_planned_reduce_driver.expected @@ -1,5 +1,5 @@ -ExchangeSinkExec[[emp_no{f}#0, hire_date{f}#1, salary{f}#2],false] -\_ProjectExec[[emp_no{f}#0, hire_date{f}#1, salary{f}#2]] +ExchangeSinkExec[[emp_no{f(EsField)}#0, hire_date{f(DateEsField)}#1, salary{f(EsField)}#2],false] +\_ProjectExec[[emp_no{f(EsField)}#0, hire_date{f(DateEsField)}#1, salary{f(EsField)}#2]] \_FieldExtractExec[emp_no{f}#0]<[],[]> - \_TopNExec[[Order[hire_date{f}#1,ASC,LAST]],20[INTEGER],36] - \_ExchangeSourceExec[[_doc{f}#3, salary{f}#2, hire_date{f}#1],false] \ No newline at end of file + \_TopNExec[[Order[hire_date{f(DateEsField)}#1,ASC,LAST]],20[INTEGER],36] + \_ExchangeSourceExec[[_doc{f(EsField)}#3, salary{f(EsField)}#2, hire_date{f(DateEsField)}#1],false] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testSomeFieldsNeededBeforeLateMaterialization/physical_optimization.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testSomeFieldsNeededBeforeLateMaterialization/physical_optimization.expected index 6fc12a53e3980..4b4f50ecdb071 100644 --- a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testSomeFieldsNeededBeforeLateMaterialization/physical_optimization.expected +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testSomeFieldsNeededBeforeLateMaterialization/physical_optimization.expected @@ -1,8 +1,8 @@ -ProjectExec[[hire_date{f}#0, salary{f}#1, emp_no{f}#2]] -\_TopNExec[[Order[hire_date{f}#0,ASC,LAST]],20[INTEGER],null] - \_ExchangeExec[[emp_no{f}#2, hire_date{f}#0, salary{f}#1],false] +ProjectExec[[hire_date{f(DateEsField)}#0, salary{f(EsField)}#1, emp_no{f(EsField)}#2]] +\_TopNExec[[Order[hire_date{f(DateEsField)}#0,ASC,LAST]],20[INTEGER],null] + \_ExchangeExec[[emp_no{f(EsField)}#2, hire_date{f(DateEsField)}#0, salary{f(EsField)}#1],false] \_FragmentExec[filter=null, estimatedRowSize=0, reducer=[], fragment=[<> -Project[[emp_no{f}#2, hire_date{f}#0, salary{f}#1]] -\_TopN[[Order[hire_date{f}#0,ASC,LAST]],20[INTEGER],false] +Project[[emp_no{f(EsField)}#2, hire_date{f(DateEsField)}#0, salary{f(EsField)}#1]] +\_TopN[[Order[hire_date{f(DateEsField)}#0,ASC,LAST]],20[INTEGER],false] \_Filter[salary{f}#1 > 10000[INTEGER]] \_EsRelation[employees][avg_worked_seconds{f}#3, birth_date{f}#4, emp_no{f}#2, first_name{f}#5, gender{f}#6, height{f}#7, height.float{f}#8, height.half_float{f}#9, height.scaled_float{f}#10, hire_date{f}#0, is_rehired{f}#11, job_positions{f}#12, languages{f}#13, languages.byte{f}#14, languages.long{f}#15, languages.short{f}#16, last_name{f}#17, salary{f}#1, salary_change{f}#18, salary_change.int{f}#19, salary_change.keyword{f}#20, salary_change.long{f}#21, still_hired{f}#22]<>]] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testTopNThenStats/local_reduce_physical_optimization_data_driver.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testTopNThenStats/local_reduce_physical_optimization_data_driver.expected index 8dc76dd8b28df..6dafad051ff32 100644 --- a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testTopNThenStats/local_reduce_physical_optimization_data_driver.expected +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testTopNThenStats/local_reduce_physical_optimization_data_driver.expected @@ -1,4 +1,4 @@ -ExchangeSinkExec[[hire_date{f}#0, salary{f}#1],false] -\_ProjectExec[[_doc{f}#2, hire_date{f}#0]] +ExchangeSinkExec[[hire_date{f(DateEsField)}#0, salary{f(EsField)}#1],false] +\_ProjectExec[[_doc{f(EsField)}#2, hire_date{f(DateEsField)}#0]] \_FieldExtractExec[hire_date{f}#0]<[],[]> \_EsQueryExec[employees], indexMode[standard], [_doc{f}#2], limit[20], sort[[FieldSort[field=hire_date{f}#0, direction=ASC, nulls=LAST]]] estimatedRowSize[24] queryBuilderAndTags [[QueryBuilderAndTags[query=null, tags=[]]]] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testTopNThenStats/local_reduce_planned_data_driver.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testTopNThenStats/local_reduce_planned_data_driver.expected index 070d12cb17d93..65eaafe17c343 100644 --- a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testTopNThenStats/local_reduce_planned_data_driver.expected +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testTopNThenStats/local_reduce_planned_data_driver.expected @@ -1,5 +1,5 @@ -ExchangeSinkExec[[hire_date{f}#0, salary{f}#1],false] +ExchangeSinkExec[[hire_date{f(DateEsField)}#0, salary{f(EsField)}#1],false] \_FragmentExec[filter=null, estimatedRowSize=0, reducer=[], fragment=[<> -Project[[_doc{f}#2, hire_date{f}#0]] -\_TopN[[Order[hire_date{f}#0,ASC,LAST]],20[INTEGER],false] +Project[[_doc{f(EsField)}#2, hire_date{f(DateEsField)}#0]] +\_TopN[[Order[hire_date{f(DateEsField)}#0,ASC,LAST]],20[INTEGER],false] \_EsRelation[employees][_doc{f}#2, avg_worked_seconds{f}#3, birth_date{f}#4, emp_no{f}#5, first_name{f}#6, gender{f}#7, height{f}#8, height.float{f}#9, height.half_float{f}#10, height.scaled_float{f}#11, hire_date{f}#0, is_rehired{f}#12, job_positions{f}#13, languages{f}#14, languages.byte{f}#15, languages.long{f}#16, languages.short{f}#17, last_name{f}#18, salary{f}#1, salary_change{f}#19, salary_change.int{f}#20, salary_change.keyword{f}#21, salary_change.long{f}#22, still_hired{f}#23]<>]] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testTopNThenStats/local_reduce_planned_reduce_driver.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testTopNThenStats/local_reduce_planned_reduce_driver.expected index 3c81025a6c14e..a0f7bfca2eddb 100644 --- a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testTopNThenStats/local_reduce_planned_reduce_driver.expected +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testTopNThenStats/local_reduce_planned_reduce_driver.expected @@ -1,5 +1,5 @@ -ExchangeSinkExec[[hire_date{f}#0, salary{f}#1],false] -\_ProjectExec[[hire_date{f}#0, salary{f}#1]] +ExchangeSinkExec[[hire_date{f(DateEsField)}#0, salary{f(EsField)}#1],false] +\_ProjectExec[[hire_date{f(DateEsField)}#0, salary{f(EsField)}#1]] \_FieldExtractExec[salary{f}#1]<[],[]> - \_TopNExec[[Order[hire_date{f}#0,ASC,LAST]],20[INTEGER],32] - \_ExchangeSourceExec[[_doc{f}#2, hire_date{f}#0],false] \ No newline at end of file + \_TopNExec[[Order[hire_date{f(DateEsField)}#0,ASC,LAST]],20[INTEGER],32] + \_ExchangeSourceExec[[_doc{f(EsField)}#2, hire_date{f(DateEsField)}#0],false] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testTopNThenStats/physical_optimization.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testTopNThenStats/physical_optimization.expected index d520dec0664bd..9aac8fbe309dd 100644 --- a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testTopNThenStats/physical_optimization.expected +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testTopNThenStats/physical_optimization.expected @@ -1,10 +1,10 @@ ProjectExec[[avg_salary{r}#0, count{r}#1]] \_EvalExec[[$$SUM$avg_salary$0{r$}#2 / $$COUNT$avg_salary$1{r$}#3 AS avg_salary#0]] \_LimitExec[10000[INTEGER],null] - \_AggregateExec[[],[SUM(salary{f}#4,true[BOOLEAN],PT0S[TIME_DURATION],compensated[KEYWORD]) AS $$SUM$avg_salary$0#2, COUNT(salary{f}#4,true[BOOLEAN],PT0S[TIME_DURATION]) AS $$COUNT$avg_salary$1#3, COUNT(*[KEYWORD],true[BOOLEAN],PT0S[TIME_DURATION]) AS count#1],SINGLE,[$$SUM$avg_salary$0$sum{r}#5, $$SUM$avg_salary$0$seen{r}#6, $$COUNT$avg_salary$1$count{r}#7, $$COUNT$avg_salary$1$seen{r}#8, $$count$count{r}#9, $$count$seen{r}#10],null] - \_TopNExec[[Order[hire_date{f}#11,ASC,LAST]],20[INTEGER],null] - \_ExchangeExec[[hire_date{f}#11, salary{f}#4],false] + \_AggregateExec[[],[SUM(salary{f(EsField)}#4,true[BOOLEAN],PT0S[TIME_DURATION],compensated[KEYWORD]) AS $$SUM$avg_salary$0#2, COUNT(salary{f(EsField)}#4,true[BOOLEAN],PT0S[TIME_DURATION]) AS $$COUNT$avg_salary$1#3, COUNT(*[KEYWORD],true[BOOLEAN],PT0S[TIME_DURATION]) AS count#1],SINGLE,[$$SUM$avg_salary$0$sum{r}#5, $$SUM$avg_salary$0$seen{r}#6, $$COUNT$avg_salary$1$count{r}#7, $$COUNT$avg_salary$1$seen{r}#8, $$count$count{r}#9, $$count$seen{r}#10],null] + \_TopNExec[[Order[hire_date{f(DateEsField)}#11,ASC,LAST]],20[INTEGER],null] + \_ExchangeExec[[hire_date{f(DateEsField)}#11, salary{f(EsField)}#4],false] \_FragmentExec[filter=null, estimatedRowSize=0, reducer=[], fragment=[<> -Project[[hire_date{f}#11, salary{f}#4]] -\_TopN[[Order[hire_date{f}#11,ASC,LAST]],20[INTEGER],false] +Project[[hire_date{f(DateEsField)}#11, salary{f(EsField)}#4]] +\_TopN[[Order[hire_date{f(DateEsField)}#11,ASC,LAST]],20[INTEGER],false] \_EsRelation[employees][avg_worked_seconds{f}#12, birth_date{f}#13, emp_no{f}#14, first_name{f}#15, gender{f}#16, height{f}#17, height.float{f}#18, height.half_float{f}#19, height.scaled_float{f}#20, hire_date{f}#11, is_rehired{f}#21, job_positions{f}#22, languages{f}#23, languages.byte{f}#24, languages.long{f}#25, languages.short{f}#26, last_name{f}#27, salary{f}#4, salary_change{f}#28, salary_change.int{f}#29, salary_change.keyword{f}#30, salary_change.long{f}#31, still_hired{f}#32]<>]] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testTopNWithMissingSortField/local_reduce_physical_optimization_data_driver.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testTopNWithMissingSortField/local_reduce_physical_optimization_data_driver.expected index 0280707cf7711..94b31f194f9c6 100644 --- a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testTopNWithMissingSortField/local_reduce_physical_optimization_data_driver.expected +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testTopNWithMissingSortField/local_reduce_physical_optimization_data_driver.expected @@ -1,4 +1,4 @@ -ExchangeSinkExec[[emp_no{f}#0, hire_date{f}#1, salary{f}#2],false] -\_ProjectExec[[_doc{f}#3, birth_date{r}#4 AS hire_date#1]] +ExchangeSinkExec[[emp_no{f(EsField)}#0, hire_date{f(DateEsField)}#1, salary{f(EsField)}#2],false] +\_ProjectExec[[_doc{f(EsField)}#3, birth_date{r}#4 AS hire_date#1]] \_EvalExec[[null[DATETIME] AS birth_date#4]] \_EsQueryExec[employees], indexMode[standard], [_doc{f}#3], limit[20], sort[] estimatedRowSize[12] queryBuilderAndTags [[QueryBuilderAndTags[query=null, tags=[]]]] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testTopNWithMissingSortField/local_reduce_planned_data_driver.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testTopNWithMissingSortField/local_reduce_planned_data_driver.expected index fc4d011c9a8fb..6b9bd659d3727 100644 --- a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testTopNWithMissingSortField/local_reduce_planned_data_driver.expected +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testTopNWithMissingSortField/local_reduce_planned_data_driver.expected @@ -1,5 +1,5 @@ -ExchangeSinkExec[[emp_no{f}#0, hire_date{f}#1, salary{f}#2],false] +ExchangeSinkExec[[emp_no{f(EsField)}#0, hire_date{f(DateEsField)}#1, salary{f(EsField)}#2],false] \_FragmentExec[filter=null, estimatedRowSize=0, reducer=[], fragment=[<> -Project[[_doc{f}#3, hire_date{f}#1]] -\_TopN[[Order[hire_date{f}#1,ASC,LAST]],20[INTEGER],false] +Project[[_doc{f(EsField)}#3, hire_date{f(DateEsField)}#1]] +\_TopN[[Order[hire_date{f(DateEsField)}#1,ASC,LAST]],20[INTEGER],false] \_EsRelation[employees][_doc{f}#3, avg_worked_seconds{f}#4, birth_date{f}#5, emp_no{f}#0, first_name{f}#6, gender{f}#7, height{f}#8, height.float{f}#9, height.half_float{f}#10, height.scaled_float{f}#11, hire_date{f}#1, is_rehired{f}#12, job_positions{f}#13, languages{f}#14, languages.byte{f}#15, languages.long{f}#16, languages.short{f}#17, last_name{f}#18, salary{f}#2, salary_change{f}#19, salary_change.int{f}#20, salary_change.keyword{f}#21, salary_change.long{f}#22, still_hired{f}#23]<>]] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testTopNWithMissingSortField/local_reduce_planned_reduce_driver.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testTopNWithMissingSortField/local_reduce_planned_reduce_driver.expected index 4b4fc0c891ac1..b4351eb176c15 100644 --- a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testTopNWithMissingSortField/local_reduce_planned_reduce_driver.expected +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testTopNWithMissingSortField/local_reduce_planned_reduce_driver.expected @@ -1,5 +1,5 @@ -ExchangeSinkExec[[emp_no{f}#0, hire_date{f}#1, salary{f}#2],false] -\_ProjectExec[[emp_no{f}#0, hire_date{f}#1, salary{f}#2]] +ExchangeSinkExec[[emp_no{f(EsField)}#0, hire_date{f(DateEsField)}#1, salary{f(EsField)}#2],false] +\_ProjectExec[[emp_no{f(EsField)}#0, hire_date{f(DateEsField)}#1, salary{f(EsField)}#2]] \_FieldExtractExec[emp_no{f}#0, salary{f}#2]<[],[]> - \_TopNExec[[Order[hire_date{f}#1,ASC,LAST]],20[INTEGER],36] - \_ExchangeSourceExec[[_doc{f}#3, hire_date{f}#1],false] \ No newline at end of file + \_TopNExec[[Order[hire_date{f(DateEsField)}#1,ASC,LAST]],20[INTEGER],36] + \_ExchangeSourceExec[[_doc{f(EsField)}#3, hire_date{f(DateEsField)}#1],false] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testTopNWithMissingSortField/physical_optimization.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testTopNWithMissingSortField/physical_optimization.expected index 84b502cae4e25..fac7b0beb280e 100644 --- a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testTopNWithMissingSortField/physical_optimization.expected +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/plugin/golden_tests/LateMaterializationPlannerGoldenTests/testTopNWithMissingSortField/physical_optimization.expected @@ -1,7 +1,7 @@ -ProjectExec[[hire_date{f}#0, salary{f}#1, emp_no{f}#2]] -\_TopNExec[[Order[hire_date{f}#0,ASC,LAST]],20[INTEGER],null] - \_ExchangeExec[[emp_no{f}#2, hire_date{f}#0, salary{f}#1],false] +ProjectExec[[hire_date{f(DateEsField)}#0, salary{f(EsField)}#1, emp_no{f(EsField)}#2]] +\_TopNExec[[Order[hire_date{f(DateEsField)}#0,ASC,LAST]],20[INTEGER],null] + \_ExchangeExec[[emp_no{f(EsField)}#2, hire_date{f(DateEsField)}#0, salary{f(EsField)}#1],false] \_FragmentExec[filter=null, estimatedRowSize=0, reducer=[], fragment=[<> -Project[[emp_no{f}#2, hire_date{f}#0, salary{f}#1]] -\_TopN[[Order[hire_date{f}#0,ASC,LAST]],20[INTEGER],false] +Project[[emp_no{f(EsField)}#2, hire_date{f(DateEsField)}#0, salary{f(EsField)}#1]] +\_TopN[[Order[hire_date{f(DateEsField)}#0,ASC,LAST]],20[INTEGER],false] \_EsRelation[employees][avg_worked_seconds{f}#3, birth_date{f}#4, emp_no{f}#2, first_name{f}#5, gender{f}#6, height{f}#7, height.float{f}#8, height.half_float{f}#9, height.scaled_float{f}#10, hire_date{f}#0, is_rehired{f}#11, job_positions{f}#12, languages{f}#13, languages.byte{f}#14, languages.long{f}#15, languages.short{f}#16, last_name{f}#17, salary{f}#1, salary_change{f}#18, salary_change.int{f}#19, salary_change.keyword{f}#20, salary_change.long{f}#21, still_hired{f}#22]<>]] \ No newline at end of file From 66cb1ed607518e9032b87462e52c2030dfcb016e Mon Sep 17 00:00:00 2001 From: Gal Lalouche Date: Thu, 5 Feb 2026 14:45:33 +0200 Subject: [PATCH 22/25] Add field aliases test --- .../src/main/resources/data/all-types.csv | 7 ++++++- .../src/main/resources/unmapped-load.csv-spec | 19 +++++++++++++++++++ .../xpack/esql/action/EsqlCapabilities.java | 5 +++++ .../elasticsearch/xpack/esql/CsvTests.java | 4 ++++ 4 files changed, 34 insertions(+), 1 deletion(-) diff --git a/x-pack/plugin/esql/qa/testFixtures/src/main/resources/data/all-types.csv b/x-pack/plugin/esql/qa/testFixtures/src/main/resources/data/all-types.csv index b6447d688c9d1..cdb40caa14a81 100644 --- a/x-pack/plugin/esql/qa/testFixtures/src/main/resources/data/all-types.csv +++ b/x-pack/plugin/esql/qa/testFixtures/src/main/resources/data/all-types.csv @@ -1 +1,6 @@ -alias_integer,boolean,byte,constant_keyword-foo,date,date_nanos,double,float,half_float,scaled_float,integer,ip,keyword,long,unsigned_long,short,text,version,wildcard,semantic_text,dense_vector +boolean:boolean,byte:byte,constant_keyword-foo:keyword,date:date,date_nanos:date_nanos,double:double,float:float,half_float:half_float,scaled_float:scaled_float,integer:integer,ip:ip,keyword:keyword,long:long,unsigned_long:unsigned_long,short:short,text:text,version:version,wildcard:keyword +true,1,foo,2024-01-01T00:00:00.000Z,2024-01-01T00:00:00.000000001Z,1.1,1.1,1.1,1.1,1,127.0.0.1,key1,100,100,10,text1,1.0.0,wild1 +false,2,foo,2024-01-02T00:00:00.000Z,2024-01-02T00:00:00.000000002Z,2.2,2.2,2.2,2.2,2,127.0.0.2,key2,200,200,20,text2,2.0.0,wild2 +true,3,foo,2024-01-03T00:00:00.000Z,2024-01-03T00:00:00.000000003Z,3.3,3.3,3.3,3.3,3,127.0.0.3,key3,300,300,30,text3,3.0.0,wild3 +false,4,foo,2024-01-04T00:00:00.000Z,2024-01-04T00:00:00.000000004Z,4.4,4.4,4.4,4.4,4,127.0.0.4,key4,400,400,40,text4,4.0.0,wild4 +true,5,foo,2024-01-05T00:00:00.000Z,2024-01-05T00:00:00.000000005Z,5.5,5.5,5.5,5.5,5,127.0.0.5,key5,500,500,50,text5,5.0.0,wild5 diff --git a/x-pack/plugin/esql/qa/testFixtures/src/main/resources/unmapped-load.csv-spec b/x-pack/plugin/esql/qa/testFixtures/src/main/resources/unmapped-load.csv-spec index b2fff4ffb70b2..d0b808a601540 100644 --- a/x-pack/plugin/esql/qa/testFixtures/src/main/resources/unmapped-load.csv-spec +++ b/x-pack/plugin/esql/qa/testFixtures/src/main/resources/unmapped-load.csv-spec @@ -729,3 +729,22 @@ count(*):long | message::INT:integer 13 | null 1 | 42 ; + +fieldAliasAndNonExistent +required_capability: unmapped_fields +required_capability: optional_fields +required_capability: field_alias_support + +SET unmapped_fields="load"\; +FROM all_types +| KEEP integer, alias_integer, does_not_exist +| SORT integer +; + +integer:integer | alias_integer:integer | does_not_exist:keyword +1 | 1 | null +2 | 2 | null +3 | 3 | null +4 | 4 | null +5 | 5 | null +; diff --git a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/action/EsqlCapabilities.java b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/action/EsqlCapabilities.java index 45b41b9be7b5e..628fb1d47bd5d 100644 --- a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/action/EsqlCapabilities.java +++ b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/action/EsqlCapabilities.java @@ -845,6 +845,11 @@ public enum Cap { */ SOURCE_FIELD_MAPPING, + /** + * Support for field aliases in mappings. + */ + FIELD_ALIAS_SUPPORT, + /** * Allow filter per individual aggregation. */ diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/CsvTests.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/CsvTests.java index 168963a616950..bb3eb9518bd29 100644 --- a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/CsvTests.java +++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/CsvTests.java @@ -350,6 +350,10 @@ public final void test() throws Throwable { "CSV tests cannot currently handle the _source field mapping directives", testCase.requiredCapabilities.contains(EsqlCapabilities.Cap.SOURCE_FIELD_MAPPING.capabilityName()) ); + assumeFalseLogging( + "CSV tests cannot currently handle field aliases in mappings", + testCase.requiredCapabilities.contains(EsqlCapabilities.Cap.FIELD_ALIAS_SUPPORT.capabilityName()) + ); assumeFalseLogging( "CSV tests cannot currently handle scoring that depends on Lucene", testCase.requiredCapabilities.contains(EsqlCapabilities.Cap.METADATA_SCORE.capabilityName()) From 221c4fadfafb16ae2bba149202d13687c512fb04 Mon Sep 17 00:00:00 2001 From: Gal Lalouche Date: Thu, 5 Feb 2026 21:06:16 +0200 Subject: [PATCH 23/25] Stuffs --- .../esql/core/expression/FieldAttribute.java | 1 - .../xpack/esql/core/tree/NodeUtils.java | 1 - .../analysis/AnalyzerUnmappedGoldenTests.java | 117 +++++++++++++----- .../esql/analysis/AnalyzerUnmappedTests.java | 53 ++++++++ .../xpack/esql/optimizer/GoldenTestCase.java | 26 ++-- .../load/analysis.expected | 3 + .../load/query.esql | 2 + .../nullify/analysis.expected | 3 + .../nullify/query.esql | 2 + .../load/analysis.expected | 4 + .../load/query.esql | 2 + .../nullify/analysis.expected | 4 + .../nullify/query.esql | 2 + .../nullify/query.esql | 2 +- .../load/analysis.expected | 5 + .../load/query.esql | 3 + .../nullify/analysis.expected | 6 + .../nullify/query.esql | 3 + .../load/analysis.expected | 5 + .../load/query.esql | 3 + .../nullify/analysis.expected | 6 + .../nullify/query.esql | 3 + .../testFuse/load/analysis.expected | 15 +++ .../testFuse/load/query.esql | 4 + .../testFuse/nullify/analysis.expected | 16 +++ .../testFuse/nullify/query.esql | 4 + .../testFuseLinear/load/analysis.expected | 18 +++ .../testFuseLinear/load/query.esql | 4 + .../testFuseLinear/nullify/analysis.expected | 19 +++ .../testFuseLinear/nullify/query.esql | 4 + .../testFuseWithEval/load/analysis.expected | 16 +++ .../testFuseWithEval/load/query.esql | 4 + .../nullify/analysis.expected | 17 +++ .../testFuseWithEval/nullify/query.esql | 4 + .../testKeep/load/analysis.expected | 5 +- .../testKeep/load/query.esql | 3 +- .../testKeep/nullify/analysis.expected | 7 +- .../testKeep/nullify/query.esql | 3 +- .../testLookupJoin/load/query.esql | 2 +- .../testLookupJoin/nullify/query.esql | 2 +- .../load/analysis.expected | 3 + .../testMappedInOneIndexOnly/load/query.esql | 2 + .../nullify/analysis.expected | 3 + .../nullify/query.esql | 2 + .../load/analysis.expected | 3 + .../load/query.esql | 2 + .../nullify/analysis.expected | 3 + .../nullify/query.esql | 2 + .../load/analysis.expected | 3 + .../load/query.esql | 2 + .../nullify/analysis.expected | 3 + .../nullify/query.esql | 2 + .../load/analysis.expected | 4 + .../load/query.esql | 2 + .../nullify/analysis.expected | 3 + .../nullify/query.esql | 2 + .../testSubqueryKeep/load/query.esql | 3 + .../testSubqueryKeep/nullify/query.esql | 3 + .../load/analysis.expected | 18 +-- .../testSubqueryKeepUnmapped/load/query.esql | 2 +- .../nullify/analysis.expected | 12 +- .../nullify/query.esql | 2 +- .../load/query.esql | 2 + .../nullify/query.esql | 2 + .../sql/qa/server/src/main/resources/apps.csv | 2 +- 65 files changed, 420 insertions(+), 70 deletions(-) create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testDifferentTypesAndUnmapped/load/analysis.expected create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testDifferentTypesAndUnmapped/load/query.esql create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testDifferentTypesAndUnmapped/nullify/analysis.expected create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testDifferentTypesAndUnmapped/nullify/query.esql create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testDifferentTypesAndUnmappedCast/load/analysis.expected create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testDifferentTypesAndUnmappedCast/load/query.esql create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testDifferentTypesAndUnmappedCast/nullify/analysis.expected create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testDifferentTypesAndUnmappedCast/nullify/query.esql create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testDoesNotExistAfterInlineStats/load/analysis.expected create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testDoesNotExistAfterInlineStats/load/query.esql create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testDoesNotExistAfterInlineStats/nullify/analysis.expected create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testDoesNotExistAfterInlineStats/nullify/query.esql create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testDoesNotExistAfterStats/load/analysis.expected create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testDoesNotExistAfterStats/load/query.esql create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testDoesNotExistAfterStats/nullify/analysis.expected create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testDoesNotExistAfterStats/nullify/query.esql create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testFuse/load/analysis.expected create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testFuse/load/query.esql create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testFuse/nullify/analysis.expected create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testFuse/nullify/query.esql create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testFuseLinear/load/analysis.expected create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testFuseLinear/load/query.esql create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testFuseLinear/nullify/analysis.expected create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testFuseLinear/nullify/query.esql create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testFuseWithEval/load/analysis.expected create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testFuseWithEval/load/query.esql create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testFuseWithEval/nullify/analysis.expected create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testFuseWithEval/nullify/query.esql create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testMappedInOneIndexOnly/load/analysis.expected create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testMappedInOneIndexOnly/load/query.esql create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testMappedInOneIndexOnly/nullify/analysis.expected create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testMappedInOneIndexOnly/nullify/query.esql create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testMappedInOneIndexOnlyCast/load/analysis.expected create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testMappedInOneIndexOnlyCast/load/query.esql create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testMappedInOneIndexOnlyCast/nullify/analysis.expected create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testMappedInOneIndexOnlyCast/nullify/query.esql create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testMappedToNonKeywordInOneIndexOnly/load/analysis.expected create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testMappedToNonKeywordInOneIndexOnly/load/query.esql create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testMappedToNonKeywordInOneIndexOnly/nullify/analysis.expected create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testMappedToNonKeywordInOneIndexOnly/nullify/query.esql create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testMappedToNonKeywordInOneIndexOnlyCast/load/analysis.expected create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testMappedToNonKeywordInOneIndexOnlyCast/load/query.esql create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testMappedToNonKeywordInOneIndexOnlyCast/nullify/analysis.expected create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testMappedToNonKeywordInOneIndexOnlyCast/nullify/query.esql create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testSubqueryKeep/load/query.esql create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testSubqueryKeep/nullify/query.esql create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testTBucketFromIndexWithoutMappedTimestamp/load/query.esql create mode 100644 x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testTBucketFromIndexWithoutMappedTimestamp/nullify/query.esql diff --git a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/core/expression/FieldAttribute.java b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/core/expression/FieldAttribute.java index 28dec3ad94a2a..14e1e9c6c094d 100644 --- a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/core/expression/FieldAttribute.java +++ b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/core/expression/FieldAttribute.java @@ -275,7 +275,6 @@ public EsField field() { @Override public String nodeString(NodeStringFormat format) { return switch (format) { - // FIXME(gal, NOCOMMIT) unhack case FULL -> Strings.format( "%s{%s(%s)%s}#%s".formatted(qualifiedName(), label(), field.getWriteableName(), synthetic() ? "$" : "", id()) ); diff --git a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/core/tree/NodeUtils.java b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/core/tree/NodeUtils.java index ed453bedbacf6..6874b869ec872 100644 --- a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/core/tree/NodeUtils.java +++ b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/core/tree/NodeUtils.java @@ -62,7 +62,6 @@ public static String diffString(String left, String right) { public static String toString(Collection c, Node.NodeStringFormat format) { return switch (format) { case LIMITED -> limitedToString(c); - // FIXME(gal, NOCOMMIT) This need to pass format to c as well case FULL -> unlimitedToString(c); }; } diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/analysis/AnalyzerUnmappedGoldenTests.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/analysis/AnalyzerUnmappedGoldenTests.java index 089a16a868bef..8aad5cdec6b1c 100644 --- a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/analysis/AnalyzerUnmappedGoldenTests.java +++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/analysis/AnalyzerUnmappedGoldenTests.java @@ -11,8 +11,7 @@ import org.elasticsearch.xpack.esql.optimizer.GoldenTestCase; import java.util.EnumSet; - -import static org.elasticsearch.xpack.esql.EsqlTestUtils.withDefaultLimitWarning; +import java.util.Optional; /** * Golden tests for analyzer behavior with unmapped fields using SET unmapped_fields="nullify" and "load". @@ -24,7 +23,8 @@ public class AnalyzerUnmappedGoldenTests extends GoldenTestCase { public void testKeep() throws Exception { runTests(""" FROM employees - | KEEP does_not_exist_field + | eval x = does_not_exist_field :: version + | keep x """); } @@ -164,6 +164,14 @@ public void testStatsBy() throws Exception { """); } + public void testDoesNotExistAfterInlineStats() throws Exception { + runTests(""" + FROM employees + | INLINE STATS COUNT(*) BY emp_no + | EVAL x = does_not_exist_field + """); + } + public void testStatsSumBy() throws Exception { runTests(""" FROM employees @@ -266,7 +274,7 @@ public void testMvExpand() throws Exception { public void testLookupJoin() throws Exception { runTests(""" FROM employees - | EVAL language_code = does_not_exist::INTEGER + | EVAL language_code = does_not_exist :: INTEGER | LOOKUP JOIN languages_lookup ON language_code """); } @@ -282,7 +290,7 @@ public void testLookupJoinWithFilter() throws Exception { public void testSubqueryKeepUnmapped() throws Exception { runTests(""" - FROM employees, (FROM languages | KEEP language_code, does_not_exist) + FROM employees, (FROM languages | KEEP language_code) | KEEP emp_no, language_code, does_not_exist """); } @@ -327,6 +335,36 @@ public void testForkWithStats() throws Exception { """); } + public void testFuse() throws Exception { + assumeTrue("requires FUSE capability", EsqlCapabilities.Cap.FUSE_V6.isEnabled()); + runTests(""" + FROM employees METADATA _score, _index, _id + | FORK (WHERE does_not_exist::LONG > 0) + (WHERE emp_no > 0) + | FUSE + """); + } + + public void testFuseWithEval() throws Exception { + assumeTrue("requires FUSE capability", EsqlCapabilities.Cap.FUSE_V6.isEnabled()); + runTests(""" + FROM employees METADATA _score, _index, _id + | FORK (EVAL x = does_not_exist::DOUBLE + 1) + (EVAL y = emp_no + 1) + | FUSE RRF + """); + } + + public void testFuseLinear() throws Exception { + assumeTrue("requires FUSE capability", EsqlCapabilities.Cap.FUSE_V6.isEnabled()); + runTests(""" + FROM employees METADATA _score, _index, _id + | FORK (WHERE does_not_exist::LONG > 0 | EVAL x = 1) + (WHERE emp_no > 0 | EVAL y = 2) + | FUSE LINEAR + """); + } + public void testCoalesce() throws Exception { runTests(""" FROM employees @@ -356,8 +394,6 @@ public void testTimeSeriesRateUnmapped() throws Exception { """); } - // TODO add one for text - public void testTimeSeriesFirstOverTimeUnmapped() throws Exception { runTests(""" TS k8s @@ -372,39 +408,47 @@ public void testPartiallyMappedField() throws Exception { """); } - public void testPartiallyMappedFieldWithStats() throws Exception { + public void testMappedInOneIndexOnly() throws Exception { runTests(""" - FROM sample_data, partial_mapping_sample_data - | STATS c = COUNT(*) BY unmapped_message + FROM sample_data, no_mapping_sample_data + | KEEP message """); } - public void testPartiallyMappedFieldWithEval() throws Exception { + public void testMappedInOneIndexOnlyCast() throws Exception { runTests(""" - FROM sample_data, partial_mapping_sample_data - | EVAL x = COALESCE(unmapped_message, "missing") - | KEEP @timestamp, x, does_not_exist + FROM sample_data, no_mapping_sample_data + | EVAL x = message :: LONG """); } - public void testDifferentTypesAcrossIndices() throws Exception { + public void testMappedToNonKeywordInOneIndexOnly() throws Exception { runTests(""" - FROM sample_data, sample_data_ts_long - | KEEP @timestamp, message, does_not_exist + FROM sample_data, no_mapping_sample_data + | KEEP event_duration """); } - public void testDifferentTypesWithCast() throws Exception { + @AwaitsFix(bugUrl = "https://github.com/elastic/elasticsearch/pull/141912") + public void testMappedToNonKeywordInOneIndexOnlyCast() throws Exception { runTests(""" - FROM sample_data, sample_data_ts_long - | EVAL ts = @timestamp::STRING - | KEEP ts, message, does_not_exist + FROM sample_data, no_mapping_sample_data + | EVAL x = event_duration :: DOUBLE """); } - @Override - protected java.util.List filteredWarnings() { - return withDefaultLimitWarning(super.filteredWarnings()); + public void testDifferentTypesAndUnmapped() throws Exception { + runTests(""" + FROM sample_data, sample_data_ts_long, no_mapping_sample_data + | KEEP @timestamp + """); + } + + public void testDifferentTypesAndUnmappedCast() throws Exception { + runTests(""" + FROM sample_data, sample_data_ts_long, no_mapping_sample_data + | EVAL x = @timestamp :: DOUBLE + """); } private static String setUnmappedNullify(String query) { @@ -416,15 +460,26 @@ private static String setUnmappedLoad(String query) { } private void runTests(String query) { - runTestsNullifyOnly(query); - if (EsqlCapabilities.Cap.OPTIONAL_FIELDS.isEnabled()) { - builder(setUnmappedLoad(query)).nestedPath("load").stages(STAGES).run(); + var nullifyException = runTestsNullifyOnly(query); + var loadException = runTestsLoadOnly(query); + if (nullifyException.isPresent() && loadException.isPresent()) { + throw new AssertionError("Both nullify and load modes failed", nullifyException.get()); + } else if (nullifyException.isPresent()) { + throw new AssertionError("Nullify mode failed (but load succeeded)", nullifyException.get()); + } else if (loadException.isPresent()) { + throw new AssertionError("Load mode failed (but nullify succeeded)", loadException.get()); } } - private void runTestsNullifyOnly(String query) { - if (EsqlCapabilities.Cap.OPTIONAL_FIELDS_NULLIFY_TECH_PREVIEW.isEnabled()) { - builder(setUnmappedNullify(query)).nestedPath("nullify").stages(STAGES).run(); - } + private Optional runTestsNullifyOnly(String query) { + return EsqlCapabilities.Cap.OPTIONAL_FIELDS_NULLIFY_TECH_PREVIEW.isEnabled() + ? builder(setUnmappedNullify(query)).nestedPath("nullify").stages(STAGES).tryRun() + : Optional.empty(); + } + + private Optional runTestsLoadOnly(String query) { + return EsqlCapabilities.Cap.OPTIONAL_FIELDS.isEnabled() + ? builder(setUnmappedLoad(query)).nestedPath("load").stages(STAGES).tryRun() + : Optional.empty(); } } diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/analysis/AnalyzerUnmappedTests.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/analysis/AnalyzerUnmappedTests.java index d2b8bdf2af5bb..7c8d614902616 100644 --- a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/analysis/AnalyzerUnmappedTests.java +++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/analysis/AnalyzerUnmappedTests.java @@ -912,6 +912,17 @@ public void testFailStatsThenEval() { verificationFailure(setUnmappedLoad(query), failure); } + public void testFailStatsThenEvalExistingField() { + var query = """ + FROM test + | STATS cnt = COUNT(*) + | EVAL x = emp_no + """; + var failure = "line 3:12: Unknown column [emp_no]"; + verificationFailure(setUnmappedNullify(query), failure); + verificationFailure(setUnmappedLoad(query), failure); + } + /* * Limit[1000[INTEGER],false,false] * \_Aggregate[[],[COUNT(does_not_exist_field{r}#18,true[BOOLEAN],PT0S[TIME_DURATION]) AS cnt#5]] @@ -3193,6 +3204,17 @@ public void testLookupJoin() { assertThat(rightRel.indexPattern(), is("languages_lookup")); } + public void testFailLookupJoinWithoutCast() { + String query = """ + FROM test + | EVAL language_code = does_not_exist + | LOOKUP JOIN languages_lookup ON language_code + """; + var failure = "is incompatible with right field [language_code] of type [INTEGER]"; + verificationFailure(setUnmappedNullify(query), failure); + verificationFailure(setUnmappedLoad(query), failure); + } + /* * Limit[1000[INTEGER],false,false] * \_Enrich[ANY,languages[KEYWORD],x{r}#5,{"match":{"indices":[],"match_field":"language_code", @@ -3268,6 +3290,26 @@ public void testSemanticText() { assertThat(relation.indexPattern(), is("test")); } + public void testFailSemanticTextLoad() { + String query = """ + FROM test + | WHERE KNN(does_not_exist, [0, 1, 2]) + """; + var failure = "first argument of [KNN(does_not_exist, [0, 1, 2])] must be [dense_vector, null, text], " + + "found value [does_not_exist] type [keyword]"; + verificationFailure(setUnmappedLoad(query), failure); + } + + public void testFailRateLoad() { + String query = """ + TS k8s + | STATS max(rate(does_not_exist)) + """; + var failure = "first argument of [rate(does_not_exist)] must be [counter_long, counter_integer or counter_double], " + + "found value [does_not_exist] type [keyword]"; + verificationFailure(setUnmappedLoad(query), failure); + } + /* * Limit[1000[INTEGER],false,false] * \_Project[[x{r}#4, does_not_exist_field1{r}#12, y{r}#8, does_not_exist_field2{r}#14]] @@ -3317,6 +3359,17 @@ public void testChangedTimestmapFieldWithRate() { """), "3:13: [rate(network.total_cost)] " + UnresolvedTimestamp.UNRESOLVED_SUFFIX); } + // This test verifies that we do not allow an unmapped @timestamp fields in tbucket. + public void testFailNoUnmappedTimestamp() throws Exception { + String query = (""" + FROM employees + | STATS c = COUNT(*) BY tbucket(1 hour) + """); + var failure = "[tbucket(1 hour)] requires the [@timestamp] field"; + verificationFailure(setUnmappedNullify(query), failure); + verificationFailure(setUnmappedLoad(query), failure); + } + private void verificationFailure(String statement, String expectedFailure) { var e = expectThrows(VerificationException.class, () -> analyzeStatement(statement)); assertThat(e.getMessage(), containsString(expectedFailure)); diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/optimizer/GoldenTestCase.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/optimizer/GoldenTestCase.java index 387da6f8f0824..4d0bbc3995745 100644 --- a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/optimizer/GoldenTestCase.java +++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/optimizer/GoldenTestCase.java @@ -58,6 +58,7 @@ import java.util.HashMap; import java.util.List; import java.util.Map; +import java.util.Optional; import java.util.function.Function; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -174,6 +175,15 @@ public TestBuilder transportVersion(TransportVersion transportVersion) { public void run() { runGoldenTest(esqlQuery, stages, searchStats, transportVersion, nestedPath); } + + public Optional tryRun() { + try { + run(); + return Optional.empty(); + } catch (Throwable e) { + return Optional.of(e); + } + } } private record Test( @@ -201,7 +211,7 @@ private void doTest() { private List> doTests() throws IOException { var statement = EsqlParser.INSTANCE.createStatement(esqlQuery); var parsedPlan = statement.plan(); - Files.createDirectories(PathUtils.get(basePath.toString(), pathArray(0))); + Files.createDirectories(outputPath()); Files.writeString(outputPath("query.esql"), esqlQuery); var analyzer = new Analyzer( new AnalyzerContext( @@ -303,12 +313,12 @@ private List> doTests() throws IOException { return result; } - // FIXME(gal, NOCOMMIT) Not a fan of this signature - private String[] pathArray(int extraElements) { - var paths = new String[nestedPath.length + 1 + extraElements]; + private Path outputPath(String... extraArrayElements) { + var paths = new String[nestedPath.length + 1 + extraArrayElements.length]; paths[0] = testName; System.arraycopy(nestedPath, 0, paths, 1, nestedPath.length); - return paths; + System.arraycopy(extraArrayElements, 0, paths, 1 + nestedPath.length, extraArrayElements.length); + return PathUtils.get(basePath.toString(), paths); } private enum TestResult { @@ -368,12 +378,6 @@ private Path expectedOutputPath(String stageName) { return outputPath(stageName + ".expected"); } - private Path outputPath(String fileName) { - var paths = pathArray(1); - paths[paths.length - 1] = fileName; - return PathUtils.get(basePath.toString(), paths); - } - private PhysicalPlan localOptimize(PhysicalPlan plan, Configuration conf) { return PlannerUtils.localPlan( EsqlTestUtils.TEST_PLANNER_SETTINGS, diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testDifferentTypesAndUnmapped/load/analysis.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testDifferentTypesAndUnmapped/load/analysis.expected new file mode 100644 index 0000000000000..338fc3701e44c --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testDifferentTypesAndUnmapped/load/analysis.expected @@ -0,0 +1,3 @@ +Limit[1000[INTEGER],false,false] +\_Project[[!@timestamp]] + \_EsRelation[sample_data,sample_data_ts_long,no_mapping_sample_data][!@timestamp, client_ip{f}#0, event_duration{f}#1, message{f}#2] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testDifferentTypesAndUnmapped/load/query.esql b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testDifferentTypesAndUnmapped/load/query.esql new file mode 100644 index 0000000000000..1e55cfb1096c9 --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testDifferentTypesAndUnmapped/load/query.esql @@ -0,0 +1,2 @@ +SET unmapped_fields="load"; FROM sample_data, sample_data_ts_long, no_mapping_sample_data +| KEEP @timestamp diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testDifferentTypesAndUnmapped/nullify/analysis.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testDifferentTypesAndUnmapped/nullify/analysis.expected new file mode 100644 index 0000000000000..338fc3701e44c --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testDifferentTypesAndUnmapped/nullify/analysis.expected @@ -0,0 +1,3 @@ +Limit[1000[INTEGER],false,false] +\_Project[[!@timestamp]] + \_EsRelation[sample_data,sample_data_ts_long,no_mapping_sample_data][!@timestamp, client_ip{f}#0, event_duration{f}#1, message{f}#2] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testDifferentTypesAndUnmapped/nullify/query.esql b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testDifferentTypesAndUnmapped/nullify/query.esql new file mode 100644 index 0000000000000..75305542ab2b0 --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testDifferentTypesAndUnmapped/nullify/query.esql @@ -0,0 +1,2 @@ +SET unmapped_fields="nullify"; FROM sample_data, sample_data_ts_long, no_mapping_sample_data +| KEEP @timestamp diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testDifferentTypesAndUnmappedCast/load/analysis.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testDifferentTypesAndUnmappedCast/load/analysis.expected new file mode 100644 index 0000000000000..1f2cf5e16ad87 --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testDifferentTypesAndUnmappedCast/load/analysis.expected @@ -0,0 +1,4 @@ +Project[[!@timestamp, client_ip{f(EsField)}#0, event_duration{f(EsField)}#1, message{f(KeywordEsField)}#2, x{r}#3]] +\_Limit[1000[INTEGER],false,false] + \_Eval[[$$@timestamp$converted_to$double{f(MultiTypeEsField)$}#4 AS x#3]] + \_EsRelation[sample_data,sample_data_ts_long,no_mapping_sample_data][!@timestamp, client_ip{f}#0, event_duration{f}#1, message{f}#2, $$@timestamp$converted_to$double{f$}#4] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testDifferentTypesAndUnmappedCast/load/query.esql b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testDifferentTypesAndUnmappedCast/load/query.esql new file mode 100644 index 0000000000000..b6749814f782a --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testDifferentTypesAndUnmappedCast/load/query.esql @@ -0,0 +1,2 @@ +SET unmapped_fields="load"; FROM sample_data, sample_data_ts_long, no_mapping_sample_data +| EVAL x = @timestamp :: DOUBLE diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testDifferentTypesAndUnmappedCast/nullify/analysis.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testDifferentTypesAndUnmappedCast/nullify/analysis.expected new file mode 100644 index 0000000000000..1f2cf5e16ad87 --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testDifferentTypesAndUnmappedCast/nullify/analysis.expected @@ -0,0 +1,4 @@ +Project[[!@timestamp, client_ip{f(EsField)}#0, event_duration{f(EsField)}#1, message{f(KeywordEsField)}#2, x{r}#3]] +\_Limit[1000[INTEGER],false,false] + \_Eval[[$$@timestamp$converted_to$double{f(MultiTypeEsField)$}#4 AS x#3]] + \_EsRelation[sample_data,sample_data_ts_long,no_mapping_sample_data][!@timestamp, client_ip{f}#0, event_duration{f}#1, message{f}#2, $$@timestamp$converted_to$double{f$}#4] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testDifferentTypesAndUnmappedCast/nullify/query.esql b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testDifferentTypesAndUnmappedCast/nullify/query.esql new file mode 100644 index 0000000000000..e486841e2f785 --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testDifferentTypesAndUnmappedCast/nullify/query.esql @@ -0,0 +1,2 @@ +SET unmapped_fields="nullify"; FROM sample_data, sample_data_ts_long, no_mapping_sample_data +| EVAL x = @timestamp :: DOUBLE diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testDifferentTypesWithCast/nullify/query.esql b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testDifferentTypesWithCast/nullify/query.esql index ab8c59e257e6d..ba866b39d02b5 100644 --- a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testDifferentTypesWithCast/nullify/query.esql +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testDifferentTypesWithCast/nullify/query.esql @@ -1,3 +1,3 @@ -SET unmapped_fields="nullify"; FROM sample_data, sample_data_ts_long +SET unmapped_fields="nullify"; FROM sample_data, sample_data_ts_long, employees | EVAL ts = @timestamp::STRING | KEEP ts, message, does_not_exist diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testDoesNotExistAfterInlineStats/load/analysis.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testDoesNotExistAfterInlineStats/load/analysis.expected new file mode 100644 index 0000000000000..13558bfef2002 --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testDoesNotExistAfterInlineStats/load/analysis.expected @@ -0,0 +1,5 @@ +Limit[1000[INTEGER],false,false] +\_Eval[[does_not_exist_field{f(PotentiallyUnmappedKeywordEsField)}#0 AS x#1]] + \_InlineStats[] + \_Aggregate[[emp_no{f(EsField)}#2],[COUNT(*[KEYWORD],true[BOOLEAN],PT0S[TIME_DURATION]) AS COUNT(*)#3, emp_no{f(EsField)}#2]] + \_EsRelation[employees][avg_worked_seconds{f}#4, birth_date{f}#5, emp_no{f}#2, first_name{f}#6, gender{f}#7, height{f}#8, height.float{f}#9, height.half_float{f}#10, height.scaled_float{f}#11, hire_date{f}#12, is_rehired{f}#13, job_positions{f}#14, languages{f}#15, languages.byte{f}#16, languages.long{f}#17, languages.short{f}#18, last_name{f}#19, salary{f}#20, salary_change{f}#21, salary_change.int{f}#22, salary_change.keyword{f}#23, salary_change.long{f}#24, still_hired{f}#25, does_not_exist_field{f}#0] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testDoesNotExistAfterInlineStats/load/query.esql b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testDoesNotExistAfterInlineStats/load/query.esql new file mode 100644 index 0000000000000..4148af41e94f6 --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testDoesNotExistAfterInlineStats/load/query.esql @@ -0,0 +1,3 @@ +SET unmapped_fields="load"; FROM employees +| INLINE STATS COUNT(*) BY emp_no +| EVAL x = does_not_exist_field diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testDoesNotExistAfterInlineStats/nullify/analysis.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testDoesNotExistAfterInlineStats/nullify/analysis.expected new file mode 100644 index 0000000000000..bbfb54572a2cb --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testDoesNotExistAfterInlineStats/nullify/analysis.expected @@ -0,0 +1,6 @@ +Limit[1000[INTEGER],false,false] +\_Eval[[does_not_exist_field{r}#0 AS x#1]] + \_InlineStats[] + \_Aggregate[[emp_no{f(EsField)}#2],[COUNT(*[KEYWORD],true[BOOLEAN],PT0S[TIME_DURATION]) AS COUNT(*)#3, emp_no{f(EsField)}#2]] + \_Eval[[null[NULL] AS does_not_exist_field#0]] + \_EsRelation[employees][avg_worked_seconds{f}#4, birth_date{f}#5, emp_no{f}#2, first_name{f}#6, gender{f}#7, height{f}#8, height.float{f}#9, height.half_float{f}#10, height.scaled_float{f}#11, hire_date{f}#12, is_rehired{f}#13, job_positions{f}#14, languages{f}#15, languages.byte{f}#16, languages.long{f}#17, languages.short{f}#18, last_name{f}#19, salary{f}#20, salary_change{f}#21, salary_change.int{f}#22, salary_change.keyword{f}#23, salary_change.long{f}#24, still_hired{f}#25] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testDoesNotExistAfterInlineStats/nullify/query.esql b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testDoesNotExistAfterInlineStats/nullify/query.esql new file mode 100644 index 0000000000000..00cb535f496f9 --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testDoesNotExistAfterInlineStats/nullify/query.esql @@ -0,0 +1,3 @@ +SET unmapped_fields="nullify"; FROM employees +| INLINE STATS COUNT(*) BY emp_no +| EVAL x = does_not_exist_field diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testDoesNotExistAfterStats/load/analysis.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testDoesNotExistAfterStats/load/analysis.expected new file mode 100644 index 0000000000000..13558bfef2002 --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testDoesNotExistAfterStats/load/analysis.expected @@ -0,0 +1,5 @@ +Limit[1000[INTEGER],false,false] +\_Eval[[does_not_exist_field{f(PotentiallyUnmappedKeywordEsField)}#0 AS x#1]] + \_InlineStats[] + \_Aggregate[[emp_no{f(EsField)}#2],[COUNT(*[KEYWORD],true[BOOLEAN],PT0S[TIME_DURATION]) AS COUNT(*)#3, emp_no{f(EsField)}#2]] + \_EsRelation[employees][avg_worked_seconds{f}#4, birth_date{f}#5, emp_no{f}#2, first_name{f}#6, gender{f}#7, height{f}#8, height.float{f}#9, height.half_float{f}#10, height.scaled_float{f}#11, hire_date{f}#12, is_rehired{f}#13, job_positions{f}#14, languages{f}#15, languages.byte{f}#16, languages.long{f}#17, languages.short{f}#18, last_name{f}#19, salary{f}#20, salary_change{f}#21, salary_change.int{f}#22, salary_change.keyword{f}#23, salary_change.long{f}#24, still_hired{f}#25, does_not_exist_field{f}#0] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testDoesNotExistAfterStats/load/query.esql b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testDoesNotExistAfterStats/load/query.esql new file mode 100644 index 0000000000000..4148af41e94f6 --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testDoesNotExistAfterStats/load/query.esql @@ -0,0 +1,3 @@ +SET unmapped_fields="load"; FROM employees +| INLINE STATS COUNT(*) BY emp_no +| EVAL x = does_not_exist_field diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testDoesNotExistAfterStats/nullify/analysis.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testDoesNotExistAfterStats/nullify/analysis.expected new file mode 100644 index 0000000000000..bbfb54572a2cb --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testDoesNotExistAfterStats/nullify/analysis.expected @@ -0,0 +1,6 @@ +Limit[1000[INTEGER],false,false] +\_Eval[[does_not_exist_field{r}#0 AS x#1]] + \_InlineStats[] + \_Aggregate[[emp_no{f(EsField)}#2],[COUNT(*[KEYWORD],true[BOOLEAN],PT0S[TIME_DURATION]) AS COUNT(*)#3, emp_no{f(EsField)}#2]] + \_Eval[[null[NULL] AS does_not_exist_field#0]] + \_EsRelation[employees][avg_worked_seconds{f}#4, birth_date{f}#5, emp_no{f}#2, first_name{f}#6, gender{f}#7, height{f}#8, height.float{f}#9, height.half_float{f}#10, height.scaled_float{f}#11, hire_date{f}#12, is_rehired{f}#13, job_positions{f}#14, languages{f}#15, languages.byte{f}#16, languages.long{f}#17, languages.short{f}#18, last_name{f}#19, salary{f}#20, salary_change{f}#21, salary_change.int{f}#22, salary_change.keyword{f}#23, salary_change.long{f}#24, still_hired{f}#25] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testDoesNotExistAfterStats/nullify/query.esql b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testDoesNotExistAfterStats/nullify/query.esql new file mode 100644 index 0000000000000..98bbe99592e9a --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testDoesNotExistAfterStats/nullify/query.esql @@ -0,0 +1,3 @@ +SET unmapped_fields="nullify"; FROM employees +| STATS COUNT(*) BY emp_no +| EVAL x = salary diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testFuse/load/analysis.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testFuse/load/analysis.expected new file mode 100644 index 0000000000000..f34822d2c1c68 --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testFuse/load/analysis.expected @@ -0,0 +1,15 @@ +Limit[1000[INTEGER],false,false] +\_Aggregate[[_id{r}#0, _index{r}#1],[SUM(_score{r}#2,true[BOOLEAN],PT0S[TIME_DURATION],compensated[KEYWORD]) AS _score#3, VALUES(avg_worked_seconds{r}#4,true[BOOLEAN],PT0S[TIME_DURATION]) AS avg_worked_seconds#5, VALUES(birth_date{r}#6,true[BOOLEAN],PT0S[TIME_DURATION]) AS birth_date#7, VALUES(emp_no{r}#8,true[BOOLEAN],PT0S[TIME_DURATION]) AS emp_no#9, VALUES(first_name{r}#10,true[BOOLEAN],PT0S[TIME_DURATION]) AS first_name#11, VALUES(gender{r}#12,true[BOOLEAN],PT0S[TIME_DURATION]) AS gender#13, VALUES(height{r}#14,true[BOOLEAN],PT0S[TIME_DURATION]) AS height#15, VALUES(height.float{r}#16,true[BOOLEAN],PT0S[TIME_DURATION]) AS height.float#17, VALUES(height.half_float{r}#18,true[BOOLEAN],PT0S[TIME_DURATION]) AS height.half_float#19, VALUES(height.scaled_float{r}#20,true[BOOLEAN],PT0S[TIME_DURATION]) AS height.scaled_float#21, VALUES(hire_date{r}#22,true[BOOLEAN],PT0S[TIME_DURATION]) AS hire_date#23, VALUES(is_rehired{r}#24,true[BOOLEAN],PT0S[TIME_DURATION]) AS is_rehired#25, VALUES(job_positions{r}#26,true[BOOLEAN],PT0S[TIME_DURATION]) AS job_positions#27, VALUES(languages{r}#28,true[BOOLEAN],PT0S[TIME_DURATION]) AS languages#29, VALUES(languages.byte{r}#30,true[BOOLEAN],PT0S[TIME_DURATION]) AS languages.byte#31, VALUES(languages.long{r}#32,true[BOOLEAN],PT0S[TIME_DURATION]) AS languages.long#33, VALUES(languages.short{r}#34,true[BOOLEAN],PT0S[TIME_DURATION]) AS languages.short#35, VALUES(last_name{r}#36,true[BOOLEAN],PT0S[TIME_DURATION]) AS last_name#37, VALUES(salary{r}#38,true[BOOLEAN],PT0S[TIME_DURATION]) AS salary#39, VALUES(salary_change{r}#40,true[BOOLEAN],PT0S[TIME_DURATION]) AS salary_change#41, VALUES(salary_change.int{r}#42,true[BOOLEAN],PT0S[TIME_DURATION]) AS salary_change.int#43, VALUES(salary_change.keyword{r}#44,true[BOOLEAN],PT0S[TIME_DURATION]) AS salary_change.keyword#45, VALUES(salary_change.long{r}#46,true[BOOLEAN],PT0S[TIME_DURATION]) AS salary_change.long#47, VALUES(still_hired{r}#48,true[BOOLEAN],PT0S[TIME_DURATION]) AS still_hired#49, VALUES(_index{r}#1,true[BOOLEAN],PT0S[TIME_DURATION]) AS _index#50, VALUES(_id{r}#0,true[BOOLEAN],PT0S[TIME_DURATION]) AS _id#51, VALUES(does_not_exist{r}#52,true[BOOLEAN],PT0S[TIME_DURATION]) AS does_not_exist#53, VALUES(_fork{r}#54,true[BOOLEAN],PT0S[TIME_DURATION]) AS _fork#55]] + \_FuseScoreEval[_score{r}#2,_fork{r}#54,RRF,null] + \_Fork[[avg_worked_seconds{r}#4, birth_date{r}#6, emp_no{r}#8, first_name{r}#10, gender{r}#12, height{r}#14, height.float{r}#16, height.half_float{r}#18, height.scaled_float{r}#20, hire_date{r}#22, is_rehired{r}#24, job_positions{r}#26, languages{r}#28, languages.byte{r}#30, languages.long{r}#32, languages.short{r}#34, last_name{r}#36, salary{r}#38, salary_change{r}#40, salary_change.int{r}#42, salary_change.keyword{r}#44, salary_change.long{r}#46, still_hired{r}#48, _score{r}#2, _index{r}#1, _id{r}#0, does_not_exist{r}#52, _fork{r}#54]] + |_Limit[1000[INTEGER],false,false] + | \_Project[[avg_worked_seconds{f(EsField)}#56, birth_date{f(DateEsField)}#57, emp_no{f(EsField)}#58, first_name{f(KeywordEsField)}#59, gender{f(KeywordEsField)}#60, height{f(EsField)}#61, height.float{f(EsField)}#62, height.half_float{f(EsField)}#63, height.scaled_float{f(EsField)}#64, hire_date{f(DateEsField)}#65, is_rehired{f(EsField)}#66, job_positions{f(KeywordEsField)}#67, languages{f(EsField)}#68, languages.byte{f(EsField)}#69, languages.long{f(EsField)}#70, languages.short{f(EsField)}#71, last_name{f(KeywordEsField)}#72, salary{f(EsField)}#73, salary_change{f(EsField)}#74, salary_change.int{f(EsField)}#75, salary_change.keyword{f(KeywordEsField)}#76, salary_change.long{f(EsField)}#77, still_hired{f(EsField)}#78, _score{m}#79, _index{m}#80, _id{m}#81, does_not_exist{f(PotentiallyUnmappedKeywordEsField)}#82, _fork{r}#83]] + | \_Eval[[fork1[KEYWORD] AS _fork#83]] + | \_Filter[TOLONG(does_not_exist{f}#82) > 0[INTEGER]] + | \_EsRelation[employees][avg_worked_seconds{f}#56, birth_date{f}#57, emp_no{f}#58, first_name{f}#59, gender{f}#60, height{f}#61, height.float{f}#62, height.half_float{f}#63, height.scaled_float{f}#64, hire_date{f}#65, is_rehired{f}#66, job_positions{f}#67, languages{f}#68, languages.byte{f}#69, languages.long{f}#70, languages.short{f}#71, last_name{f}#72, salary{f}#73, salary_change{f}#74, salary_change.int{f}#75, salary_change.keyword{f}#76, salary_change.long{f}#77, still_hired{f}#78, _score{m}#79, _index{m}#80, _id{m}#81, does_not_exist{f}#82] + \_Limit[1000[INTEGER],false,false] + \_Project[[avg_worked_seconds{f(EsField)}#84, birth_date{f(DateEsField)}#85, emp_no{f(EsField)}#86, first_name{f(KeywordEsField)}#87, gender{f(KeywordEsField)}#88, height{f(EsField)}#89, height.float{f(EsField)}#90, height.half_float{f(EsField)}#91, height.scaled_float{f(EsField)}#92, hire_date{f(DateEsField)}#93, is_rehired{f(EsField)}#94, job_positions{f(KeywordEsField)}#95, languages{f(EsField)}#96, languages.byte{f(EsField)}#97, languages.long{f(EsField)}#98, languages.short{f(EsField)}#99, last_name{f(KeywordEsField)}#100, salary{f(EsField)}#101, salary_change{f(EsField)}#102, salary_change.int{f(EsField)}#103, salary_change.keyword{f(KeywordEsField)}#104, salary_change.long{f(EsField)}#105, still_hired{f(EsField)}#106, _score{m}#79, _index{m}#80, _id{m}#81, does_not_exist{r}#107, _fork{r}#83]] + \_Eval[[null[KEYWORD] AS does_not_exist#107]] + \_Eval[[fork2[KEYWORD] AS _fork#83]] + \_Filter[emp_no{f}#86 > 0[INTEGER]] + \_EsRelation[employees][avg_worked_seconds{f}#84, birth_date{f}#85, emp_no{f}#86, first_name{f}#87, gender{f}#88, height{f}#89, height.float{f}#90, height.half_float{f}#91, height.scaled_float{f}#92, hire_date{f}#93, is_rehired{f}#94, job_positions{f}#95, languages{f}#96, languages.byte{f}#97, languages.long{f}#98, languages.short{f}#99, last_name{f}#100, salary{f}#101, salary_change{f}#102, salary_change.int{f}#103, salary_change.keyword{f}#104, salary_change.long{f}#105, still_hired{f}#106, _score{m}#79, _index{m}#80, _id{m}#81] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testFuse/load/query.esql b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testFuse/load/query.esql new file mode 100644 index 0000000000000..2217f682e64de --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testFuse/load/query.esql @@ -0,0 +1,4 @@ +SET unmapped_fields="load"; FROM employees METADATA _score, _index, _id +| FORK (WHERE does_not_exist::LONG > 0) + (WHERE emp_no > 0) +| FUSE diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testFuse/nullify/analysis.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testFuse/nullify/analysis.expected new file mode 100644 index 0000000000000..cfa9ace9ad952 --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testFuse/nullify/analysis.expected @@ -0,0 +1,16 @@ +Limit[1000[INTEGER],false,false] +\_Aggregate[[_id{r}#0, _index{r}#1],[SUM(_score{r}#2,true[BOOLEAN],PT0S[TIME_DURATION],compensated[KEYWORD]) AS _score#3, VALUES(avg_worked_seconds{r}#4,true[BOOLEAN],PT0S[TIME_DURATION]) AS avg_worked_seconds#5, VALUES(birth_date{r}#6,true[BOOLEAN],PT0S[TIME_DURATION]) AS birth_date#7, VALUES(emp_no{r}#8,true[BOOLEAN],PT0S[TIME_DURATION]) AS emp_no#9, VALUES(first_name{r}#10,true[BOOLEAN],PT0S[TIME_DURATION]) AS first_name#11, VALUES(gender{r}#12,true[BOOLEAN],PT0S[TIME_DURATION]) AS gender#13, VALUES(height{r}#14,true[BOOLEAN],PT0S[TIME_DURATION]) AS height#15, VALUES(height.float{r}#16,true[BOOLEAN],PT0S[TIME_DURATION]) AS height.float#17, VALUES(height.half_float{r}#18,true[BOOLEAN],PT0S[TIME_DURATION]) AS height.half_float#19, VALUES(height.scaled_float{r}#20,true[BOOLEAN],PT0S[TIME_DURATION]) AS height.scaled_float#21, VALUES(hire_date{r}#22,true[BOOLEAN],PT0S[TIME_DURATION]) AS hire_date#23, VALUES(is_rehired{r}#24,true[BOOLEAN],PT0S[TIME_DURATION]) AS is_rehired#25, VALUES(job_positions{r}#26,true[BOOLEAN],PT0S[TIME_DURATION]) AS job_positions#27, VALUES(languages{r}#28,true[BOOLEAN],PT0S[TIME_DURATION]) AS languages#29, VALUES(languages.byte{r}#30,true[BOOLEAN],PT0S[TIME_DURATION]) AS languages.byte#31, VALUES(languages.long{r}#32,true[BOOLEAN],PT0S[TIME_DURATION]) AS languages.long#33, VALUES(languages.short{r}#34,true[BOOLEAN],PT0S[TIME_DURATION]) AS languages.short#35, VALUES(last_name{r}#36,true[BOOLEAN],PT0S[TIME_DURATION]) AS last_name#37, VALUES(salary{r}#38,true[BOOLEAN],PT0S[TIME_DURATION]) AS salary#39, VALUES(salary_change{r}#40,true[BOOLEAN],PT0S[TIME_DURATION]) AS salary_change#41, VALUES(salary_change.int{r}#42,true[BOOLEAN],PT0S[TIME_DURATION]) AS salary_change.int#43, VALUES(salary_change.keyword{r}#44,true[BOOLEAN],PT0S[TIME_DURATION]) AS salary_change.keyword#45, VALUES(salary_change.long{r}#46,true[BOOLEAN],PT0S[TIME_DURATION]) AS salary_change.long#47, VALUES(still_hired{r}#48,true[BOOLEAN],PT0S[TIME_DURATION]) AS still_hired#49, VALUES(_index{r}#1,true[BOOLEAN],PT0S[TIME_DURATION]) AS _index#50, VALUES(_id{r}#0,true[BOOLEAN],PT0S[TIME_DURATION]) AS _id#51, VALUES(does_not_exist{r}#52,true[BOOLEAN],PT0S[TIME_DURATION]) AS does_not_exist#53, VALUES(_fork{r}#54,true[BOOLEAN],PT0S[TIME_DURATION]) AS _fork#55]] + \_FuseScoreEval[_score{r}#2,_fork{r}#54,RRF,null] + \_Fork[[avg_worked_seconds{r}#4, birth_date{r}#6, emp_no{r}#8, first_name{r}#10, gender{r}#12, height{r}#14, height.float{r}#16, height.half_float{r}#18, height.scaled_float{r}#20, hire_date{r}#22, is_rehired{r}#24, job_positions{r}#26, languages{r}#28, languages.byte{r}#30, languages.long{r}#32, languages.short{r}#34, last_name{r}#36, salary{r}#38, salary_change{r}#40, salary_change.int{r}#42, salary_change.keyword{r}#44, salary_change.long{r}#46, still_hired{r}#48, _score{r}#2, _index{r}#1, _id{r}#0, does_not_exist{r}#52, _fork{r}#54]] + |_Limit[1000[INTEGER],false,false] + | \_Project[[avg_worked_seconds{f(EsField)}#56, birth_date{f(DateEsField)}#57, emp_no{f(EsField)}#58, first_name{f(KeywordEsField)}#59, gender{f(KeywordEsField)}#60, height{f(EsField)}#61, height.float{f(EsField)}#62, height.half_float{f(EsField)}#63, height.scaled_float{f(EsField)}#64, hire_date{f(DateEsField)}#65, is_rehired{f(EsField)}#66, job_positions{f(KeywordEsField)}#67, languages{f(EsField)}#68, languages.byte{f(EsField)}#69, languages.long{f(EsField)}#70, languages.short{f(EsField)}#71, last_name{f(KeywordEsField)}#72, salary{f(EsField)}#73, salary_change{f(EsField)}#74, salary_change.int{f(EsField)}#75, salary_change.keyword{f(KeywordEsField)}#76, salary_change.long{f(EsField)}#77, still_hired{f(EsField)}#78, _score{m}#79, _index{m}#80, _id{m}#81, does_not_exist{r}#82, _fork{r}#83]] + | \_Eval[[fork1[KEYWORD] AS _fork#83]] + | \_Filter[TOLONG(does_not_exist{r}#82) > 0[INTEGER]] + | \_Eval[[null[NULL] AS does_not_exist#82]] + | \_EsRelation[employees][avg_worked_seconds{f}#56, birth_date{f}#57, emp_no{f}#58, first_name{f}#59, gender{f}#60, height{f}#61, height.float{f}#62, height.half_float{f}#63, height.scaled_float{f}#64, hire_date{f}#65, is_rehired{f}#66, job_positions{f}#67, languages{f}#68, languages.byte{f}#69, languages.long{f}#70, languages.short{f}#71, last_name{f}#72, salary{f}#73, salary_change{f}#74, salary_change.int{f}#75, salary_change.keyword{f}#76, salary_change.long{f}#77, still_hired{f}#78, _score{m}#79, _index{m}#80, _id{m}#81] + \_Limit[1000[INTEGER],false,false] + \_Project[[avg_worked_seconds{f(EsField)}#84, birth_date{f(DateEsField)}#85, emp_no{f(EsField)}#86, first_name{f(KeywordEsField)}#87, gender{f(KeywordEsField)}#88, height{f(EsField)}#89, height.float{f(EsField)}#90, height.half_float{f(EsField)}#91, height.scaled_float{f(EsField)}#92, hire_date{f(DateEsField)}#93, is_rehired{f(EsField)}#94, job_positions{f(KeywordEsField)}#95, languages{f(EsField)}#96, languages.byte{f(EsField)}#97, languages.long{f(EsField)}#98, languages.short{f(EsField)}#99, last_name{f(KeywordEsField)}#100, salary{f(EsField)}#101, salary_change{f(EsField)}#102, salary_change.int{f(EsField)}#103, salary_change.keyword{f(KeywordEsField)}#104, salary_change.long{f(EsField)}#105, still_hired{f(EsField)}#106, _score{m}#79, _index{m}#80, _id{m}#81, does_not_exist{r}#107, _fork{r}#83]] + \_Eval[[null[NULL] AS does_not_exist#107]] + \_Eval[[fork2[KEYWORD] AS _fork#83]] + \_Filter[emp_no{f}#86 > 0[INTEGER]] + \_EsRelation[employees][avg_worked_seconds{f}#84, birth_date{f}#85, emp_no{f}#86, first_name{f}#87, gender{f}#88, height{f}#89, height.float{f}#90, height.half_float{f}#91, height.scaled_float{f}#92, hire_date{f}#93, is_rehired{f}#94, job_positions{f}#95, languages{f}#96, languages.byte{f}#97, languages.long{f}#98, languages.short{f}#99, last_name{f}#100, salary{f}#101, salary_change{f}#102, salary_change.int{f}#103, salary_change.keyword{f}#104, salary_change.long{f}#105, still_hired{f}#106, _score{m}#79, _index{m}#80, _id{m}#81] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testFuse/nullify/query.esql b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testFuse/nullify/query.esql new file mode 100644 index 0000000000000..53465ff6db0c5 --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testFuse/nullify/query.esql @@ -0,0 +1,4 @@ +SET unmapped_fields="nullify"; FROM employees METADATA _score, _index, _id +| FORK (WHERE does_not_exist::LONG > 0) + (WHERE emp_no > 0) +| FUSE diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testFuseLinear/load/analysis.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testFuseLinear/load/analysis.expected new file mode 100644 index 0000000000000..04da9a423e8dc --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testFuseLinear/load/analysis.expected @@ -0,0 +1,18 @@ +Limit[1000[INTEGER],false,false] +\_Aggregate[[_id{r}#0, _index{r}#1],[SUM(_score{r}#2,true[BOOLEAN],PT0S[TIME_DURATION],compensated[KEYWORD]) AS _score#3, VALUES(avg_worked_seconds{r}#4,true[BOOLEAN],PT0S[TIME_DURATION]) AS avg_worked_seconds#5, VALUES(birth_date{r}#6,true[BOOLEAN],PT0S[TIME_DURATION]) AS birth_date#7, VALUES(emp_no{r}#8,true[BOOLEAN],PT0S[TIME_DURATION]) AS emp_no#9, VALUES(first_name{r}#10,true[BOOLEAN],PT0S[TIME_DURATION]) AS first_name#11, VALUES(gender{r}#12,true[BOOLEAN],PT0S[TIME_DURATION]) AS gender#13, VALUES(height{r}#14,true[BOOLEAN],PT0S[TIME_DURATION]) AS height#15, VALUES(height.float{r}#16,true[BOOLEAN],PT0S[TIME_DURATION]) AS height.float#17, VALUES(height.half_float{r}#18,true[BOOLEAN],PT0S[TIME_DURATION]) AS height.half_float#19, VALUES(height.scaled_float{r}#20,true[BOOLEAN],PT0S[TIME_DURATION]) AS height.scaled_float#21, VALUES(hire_date{r}#22,true[BOOLEAN],PT0S[TIME_DURATION]) AS hire_date#23, VALUES(is_rehired{r}#24,true[BOOLEAN],PT0S[TIME_DURATION]) AS is_rehired#25, VALUES(job_positions{r}#26,true[BOOLEAN],PT0S[TIME_DURATION]) AS job_positions#27, VALUES(languages{r}#28,true[BOOLEAN],PT0S[TIME_DURATION]) AS languages#29, VALUES(languages.byte{r}#30,true[BOOLEAN],PT0S[TIME_DURATION]) AS languages.byte#31, VALUES(languages.long{r}#32,true[BOOLEAN],PT0S[TIME_DURATION]) AS languages.long#33, VALUES(languages.short{r}#34,true[BOOLEAN],PT0S[TIME_DURATION]) AS languages.short#35, VALUES(last_name{r}#36,true[BOOLEAN],PT0S[TIME_DURATION]) AS last_name#37, VALUES(salary{r}#38,true[BOOLEAN],PT0S[TIME_DURATION]) AS salary#39, VALUES(salary_change{r}#40,true[BOOLEAN],PT0S[TIME_DURATION]) AS salary_change#41, VALUES(salary_change.int{r}#42,true[BOOLEAN],PT0S[TIME_DURATION]) AS salary_change.int#43, VALUES(salary_change.keyword{r}#44,true[BOOLEAN],PT0S[TIME_DURATION]) AS salary_change.keyword#45, VALUES(salary_change.long{r}#46,true[BOOLEAN],PT0S[TIME_DURATION]) AS salary_change.long#47, VALUES(still_hired{r}#48,true[BOOLEAN],PT0S[TIME_DURATION]) AS still_hired#49, VALUES(_index{r}#1,true[BOOLEAN],PT0S[TIME_DURATION]) AS _index#50, VALUES(_id{r}#0,true[BOOLEAN],PT0S[TIME_DURATION]) AS _id#51, VALUES(does_not_exist{r}#52,true[BOOLEAN],PT0S[TIME_DURATION]) AS does_not_exist#53, VALUES(x{r}#54,true[BOOLEAN],PT0S[TIME_DURATION]) AS x#55, VALUES(_fork{r}#56,true[BOOLEAN],PT0S[TIME_DURATION]) AS _fork#57, VALUES(y{r}#58,true[BOOLEAN],PT0S[TIME_DURATION]) AS y#59]] + \_FuseScoreEval[_score{r}#2,_fork{r}#56,LINEAR,null] + \_Fork[[avg_worked_seconds{r}#4, birth_date{r}#6, emp_no{r}#8, first_name{r}#10, gender{r}#12, height{r}#14, height.float{r}#16, height.half_float{r}#18, height.scaled_float{r}#20, hire_date{r}#22, is_rehired{r}#24, job_positions{r}#26, languages{r}#28, languages.byte{r}#30, languages.long{r}#32, languages.short{r}#34, last_name{r}#36, salary{r}#38, salary_change{r}#40, salary_change.int{r}#42, salary_change.keyword{r}#44, salary_change.long{r}#46, still_hired{r}#48, _score{r}#2, _index{r}#1, _id{r}#0, does_not_exist{r}#52, x{r}#54, _fork{r}#56, y{r}#58]] + |_Limit[1000[INTEGER],false,false] + | \_Project[[avg_worked_seconds{f(EsField)}#60, birth_date{f(DateEsField)}#61, emp_no{f(EsField)}#62, first_name{f(KeywordEsField)}#63, gender{f(KeywordEsField)}#64, height{f(EsField)}#65, height.float{f(EsField)}#66, height.half_float{f(EsField)}#67, height.scaled_float{f(EsField)}#68, hire_date{f(DateEsField)}#69, is_rehired{f(EsField)}#70, job_positions{f(KeywordEsField)}#71, languages{f(EsField)}#72, languages.byte{f(EsField)}#73, languages.long{f(EsField)}#74, languages.short{f(EsField)}#75, last_name{f(KeywordEsField)}#76, salary{f(EsField)}#77, salary_change{f(EsField)}#78, salary_change.int{f(EsField)}#79, salary_change.keyword{f(KeywordEsField)}#80, salary_change.long{f(EsField)}#81, still_hired{f(EsField)}#82, _score{m}#83, _index{m}#84, _id{m}#85, does_not_exist{f(PotentiallyUnmappedKeywordEsField)}#86, x{r}#87, _fork{r}#88, y{r}#89]] + | \_Eval[[null[INTEGER] AS y#89]] + | \_Eval[[fork1[KEYWORD] AS _fork#88]] + | \_Eval[[1[INTEGER] AS x#87]] + | \_Filter[TOLONG(does_not_exist{f}#86) > 0[INTEGER]] + | \_EsRelation[employees][avg_worked_seconds{f}#60, birth_date{f}#61, emp_no{f}#62, first_name{f}#63, gender{f}#64, height{f}#65, height.float{f}#66, height.half_float{f}#67, height.scaled_float{f}#68, hire_date{f}#69, is_rehired{f}#70, job_positions{f}#71, languages{f}#72, languages.byte{f}#73, languages.long{f}#74, languages.short{f}#75, last_name{f}#76, salary{f}#77, salary_change{f}#78, salary_change.int{f}#79, salary_change.keyword{f}#80, salary_change.long{f}#81, still_hired{f}#82, _score{m}#83, _index{m}#84, _id{m}#85, does_not_exist{f}#86] + \_Limit[1000[INTEGER],false,false] + \_Project[[avg_worked_seconds{f(EsField)}#90, birth_date{f(DateEsField)}#91, emp_no{f(EsField)}#92, first_name{f(KeywordEsField)}#93, gender{f(KeywordEsField)}#94, height{f(EsField)}#95, height.float{f(EsField)}#96, height.half_float{f(EsField)}#97, height.scaled_float{f(EsField)}#98, hire_date{f(DateEsField)}#99, is_rehired{f(EsField)}#100, job_positions{f(KeywordEsField)}#101, languages{f(EsField)}#102, languages.byte{f(EsField)}#103, languages.long{f(EsField)}#104, languages.short{f(EsField)}#105, last_name{f(KeywordEsField)}#106, salary{f(EsField)}#107, salary_change{f(EsField)}#108, salary_change.int{f(EsField)}#109, salary_change.keyword{f(KeywordEsField)}#110, salary_change.long{f(EsField)}#111, still_hired{f(EsField)}#112, _score{m}#83, _index{m}#84, _id{m}#85, does_not_exist{r}#113, x{r}#114, _fork{r}#88, y{r}#115]] + \_Eval[[null[KEYWORD] AS does_not_exist#113, null[INTEGER] AS x#114]] + \_Eval[[fork2[KEYWORD] AS _fork#88]] + \_Eval[[2[INTEGER] AS y#115]] + \_Filter[emp_no{f}#92 > 0[INTEGER]] + \_EsRelation[employees][avg_worked_seconds{f}#90, birth_date{f}#91, emp_no{f}#92, first_name{f}#93, gender{f}#94, height{f}#95, height.float{f}#96, height.half_float{f}#97, height.scaled_float{f}#98, hire_date{f}#99, is_rehired{f}#100, job_positions{f}#101, languages{f}#102, languages.byte{f}#103, languages.long{f}#104, languages.short{f}#105, last_name{f}#106, salary{f}#107, salary_change{f}#108, salary_change.int{f}#109, salary_change.keyword{f}#110, salary_change.long{f}#111, still_hired{f}#112, _score{m}#83, _index{m}#84, _id{m}#85] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testFuseLinear/load/query.esql b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testFuseLinear/load/query.esql new file mode 100644 index 0000000000000..6ca46384903c8 --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testFuseLinear/load/query.esql @@ -0,0 +1,4 @@ +SET unmapped_fields="load"; FROM employees METADATA _score, _index, _id +| FORK (WHERE does_not_exist::LONG > 0 | EVAL x = 1) + (WHERE emp_no > 0 | EVAL y = 2) +| FUSE LINEAR diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testFuseLinear/nullify/analysis.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testFuseLinear/nullify/analysis.expected new file mode 100644 index 0000000000000..2d4aef7657ab1 --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testFuseLinear/nullify/analysis.expected @@ -0,0 +1,19 @@ +Limit[1000[INTEGER],false,false] +\_Aggregate[[_id{r}#0, _index{r}#1],[SUM(_score{r}#2,true[BOOLEAN],PT0S[TIME_DURATION],compensated[KEYWORD]) AS _score#3, VALUES(avg_worked_seconds{r}#4,true[BOOLEAN],PT0S[TIME_DURATION]) AS avg_worked_seconds#5, VALUES(birth_date{r}#6,true[BOOLEAN],PT0S[TIME_DURATION]) AS birth_date#7, VALUES(emp_no{r}#8,true[BOOLEAN],PT0S[TIME_DURATION]) AS emp_no#9, VALUES(first_name{r}#10,true[BOOLEAN],PT0S[TIME_DURATION]) AS first_name#11, VALUES(gender{r}#12,true[BOOLEAN],PT0S[TIME_DURATION]) AS gender#13, VALUES(height{r}#14,true[BOOLEAN],PT0S[TIME_DURATION]) AS height#15, VALUES(height.float{r}#16,true[BOOLEAN],PT0S[TIME_DURATION]) AS height.float#17, VALUES(height.half_float{r}#18,true[BOOLEAN],PT0S[TIME_DURATION]) AS height.half_float#19, VALUES(height.scaled_float{r}#20,true[BOOLEAN],PT0S[TIME_DURATION]) AS height.scaled_float#21, VALUES(hire_date{r}#22,true[BOOLEAN],PT0S[TIME_DURATION]) AS hire_date#23, VALUES(is_rehired{r}#24,true[BOOLEAN],PT0S[TIME_DURATION]) AS is_rehired#25, VALUES(job_positions{r}#26,true[BOOLEAN],PT0S[TIME_DURATION]) AS job_positions#27, VALUES(languages{r}#28,true[BOOLEAN],PT0S[TIME_DURATION]) AS languages#29, VALUES(languages.byte{r}#30,true[BOOLEAN],PT0S[TIME_DURATION]) AS languages.byte#31, VALUES(languages.long{r}#32,true[BOOLEAN],PT0S[TIME_DURATION]) AS languages.long#33, VALUES(languages.short{r}#34,true[BOOLEAN],PT0S[TIME_DURATION]) AS languages.short#35, VALUES(last_name{r}#36,true[BOOLEAN],PT0S[TIME_DURATION]) AS last_name#37, VALUES(salary{r}#38,true[BOOLEAN],PT0S[TIME_DURATION]) AS salary#39, VALUES(salary_change{r}#40,true[BOOLEAN],PT0S[TIME_DURATION]) AS salary_change#41, VALUES(salary_change.int{r}#42,true[BOOLEAN],PT0S[TIME_DURATION]) AS salary_change.int#43, VALUES(salary_change.keyword{r}#44,true[BOOLEAN],PT0S[TIME_DURATION]) AS salary_change.keyword#45, VALUES(salary_change.long{r}#46,true[BOOLEAN],PT0S[TIME_DURATION]) AS salary_change.long#47, VALUES(still_hired{r}#48,true[BOOLEAN],PT0S[TIME_DURATION]) AS still_hired#49, VALUES(_index{r}#1,true[BOOLEAN],PT0S[TIME_DURATION]) AS _index#50, VALUES(_id{r}#0,true[BOOLEAN],PT0S[TIME_DURATION]) AS _id#51, VALUES(does_not_exist{r}#52,true[BOOLEAN],PT0S[TIME_DURATION]) AS does_not_exist#53, VALUES(x{r}#54,true[BOOLEAN],PT0S[TIME_DURATION]) AS x#55, VALUES(_fork{r}#56,true[BOOLEAN],PT0S[TIME_DURATION]) AS _fork#57, VALUES(y{r}#58,true[BOOLEAN],PT0S[TIME_DURATION]) AS y#59]] + \_FuseScoreEval[_score{r}#2,_fork{r}#56,LINEAR,null] + \_Fork[[avg_worked_seconds{r}#4, birth_date{r}#6, emp_no{r}#8, first_name{r}#10, gender{r}#12, height{r}#14, height.float{r}#16, height.half_float{r}#18, height.scaled_float{r}#20, hire_date{r}#22, is_rehired{r}#24, job_positions{r}#26, languages{r}#28, languages.byte{r}#30, languages.long{r}#32, languages.short{r}#34, last_name{r}#36, salary{r}#38, salary_change{r}#40, salary_change.int{r}#42, salary_change.keyword{r}#44, salary_change.long{r}#46, still_hired{r}#48, _score{r}#2, _index{r}#1, _id{r}#0, does_not_exist{r}#52, x{r}#54, _fork{r}#56, y{r}#58]] + |_Limit[1000[INTEGER],false,false] + | \_Project[[avg_worked_seconds{f(EsField)}#60, birth_date{f(DateEsField)}#61, emp_no{f(EsField)}#62, first_name{f(KeywordEsField)}#63, gender{f(KeywordEsField)}#64, height{f(EsField)}#65, height.float{f(EsField)}#66, height.half_float{f(EsField)}#67, height.scaled_float{f(EsField)}#68, hire_date{f(DateEsField)}#69, is_rehired{f(EsField)}#70, job_positions{f(KeywordEsField)}#71, languages{f(EsField)}#72, languages.byte{f(EsField)}#73, languages.long{f(EsField)}#74, languages.short{f(EsField)}#75, last_name{f(KeywordEsField)}#76, salary{f(EsField)}#77, salary_change{f(EsField)}#78, salary_change.int{f(EsField)}#79, salary_change.keyword{f(KeywordEsField)}#80, salary_change.long{f(EsField)}#81, still_hired{f(EsField)}#82, _score{m}#83, _index{m}#84, _id{m}#85, does_not_exist{r}#86, x{r}#87, _fork{r}#88, y{r}#89]] + | \_Eval[[null[INTEGER] AS y#89]] + | \_Eval[[fork1[KEYWORD] AS _fork#88]] + | \_Eval[[1[INTEGER] AS x#87]] + | \_Filter[TOLONG(does_not_exist{r}#86) > 0[INTEGER]] + | \_Eval[[null[NULL] AS does_not_exist#86]] + | \_EsRelation[employees][avg_worked_seconds{f}#60, birth_date{f}#61, emp_no{f}#62, first_name{f}#63, gender{f}#64, height{f}#65, height.float{f}#66, height.half_float{f}#67, height.scaled_float{f}#68, hire_date{f}#69, is_rehired{f}#70, job_positions{f}#71, languages{f}#72, languages.byte{f}#73, languages.long{f}#74, languages.short{f}#75, last_name{f}#76, salary{f}#77, salary_change{f}#78, salary_change.int{f}#79, salary_change.keyword{f}#80, salary_change.long{f}#81, still_hired{f}#82, _score{m}#83, _index{m}#84, _id{m}#85] + \_Limit[1000[INTEGER],false,false] + \_Project[[avg_worked_seconds{f(EsField)}#90, birth_date{f(DateEsField)}#91, emp_no{f(EsField)}#92, first_name{f(KeywordEsField)}#93, gender{f(KeywordEsField)}#94, height{f(EsField)}#95, height.float{f(EsField)}#96, height.half_float{f(EsField)}#97, height.scaled_float{f(EsField)}#98, hire_date{f(DateEsField)}#99, is_rehired{f(EsField)}#100, job_positions{f(KeywordEsField)}#101, languages{f(EsField)}#102, languages.byte{f(EsField)}#103, languages.long{f(EsField)}#104, languages.short{f(EsField)}#105, last_name{f(KeywordEsField)}#106, salary{f(EsField)}#107, salary_change{f(EsField)}#108, salary_change.int{f(EsField)}#109, salary_change.keyword{f(KeywordEsField)}#110, salary_change.long{f(EsField)}#111, still_hired{f(EsField)}#112, _score{m}#83, _index{m}#84, _id{m}#85, does_not_exist{r}#113, x{r}#114, _fork{r}#88, y{r}#115]] + \_Eval[[null[NULL] AS does_not_exist#113, null[INTEGER] AS x#114]] + \_Eval[[fork2[KEYWORD] AS _fork#88]] + \_Eval[[2[INTEGER] AS y#115]] + \_Filter[emp_no{f}#92 > 0[INTEGER]] + \_EsRelation[employees][avg_worked_seconds{f}#90, birth_date{f}#91, emp_no{f}#92, first_name{f}#93, gender{f}#94, height{f}#95, height.float{f}#96, height.half_float{f}#97, height.scaled_float{f}#98, hire_date{f}#99, is_rehired{f}#100, job_positions{f}#101, languages{f}#102, languages.byte{f}#103, languages.long{f}#104, languages.short{f}#105, last_name{f}#106, salary{f}#107, salary_change{f}#108, salary_change.int{f}#109, salary_change.keyword{f}#110, salary_change.long{f}#111, still_hired{f}#112, _score{m}#83, _index{m}#84, _id{m}#85] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testFuseLinear/nullify/query.esql b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testFuseLinear/nullify/query.esql new file mode 100644 index 0000000000000..b4201b56e3cf8 --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testFuseLinear/nullify/query.esql @@ -0,0 +1,4 @@ +SET unmapped_fields="nullify"; FROM employees METADATA _score, _index, _id +| FORK (WHERE does_not_exist::LONG > 0 | EVAL x = 1) + (WHERE emp_no > 0 | EVAL y = 2) +| FUSE LINEAR diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testFuseWithEval/load/analysis.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testFuseWithEval/load/analysis.expected new file mode 100644 index 0000000000000..bc41c8f49b9f2 --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testFuseWithEval/load/analysis.expected @@ -0,0 +1,16 @@ +Limit[1000[INTEGER],false,false] +\_Aggregate[[_id{r}#0, _index{r}#1],[SUM(_score{r}#2,true[BOOLEAN],PT0S[TIME_DURATION],compensated[KEYWORD]) AS _score#3, VALUES(avg_worked_seconds{r}#4,true[BOOLEAN],PT0S[TIME_DURATION]) AS avg_worked_seconds#5, VALUES(birth_date{r}#6,true[BOOLEAN],PT0S[TIME_DURATION]) AS birth_date#7, VALUES(emp_no{r}#8,true[BOOLEAN],PT0S[TIME_DURATION]) AS emp_no#9, VALUES(first_name{r}#10,true[BOOLEAN],PT0S[TIME_DURATION]) AS first_name#11, VALUES(gender{r}#12,true[BOOLEAN],PT0S[TIME_DURATION]) AS gender#13, VALUES(height{r}#14,true[BOOLEAN],PT0S[TIME_DURATION]) AS height#15, VALUES(height.float{r}#16,true[BOOLEAN],PT0S[TIME_DURATION]) AS height.float#17, VALUES(height.half_float{r}#18,true[BOOLEAN],PT0S[TIME_DURATION]) AS height.half_float#19, VALUES(height.scaled_float{r}#20,true[BOOLEAN],PT0S[TIME_DURATION]) AS height.scaled_float#21, VALUES(hire_date{r}#22,true[BOOLEAN],PT0S[TIME_DURATION]) AS hire_date#23, VALUES(is_rehired{r}#24,true[BOOLEAN],PT0S[TIME_DURATION]) AS is_rehired#25, VALUES(job_positions{r}#26,true[BOOLEAN],PT0S[TIME_DURATION]) AS job_positions#27, VALUES(languages{r}#28,true[BOOLEAN],PT0S[TIME_DURATION]) AS languages#29, VALUES(languages.byte{r}#30,true[BOOLEAN],PT0S[TIME_DURATION]) AS languages.byte#31, VALUES(languages.long{r}#32,true[BOOLEAN],PT0S[TIME_DURATION]) AS languages.long#33, VALUES(languages.short{r}#34,true[BOOLEAN],PT0S[TIME_DURATION]) AS languages.short#35, VALUES(last_name{r}#36,true[BOOLEAN],PT0S[TIME_DURATION]) AS last_name#37, VALUES(salary{r}#38,true[BOOLEAN],PT0S[TIME_DURATION]) AS salary#39, VALUES(salary_change{r}#40,true[BOOLEAN],PT0S[TIME_DURATION]) AS salary_change#41, VALUES(salary_change.int{r}#42,true[BOOLEAN],PT0S[TIME_DURATION]) AS salary_change.int#43, VALUES(salary_change.keyword{r}#44,true[BOOLEAN],PT0S[TIME_DURATION]) AS salary_change.keyword#45, VALUES(salary_change.long{r}#46,true[BOOLEAN],PT0S[TIME_DURATION]) AS salary_change.long#47, VALUES(still_hired{r}#48,true[BOOLEAN],PT0S[TIME_DURATION]) AS still_hired#49, VALUES(_index{r}#1,true[BOOLEAN],PT0S[TIME_DURATION]) AS _index#50, VALUES(_id{r}#0,true[BOOLEAN],PT0S[TIME_DURATION]) AS _id#51, VALUES(does_not_exist{r}#52,true[BOOLEAN],PT0S[TIME_DURATION]) AS does_not_exist#53, VALUES(x{r}#54,true[BOOLEAN],PT0S[TIME_DURATION]) AS x#55, VALUES(_fork{r}#56,true[BOOLEAN],PT0S[TIME_DURATION]) AS _fork#57, VALUES(y{r}#58,true[BOOLEAN],PT0S[TIME_DURATION]) AS y#59]] + \_FuseScoreEval[_score{r}#2,_fork{r}#56,RRF,null] + \_Fork[[avg_worked_seconds{r}#4, birth_date{r}#6, emp_no{r}#8, first_name{r}#10, gender{r}#12, height{r}#14, height.float{r}#16, height.half_float{r}#18, height.scaled_float{r}#20, hire_date{r}#22, is_rehired{r}#24, job_positions{r}#26, languages{r}#28, languages.byte{r}#30, languages.long{r}#32, languages.short{r}#34, last_name{r}#36, salary{r}#38, salary_change{r}#40, salary_change.int{r}#42, salary_change.keyword{r}#44, salary_change.long{r}#46, still_hired{r}#48, _score{r}#2, _index{r}#1, _id{r}#0, does_not_exist{r}#52, x{r}#54, _fork{r}#56, y{r}#58]] + |_Limit[1000[INTEGER],false,false] + | \_Project[[avg_worked_seconds{f(EsField)}#60, birth_date{f(DateEsField)}#61, emp_no{f(EsField)}#62, first_name{f(KeywordEsField)}#63, gender{f(KeywordEsField)}#64, height{f(EsField)}#65, height.float{f(EsField)}#66, height.half_float{f(EsField)}#67, height.scaled_float{f(EsField)}#68, hire_date{f(DateEsField)}#69, is_rehired{f(EsField)}#70, job_positions{f(KeywordEsField)}#71, languages{f(EsField)}#72, languages.byte{f(EsField)}#73, languages.long{f(EsField)}#74, languages.short{f(EsField)}#75, last_name{f(KeywordEsField)}#76, salary{f(EsField)}#77, salary_change{f(EsField)}#78, salary_change.int{f(EsField)}#79, salary_change.keyword{f(KeywordEsField)}#80, salary_change.long{f(EsField)}#81, still_hired{f(EsField)}#82, _score{m}#83, _index{m}#84, _id{m}#85, does_not_exist{f(PotentiallyUnmappedKeywordEsField)}#86, x{r}#87, _fork{r}#88, y{r}#89]] + | \_Eval[[null[INTEGER] AS y#89]] + | \_Eval[[fork1[KEYWORD] AS _fork#88]] + | \_Eval[[TODOUBLE(does_not_exist{f}#86) + 1[INTEGER] AS x#87]] + | \_EsRelation[employees][avg_worked_seconds{f}#60, birth_date{f}#61, emp_no{f}#62, first_name{f}#63, gender{f}#64, height{f}#65, height.float{f}#66, height.half_float{f}#67, height.scaled_float{f}#68, hire_date{f}#69, is_rehired{f}#70, job_positions{f}#71, languages{f}#72, languages.byte{f}#73, languages.long{f}#74, languages.short{f}#75, last_name{f}#76, salary{f}#77, salary_change{f}#78, salary_change.int{f}#79, salary_change.keyword{f}#80, salary_change.long{f}#81, still_hired{f}#82, _score{m}#83, _index{m}#84, _id{m}#85, does_not_exist{f}#86] + \_Limit[1000[INTEGER],false,false] + \_Project[[avg_worked_seconds{f(EsField)}#90, birth_date{f(DateEsField)}#91, emp_no{f(EsField)}#92, first_name{f(KeywordEsField)}#93, gender{f(KeywordEsField)}#94, height{f(EsField)}#95, height.float{f(EsField)}#96, height.half_float{f(EsField)}#97, height.scaled_float{f(EsField)}#98, hire_date{f(DateEsField)}#99, is_rehired{f(EsField)}#100, job_positions{f(KeywordEsField)}#101, languages{f(EsField)}#102, languages.byte{f(EsField)}#103, languages.long{f(EsField)}#104, languages.short{f(EsField)}#105, last_name{f(KeywordEsField)}#106, salary{f(EsField)}#107, salary_change{f(EsField)}#108, salary_change.int{f(EsField)}#109, salary_change.keyword{f(KeywordEsField)}#110, salary_change.long{f(EsField)}#111, still_hired{f(EsField)}#112, _score{m}#83, _index{m}#84, _id{m}#85, does_not_exist{r}#113, x{r}#114, _fork{r}#88, y{r}#115]] + \_Eval[[null[KEYWORD] AS does_not_exist#113, null[DOUBLE] AS x#114]] + \_Eval[[fork2[KEYWORD] AS _fork#88]] + \_Eval[[emp_no{f}#92 + 1[INTEGER] AS y#115]] + \_EsRelation[employees][avg_worked_seconds{f}#90, birth_date{f}#91, emp_no{f}#92, first_name{f}#93, gender{f}#94, height{f}#95, height.float{f}#96, height.half_float{f}#97, height.scaled_float{f}#98, hire_date{f}#99, is_rehired{f}#100, job_positions{f}#101, languages{f}#102, languages.byte{f}#103, languages.long{f}#104, languages.short{f}#105, last_name{f}#106, salary{f}#107, salary_change{f}#108, salary_change.int{f}#109, salary_change.keyword{f}#110, salary_change.long{f}#111, still_hired{f}#112, _score{m}#83, _index{m}#84, _id{m}#85] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testFuseWithEval/load/query.esql b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testFuseWithEval/load/query.esql new file mode 100644 index 0000000000000..28caa1c3f1e98 --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testFuseWithEval/load/query.esql @@ -0,0 +1,4 @@ +SET unmapped_fields="load"; FROM employees METADATA _score, _index, _id +| FORK (EVAL x = does_not_exist::DOUBLE + 1) + (EVAL y = emp_no + 1) +| FUSE RRF diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testFuseWithEval/nullify/analysis.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testFuseWithEval/nullify/analysis.expected new file mode 100644 index 0000000000000..7c2ca4cbcfc17 --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testFuseWithEval/nullify/analysis.expected @@ -0,0 +1,17 @@ +Limit[1000[INTEGER],false,false] +\_Aggregate[[_id{r}#0, _index{r}#1],[SUM(_score{r}#2,true[BOOLEAN],PT0S[TIME_DURATION],compensated[KEYWORD]) AS _score#3, VALUES(avg_worked_seconds{r}#4,true[BOOLEAN],PT0S[TIME_DURATION]) AS avg_worked_seconds#5, VALUES(birth_date{r}#6,true[BOOLEAN],PT0S[TIME_DURATION]) AS birth_date#7, VALUES(emp_no{r}#8,true[BOOLEAN],PT0S[TIME_DURATION]) AS emp_no#9, VALUES(first_name{r}#10,true[BOOLEAN],PT0S[TIME_DURATION]) AS first_name#11, VALUES(gender{r}#12,true[BOOLEAN],PT0S[TIME_DURATION]) AS gender#13, VALUES(height{r}#14,true[BOOLEAN],PT0S[TIME_DURATION]) AS height#15, VALUES(height.float{r}#16,true[BOOLEAN],PT0S[TIME_DURATION]) AS height.float#17, VALUES(height.half_float{r}#18,true[BOOLEAN],PT0S[TIME_DURATION]) AS height.half_float#19, VALUES(height.scaled_float{r}#20,true[BOOLEAN],PT0S[TIME_DURATION]) AS height.scaled_float#21, VALUES(hire_date{r}#22,true[BOOLEAN],PT0S[TIME_DURATION]) AS hire_date#23, VALUES(is_rehired{r}#24,true[BOOLEAN],PT0S[TIME_DURATION]) AS is_rehired#25, VALUES(job_positions{r}#26,true[BOOLEAN],PT0S[TIME_DURATION]) AS job_positions#27, VALUES(languages{r}#28,true[BOOLEAN],PT0S[TIME_DURATION]) AS languages#29, VALUES(languages.byte{r}#30,true[BOOLEAN],PT0S[TIME_DURATION]) AS languages.byte#31, VALUES(languages.long{r}#32,true[BOOLEAN],PT0S[TIME_DURATION]) AS languages.long#33, VALUES(languages.short{r}#34,true[BOOLEAN],PT0S[TIME_DURATION]) AS languages.short#35, VALUES(last_name{r}#36,true[BOOLEAN],PT0S[TIME_DURATION]) AS last_name#37, VALUES(salary{r}#38,true[BOOLEAN],PT0S[TIME_DURATION]) AS salary#39, VALUES(salary_change{r}#40,true[BOOLEAN],PT0S[TIME_DURATION]) AS salary_change#41, VALUES(salary_change.int{r}#42,true[BOOLEAN],PT0S[TIME_DURATION]) AS salary_change.int#43, VALUES(salary_change.keyword{r}#44,true[BOOLEAN],PT0S[TIME_DURATION]) AS salary_change.keyword#45, VALUES(salary_change.long{r}#46,true[BOOLEAN],PT0S[TIME_DURATION]) AS salary_change.long#47, VALUES(still_hired{r}#48,true[BOOLEAN],PT0S[TIME_DURATION]) AS still_hired#49, VALUES(_index{r}#1,true[BOOLEAN],PT0S[TIME_DURATION]) AS _index#50, VALUES(_id{r}#0,true[BOOLEAN],PT0S[TIME_DURATION]) AS _id#51, VALUES(does_not_exist{r}#52,true[BOOLEAN],PT0S[TIME_DURATION]) AS does_not_exist#53, VALUES(x{r}#54,true[BOOLEAN],PT0S[TIME_DURATION]) AS x#55, VALUES(_fork{r}#56,true[BOOLEAN],PT0S[TIME_DURATION]) AS _fork#57, VALUES(y{r}#58,true[BOOLEAN],PT0S[TIME_DURATION]) AS y#59]] + \_FuseScoreEval[_score{r}#2,_fork{r}#56,RRF,null] + \_Fork[[avg_worked_seconds{r}#4, birth_date{r}#6, emp_no{r}#8, first_name{r}#10, gender{r}#12, height{r}#14, height.float{r}#16, height.half_float{r}#18, height.scaled_float{r}#20, hire_date{r}#22, is_rehired{r}#24, job_positions{r}#26, languages{r}#28, languages.byte{r}#30, languages.long{r}#32, languages.short{r}#34, last_name{r}#36, salary{r}#38, salary_change{r}#40, salary_change.int{r}#42, salary_change.keyword{r}#44, salary_change.long{r}#46, still_hired{r}#48, _score{r}#2, _index{r}#1, _id{r}#0, does_not_exist{r}#52, x{r}#54, _fork{r}#56, y{r}#58]] + |_Limit[1000[INTEGER],false,false] + | \_Project[[avg_worked_seconds{f(EsField)}#60, birth_date{f(DateEsField)}#61, emp_no{f(EsField)}#62, first_name{f(KeywordEsField)}#63, gender{f(KeywordEsField)}#64, height{f(EsField)}#65, height.float{f(EsField)}#66, height.half_float{f(EsField)}#67, height.scaled_float{f(EsField)}#68, hire_date{f(DateEsField)}#69, is_rehired{f(EsField)}#70, job_positions{f(KeywordEsField)}#71, languages{f(EsField)}#72, languages.byte{f(EsField)}#73, languages.long{f(EsField)}#74, languages.short{f(EsField)}#75, last_name{f(KeywordEsField)}#76, salary{f(EsField)}#77, salary_change{f(EsField)}#78, salary_change.int{f(EsField)}#79, salary_change.keyword{f(KeywordEsField)}#80, salary_change.long{f(EsField)}#81, still_hired{f(EsField)}#82, _score{m}#83, _index{m}#84, _id{m}#85, does_not_exist{r}#86, x{r}#87, _fork{r}#88, y{r}#89]] + | \_Eval[[null[INTEGER] AS y#89]] + | \_Eval[[fork1[KEYWORD] AS _fork#88]] + | \_Eval[[TODOUBLE(does_not_exist{r}#86) + 1[INTEGER] AS x#87]] + | \_Eval[[null[NULL] AS does_not_exist#86]] + | \_EsRelation[employees][avg_worked_seconds{f}#60, birth_date{f}#61, emp_no{f}#62, first_name{f}#63, gender{f}#64, height{f}#65, height.float{f}#66, height.half_float{f}#67, height.scaled_float{f}#68, hire_date{f}#69, is_rehired{f}#70, job_positions{f}#71, languages{f}#72, languages.byte{f}#73, languages.long{f}#74, languages.short{f}#75, last_name{f}#76, salary{f}#77, salary_change{f}#78, salary_change.int{f}#79, salary_change.keyword{f}#80, salary_change.long{f}#81, still_hired{f}#82, _score{m}#83, _index{m}#84, _id{m}#85] + \_Limit[1000[INTEGER],false,false] + \_Project[[avg_worked_seconds{f(EsField)}#90, birth_date{f(DateEsField)}#91, emp_no{f(EsField)}#92, first_name{f(KeywordEsField)}#93, gender{f(KeywordEsField)}#94, height{f(EsField)}#95, height.float{f(EsField)}#96, height.half_float{f(EsField)}#97, height.scaled_float{f(EsField)}#98, hire_date{f(DateEsField)}#99, is_rehired{f(EsField)}#100, job_positions{f(KeywordEsField)}#101, languages{f(EsField)}#102, languages.byte{f(EsField)}#103, languages.long{f(EsField)}#104, languages.short{f(EsField)}#105, last_name{f(KeywordEsField)}#106, salary{f(EsField)}#107, salary_change{f(EsField)}#108, salary_change.int{f(EsField)}#109, salary_change.keyword{f(KeywordEsField)}#110, salary_change.long{f(EsField)}#111, still_hired{f(EsField)}#112, _score{m}#83, _index{m}#84, _id{m}#85, does_not_exist{r}#113, x{r}#114, _fork{r}#88, y{r}#115]] + \_Eval[[null[NULL] AS does_not_exist#113, null[DOUBLE] AS x#114]] + \_Eval[[fork2[KEYWORD] AS _fork#88]] + \_Eval[[emp_no{f}#92 + 1[INTEGER] AS y#115]] + \_EsRelation[employees][avg_worked_seconds{f}#90, birth_date{f}#91, emp_no{f}#92, first_name{f}#93, gender{f}#94, height{f}#95, height.float{f}#96, height.half_float{f}#97, height.scaled_float{f}#98, hire_date{f}#99, is_rehired{f}#100, job_positions{f}#101, languages{f}#102, languages.byte{f}#103, languages.long{f}#104, languages.short{f}#105, last_name{f}#106, salary{f}#107, salary_change{f}#108, salary_change.int{f}#109, salary_change.keyword{f}#110, salary_change.long{f}#111, still_hired{f}#112, _score{m}#83, _index{m}#84, _id{m}#85] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testFuseWithEval/nullify/query.esql b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testFuseWithEval/nullify/query.esql new file mode 100644 index 0000000000000..b4413e66d0853 --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testFuseWithEval/nullify/query.esql @@ -0,0 +1,4 @@ +SET unmapped_fields="nullify"; FROM employees METADATA _score, _index, _id +| FORK (EVAL x = does_not_exist::DOUBLE + 1) + (EVAL y = emp_no + 1) +| FUSE RRF diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testKeep/load/analysis.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testKeep/load/analysis.expected index d21ff127af792..2dea9af44b3d1 100644 --- a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testKeep/load/analysis.expected +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testKeep/load/analysis.expected @@ -1,3 +1,4 @@ Limit[1000[INTEGER],false,false] -\_Project[[does_not_exist_field{f(PotentiallyUnmappedKeywordEsField)}#0]] - \_EsRelation[employees][avg_worked_seconds{f}#1, birth_date{f}#2, emp_no{f}#3, first_name{f}#4, gender{f}#5, height{f}#6, height.float{f}#7, height.half_float{f}#8, height.scaled_float{f}#9, hire_date{f}#10, is_rehired{f}#11, job_positions{f}#12, languages{f}#13, languages.byte{f}#14, languages.long{f}#15, languages.short{f}#16, last_name{f}#17, salary{f}#18, salary_change{f}#19, salary_change.int{f}#20, salary_change.keyword{f}#21, salary_change.long{f}#22, still_hired{f}#23, does_not_exist_field{f}#0] \ No newline at end of file +\_Project[[x{r}#0]] + \_Eval[[TOVERSION(does_not_exist_field{f(PotentiallyUnmappedKeywordEsField)}#1) AS x#0]] + \_EsRelation[employees][avg_worked_seconds{f}#2, birth_date{f}#3, emp_no{f}#4, first_name{f}#5, gender{f}#6, height{f}#7, height.float{f}#8, height.half_float{f}#9, height.scaled_float{f}#10, hire_date{f}#11, is_rehired{f}#12, job_positions{f}#13, languages{f}#14, languages.byte{f}#15, languages.long{f}#16, languages.short{f}#17, last_name{f}#18, salary{f}#19, salary_change{f}#20, salary_change.int{f}#21, salary_change.keyword{f}#22, salary_change.long{f}#23, still_hired{f}#24, does_not_exist_field{f}#1] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testKeep/load/query.esql b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testKeep/load/query.esql index 85b4cb1847fc2..4508523015814 100644 --- a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testKeep/load/query.esql +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testKeep/load/query.esql @@ -1,2 +1,3 @@ SET unmapped_fields="load"; FROM employees -| KEEP does_not_exist_field +| eval x = does_not_exist_field :: version +| keep x diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testKeep/nullify/analysis.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testKeep/nullify/analysis.expected index 4cc092c3f4aee..25f14d02025c3 100644 --- a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testKeep/nullify/analysis.expected +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testKeep/nullify/analysis.expected @@ -1,4 +1,5 @@ Limit[1000[INTEGER],false,false] -\_Project[[does_not_exist_field{r}#0]] - \_Eval[[null[NULL] AS does_not_exist_field#0]] - \_EsRelation[employees][avg_worked_seconds{f}#1, birth_date{f}#2, emp_no{f}#3, first_name{f}#4, gender{f}#5, height{f}#6, height.float{f}#7, height.half_float{f}#8, height.scaled_float{f}#9, hire_date{f}#10, is_rehired{f}#11, job_positions{f}#12, languages{f}#13, languages.byte{f}#14, languages.long{f}#15, languages.short{f}#16, last_name{f}#17, salary{f}#18, salary_change{f}#19, salary_change.int{f}#20, salary_change.keyword{f}#21, salary_change.long{f}#22, still_hired{f}#23] \ No newline at end of file +\_Project[[x{r}#0]] + \_Eval[[TOVERSION(does_not_exist_field{r}#1) AS x#0]] + \_Eval[[null[NULL] AS does_not_exist_field#1]] + \_EsRelation[employees][avg_worked_seconds{f}#2, birth_date{f}#3, emp_no{f}#4, first_name{f}#5, gender{f}#6, height{f}#7, height.float{f}#8, height.half_float{f}#9, height.scaled_float{f}#10, hire_date{f}#11, is_rehired{f}#12, job_positions{f}#13, languages{f}#14, languages.byte{f}#15, languages.long{f}#16, languages.short{f}#17, last_name{f}#18, salary{f}#19, salary_change{f}#20, salary_change.int{f}#21, salary_change.keyword{f}#22, salary_change.long{f}#23, still_hired{f}#24] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testKeep/nullify/query.esql b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testKeep/nullify/query.esql index aa0cb37ad9b24..696229a0c3317 100644 --- a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testKeep/nullify/query.esql +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testKeep/nullify/query.esql @@ -1,2 +1,3 @@ SET unmapped_fields="nullify"; FROM employees -| KEEP does_not_exist_field +| eval x = does_not_exist_field :: version +| keep x diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testLookupJoin/load/query.esql b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testLookupJoin/load/query.esql index 4297a1b213923..45bedb56b16b8 100644 --- a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testLookupJoin/load/query.esql +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testLookupJoin/load/query.esql @@ -1,3 +1,3 @@ SET unmapped_fields="load"; FROM employees -| EVAL language_code = does_not_exist::INTEGER +| EVAL language_code = does_not_exist :: INTEGER | LOOKUP JOIN languages_lookup ON language_code diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testLookupJoin/nullify/query.esql b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testLookupJoin/nullify/query.esql index e0f372f5ca05b..a17cbe97c2008 100644 --- a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testLookupJoin/nullify/query.esql +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testLookupJoin/nullify/query.esql @@ -1,3 +1,3 @@ SET unmapped_fields="nullify"; FROM employees -| EVAL language_code = does_not_exist::INTEGER +| EVAL language_code = does_not_exist :: INTEGER | LOOKUP JOIN languages_lookup ON language_code diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testMappedInOneIndexOnly/load/analysis.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testMappedInOneIndexOnly/load/analysis.expected new file mode 100644 index 0000000000000..4074128abfe69 --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testMappedInOneIndexOnly/load/analysis.expected @@ -0,0 +1,3 @@ +Limit[1000[INTEGER],false,false] +\_Project[[message{f(PotentiallyUnmappedKeywordEsField)}#0]] + \_EsRelation[sample_data,no_mapping_sample_data][@timestamp{f}#1, client_ip{f}#2, event_duration{f}#3, message{f}#0] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testMappedInOneIndexOnly/load/query.esql b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testMappedInOneIndexOnly/load/query.esql new file mode 100644 index 0000000000000..3b89545a17fb7 --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testMappedInOneIndexOnly/load/query.esql @@ -0,0 +1,2 @@ +SET unmapped_fields="load"; FROM sample_data, no_mapping_sample_data +| KEEP message diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testMappedInOneIndexOnly/nullify/analysis.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testMappedInOneIndexOnly/nullify/analysis.expected new file mode 100644 index 0000000000000..b2a87f783ec41 --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testMappedInOneIndexOnly/nullify/analysis.expected @@ -0,0 +1,3 @@ +Limit[1000[INTEGER],false,false] +\_Project[[message{f(KeywordEsField)}#0]] + \_EsRelation[sample_data,no_mapping_sample_data][@timestamp{f}#1, client_ip{f}#2, event_duration{f}#3, message{f}#0] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testMappedInOneIndexOnly/nullify/query.esql b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testMappedInOneIndexOnly/nullify/query.esql new file mode 100644 index 0000000000000..9ab256bac0ccc --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testMappedInOneIndexOnly/nullify/query.esql @@ -0,0 +1,2 @@ +SET unmapped_fields="nullify"; FROM sample_data, no_mapping_sample_data +| KEEP message diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testMappedInOneIndexOnlyCast/load/analysis.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testMappedInOneIndexOnlyCast/load/analysis.expected new file mode 100644 index 0000000000000..9ec2b3b4a4afd --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testMappedInOneIndexOnlyCast/load/analysis.expected @@ -0,0 +1,3 @@ +Limit[1000[INTEGER],false,false] +\_Eval[[TOLONG(message{f(PotentiallyUnmappedKeywordEsField)}#0) AS x#1]] + \_EsRelation[sample_data,no_mapping_sample_data][@timestamp{f}#2, client_ip{f}#3, event_duration{f}#4, message{f}#0] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testMappedInOneIndexOnlyCast/load/query.esql b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testMappedInOneIndexOnlyCast/load/query.esql new file mode 100644 index 0000000000000..5f15147e4ed84 --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testMappedInOneIndexOnlyCast/load/query.esql @@ -0,0 +1,2 @@ +SET unmapped_fields="load"; FROM sample_data, no_mapping_sample_data +| EVAL x = message :: LONG diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testMappedInOneIndexOnlyCast/nullify/analysis.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testMappedInOneIndexOnlyCast/nullify/analysis.expected new file mode 100644 index 0000000000000..199057917fbe8 --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testMappedInOneIndexOnlyCast/nullify/analysis.expected @@ -0,0 +1,3 @@ +Limit[1000[INTEGER],false,false] +\_Eval[[TOLONG(message{f(KeywordEsField)}#0) AS x#1]] + \_EsRelation[sample_data,no_mapping_sample_data][@timestamp{f}#2, client_ip{f}#3, event_duration{f}#4, message{f}#0] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testMappedInOneIndexOnlyCast/nullify/query.esql b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testMappedInOneIndexOnlyCast/nullify/query.esql new file mode 100644 index 0000000000000..46601c5b712ed --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testMappedInOneIndexOnlyCast/nullify/query.esql @@ -0,0 +1,2 @@ +SET unmapped_fields="nullify"; FROM sample_data, no_mapping_sample_data +| EVAL x = message :: LONG diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testMappedToNonKeywordInOneIndexOnly/load/analysis.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testMappedToNonKeywordInOneIndexOnly/load/analysis.expected new file mode 100644 index 0000000000000..812e7c610bd25 --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testMappedToNonKeywordInOneIndexOnly/load/analysis.expected @@ -0,0 +1,3 @@ +Limit[1000[INTEGER],false,false] +\_Project[[!event_duration]] + \_EsRelation[sample_data,no_mapping_sample_data][@timestamp{f}#0, client_ip{f}#1, event_duration{f}#2, message{f}#3] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testMappedToNonKeywordInOneIndexOnly/load/query.esql b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testMappedToNonKeywordInOneIndexOnly/load/query.esql new file mode 100644 index 0000000000000..2d32247edd0a4 --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testMappedToNonKeywordInOneIndexOnly/load/query.esql @@ -0,0 +1,2 @@ +SET unmapped_fields="load"; FROM sample_data, no_mapping_sample_data +| KEEP event_duration diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testMappedToNonKeywordInOneIndexOnly/nullify/analysis.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testMappedToNonKeywordInOneIndexOnly/nullify/analysis.expected new file mode 100644 index 0000000000000..c417694e5f80d --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testMappedToNonKeywordInOneIndexOnly/nullify/analysis.expected @@ -0,0 +1,3 @@ +Limit[1000[INTEGER],false,false] +\_Project[[event_duration{f(EsField)}#0]] + \_EsRelation[sample_data,no_mapping_sample_data][@timestamp{f}#1, client_ip{f}#2, event_duration{f}#0, message{f}#3] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testMappedToNonKeywordInOneIndexOnly/nullify/query.esql b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testMappedToNonKeywordInOneIndexOnly/nullify/query.esql new file mode 100644 index 0000000000000..dac9f41556304 --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testMappedToNonKeywordInOneIndexOnly/nullify/query.esql @@ -0,0 +1,2 @@ +SET unmapped_fields="nullify"; FROM sample_data, no_mapping_sample_data +| KEEP event_duration diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testMappedToNonKeywordInOneIndexOnlyCast/load/analysis.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testMappedToNonKeywordInOneIndexOnlyCast/load/analysis.expected new file mode 100644 index 0000000000000..18306fbb2a3b6 --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testMappedToNonKeywordInOneIndexOnlyCast/load/analysis.expected @@ -0,0 +1,4 @@ +Project[[@timestamp{f(DateEsField)}#0, client_ip{f(EsField)}#1, !event_duration, message{f(KeywordEsField)}#2, x{r}#3]] +\_Limit[1000[INTEGER],false,false] + \_Eval[[$$event_duration$converted_to$double{f(MultiTypeEsField)$}#4 AS x#3]] + \_EsRelation[sample_data,no_mapping_sample_data][@timestamp{f}#0, client_ip{f}#1, !event_duration, message{f}#2, $$event_duration$converted_to$double{f$}#4] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testMappedToNonKeywordInOneIndexOnlyCast/load/query.esql b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testMappedToNonKeywordInOneIndexOnlyCast/load/query.esql new file mode 100644 index 0000000000000..75ac5ca4e241d --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testMappedToNonKeywordInOneIndexOnlyCast/load/query.esql @@ -0,0 +1,2 @@ +SET unmapped_fields="load"; FROM sample_data, no_mapping_sample_data +| EVAL x = event_duration :: DOUBLE diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testMappedToNonKeywordInOneIndexOnlyCast/nullify/analysis.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testMappedToNonKeywordInOneIndexOnlyCast/nullify/analysis.expected new file mode 100644 index 0000000000000..bfa31bd940d18 --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testMappedToNonKeywordInOneIndexOnlyCast/nullify/analysis.expected @@ -0,0 +1,3 @@ +Limit[1000[INTEGER],false,false] +\_Eval[[TODOUBLE(event_duration{f(EsField)}#0) AS x#1]] + \_EsRelation[sample_data,no_mapping_sample_data][@timestamp{f}#2, client_ip{f}#3, event_duration{f}#0, message{f}#4] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testMappedToNonKeywordInOneIndexOnlyCast/nullify/query.esql b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testMappedToNonKeywordInOneIndexOnlyCast/nullify/query.esql new file mode 100644 index 0000000000000..59b35e88e844b --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testMappedToNonKeywordInOneIndexOnlyCast/nullify/query.esql @@ -0,0 +1,2 @@ +SET unmapped_fields="nullify"; FROM sample_data, no_mapping_sample_data +| EVAL x = event_duration :: DOUBLE diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testSubqueryKeep/load/query.esql b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testSubqueryKeep/load/query.esql new file mode 100644 index 0000000000000..7c1e28505d1fa --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testSubqueryKeep/load/query.esql @@ -0,0 +1,3 @@ +SET unmapped_fields="load"; SET unmapped_fields="load"; FROM employees, (FROM languages | KEEP emp_no) +| KEEP emp_no, language_code +| WHERE emp_no > 0 diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testSubqueryKeep/nullify/query.esql b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testSubqueryKeep/nullify/query.esql new file mode 100644 index 0000000000000..62dc68de394b6 --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testSubqueryKeep/nullify/query.esql @@ -0,0 +1,3 @@ +SET unmapped_fields="nullify"; SET unmapped_fields="load"; FROM employees, (FROM languages | KEEP emp_no) +| KEEP emp_no, language_code +| WHERE emp_no > 0 diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testSubqueryKeepUnmapped/load/analysis.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testSubqueryKeepUnmapped/load/analysis.expected index b4452dd003c30..cc9006fedeefc 100644 --- a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testSubqueryKeepUnmapped/load/analysis.expected +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testSubqueryKeepUnmapped/load/analysis.expected @@ -1,11 +1,13 @@ Limit[1000[INTEGER],false,false] \_Project[[emp_no{r}#0, language_code{r}#1, does_not_exist{r}#2]] \_UnionAll[[avg_worked_seconds{r}#3, birth_date{r}#4, emp_no{r}#0, first_name{r}#5, gender{r}#6, height{r}#7, height.float{r}#8, height.half_float{r}#9, height.scaled_float{r}#10, hire_date{r}#11, is_rehired{r}#12, job_positions{r}#13, languages{r}#14, languages.byte{r}#15, languages.long{r}#16, languages.short{r}#17, last_name{r}#18, salary{r}#19, salary_change{r}#20, salary_change.int{r}#21, salary_change.keyword{r}#22, salary_change.long{r}#23, still_hired{r}#24, language_code{r}#1, does_not_exist{r}#2]] - |_Project[[avg_worked_seconds{f(EsField)}#25, birth_date{f(DateEsField)}#26, emp_no{f(EsField)}#27, first_name{f(KeywordEsField)}#28, gender{f(KeywordEsField)}#29, height{f(EsField)}#30, height.float{f(EsField)}#31, height.half_float{f(EsField)}#32, height.scaled_float{f(EsField)}#33, hire_date{f(DateEsField)}#34, is_rehired{f(EsField)}#35, job_positions{f(KeywordEsField)}#36, languages{f(EsField)}#37, languages.byte{f(EsField)}#38, languages.long{f(EsField)}#39, languages.short{f(EsField)}#40, last_name{f(KeywordEsField)}#41, salary{f(EsField)}#42, salary_change{f(EsField)}#43, salary_change.int{f(EsField)}#44, salary_change.keyword{f(KeywordEsField)}#45, salary_change.long{f(EsField)}#46, still_hired{f(EsField)}#47, language_code{r}#48, does_not_exist{r}#49]] - | \_Eval[[null[INTEGER] AS language_code#48, null[KEYWORD] AS does_not_exist#49]] - | \_EsRelation[employees][avg_worked_seconds{f}#25, birth_date{f}#26, emp_no{f}#27, first_name{f}#28, gender{f}#29, height{f}#30, height.float{f}#31, height.half_float{f}#32, height.scaled_float{f}#33, hire_date{f}#34, is_rehired{f}#35, job_positions{f}#36, languages{f}#37, languages.byte{f}#38, languages.long{f}#39, languages.short{f}#40, last_name{f}#41, salary{f}#42, salary_change{f}#43, salary_change.int{f}#44, salary_change.keyword{f}#45, salary_change.long{f}#46, still_hired{f}#47] - \_Project[[avg_worked_seconds{r}#50, birth_date{r}#51, emp_no{r}#52, first_name{r}#53, gender{r}#54, height{r}#55, height.float{r}#56, height.half_float{r}#57, height.scaled_float{r}#58, hire_date{r}#59, is_rehired{r}#60, job_positions{r}#61, languages{r}#62, languages.byte{r}#63, languages.long{r}#64, languages.short{r}#65, last_name{r}#66, salary{r}#67, salary_change{r}#68, salary_change.int{r}#69, salary_change.keyword{r}#70, salary_change.long{r}#71, still_hired{r}#72, language_code{f(EsField)}#73, does_not_exist{f(PotentiallyUnmappedKeywordEsField)}#74]] - \_Eval[[null[LONG] AS avg_worked_seconds#50, null[DATETIME] AS birth_date#51, null[INTEGER] AS emp_no#52, null[KEYWORD] AS first_name#53, null[KEYWORD] AS gender#54, null[DOUBLE] AS height#55, null[DOUBLE] AS height.float#56, null[DOUBLE] AS height.half_float#57, null[DOUBLE] AS height.scaled_float#58, null[DATETIME] AS hire_date#59, null[BOOLEAN] AS is_rehired#60, null[KEYWORD] AS job_positions#61, null[INTEGER] AS languages#62, null[INTEGER] AS languages.byte#63, null[LONG] AS languages.long#64, null[INTEGER] AS languages.short#65, null[KEYWORD] AS last_name#66, null[INTEGER] AS salary#67, null[DOUBLE] AS salary_change#68, null[INTEGER] AS salary_change.int#69, null[KEYWORD] AS salary_change.keyword#70, null[LONG] AS salary_change.long#71, null[BOOLEAN] AS still_hired#72]] - \_Subquery[] - \_Project[[language_code{f(EsField)}#73, does_not_exist{f(PotentiallyUnmappedKeywordEsField)}#74]] - \_EsRelation[languages][language_code{f}#73, language_name{f}#75, does_not_exist{f}#74] \ No newline at end of file + |_Project[[avg_worked_seconds{f(EsField)}#25, birth_date{f(DateEsField)}#26, emp_no{f(EsField)}#27, first_name{f(KeywordEsField)}#28, gender{f(KeywordEsField)}#29, height{f(EsField)}#30, height.float{f(EsField)}#31, height.half_float{f(EsField)}#32, height.scaled_float{f(EsField)}#33, hire_date{f(DateEsField)}#34, is_rehired{f(EsField)}#35, job_positions{f(KeywordEsField)}#36, languages{f(EsField)}#37, languages.byte{f(EsField)}#38, languages.long{f(EsField)}#39, languages.short{f(EsField)}#40, last_name{f(KeywordEsField)}#41, salary{f(EsField)}#42, salary_change{f(EsField)}#43, salary_change.int{f(EsField)}#44, salary_change.keyword{f(KeywordEsField)}#45, salary_change.long{f(EsField)}#46, still_hired{f(EsField)}#47, language_code{r}#48, does_not_exist{f(PotentiallyUnmappedKeywordEsField)}#49]] + | \_Eval[[null[INTEGER] AS language_code#48]] + | \_EsRelation[employees][avg_worked_seconds{f}#25, birth_date{f}#26, emp_no{f}#27, first_name{f}#28, gender{f}#29, height{f}#30, height.float{f}#31, height.half_float{f}#32, height.scaled_float{f}#33, hire_date{f}#34, is_rehired{f}#35, job_positions{f}#36, languages{f}#37, languages.byte{f}#38, languages.long{f}#39, languages.short{f}#40, last_name{f}#41, salary{f}#42, salary_change{f}#43, salary_change.int{f}#44, salary_change.keyword{f}#45, salary_change.long{f}#46, still_hired{f}#47, does_not_exist{f}#49] + \_Project[[avg_worked_seconds{r}#50, birth_date{r}#51, emp_no{r}#52, first_name{r}#53, gender{r}#54, height{r}#55, height.float{r}#56, height.half_float{r}#57, height.scaled_float{r}#58, hire_date{r}#59, is_rehired{r}#60, job_positions{r}#61, languages{r}#62, languages.byte{r}#63, languages.long{r}#64, languages.short{r}#65, last_name{r}#66, salary{r}#67, salary_change{r}#68, salary_change.int{r}#69, salary_change.keyword{r}#70, salary_change.long{r}#71, still_hired{r}#72, language_code{f(EsField)}#73, does_not_exist{r}#74]] + \_Eval[[null[KEYWORD] AS does_not_exist#74]] + \_Project[[avg_worked_seconds{r}#50, birth_date{r}#51, emp_no{r}#52, first_name{r}#53, gender{r}#54, height{r}#55, height.float{r}#56, height.half_float{r}#57, height.scaled_float{r}#58, hire_date{r}#59, is_rehired{r}#60, job_positions{r}#61, languages{r}#62, languages.byte{r}#63, languages.long{r}#64, languages.short{r}#65, last_name{r}#66, salary{r}#67, salary_change{r}#68, salary_change.int{r}#69, salary_change.keyword{r}#70, salary_change.long{r}#71, still_hired{r}#72, language_code{f(EsField)}#73]] + \_Eval[[null[LONG] AS avg_worked_seconds#50, null[DATETIME] AS birth_date#51, null[INTEGER] AS emp_no#52, null[KEYWORD] AS first_name#53, null[KEYWORD] AS gender#54, null[DOUBLE] AS height#55, null[DOUBLE] AS height.float#56, null[DOUBLE] AS height.half_float#57, null[DOUBLE] AS height.scaled_float#58, null[DATETIME] AS hire_date#59, null[BOOLEAN] AS is_rehired#60, null[KEYWORD] AS job_positions#61, null[INTEGER] AS languages#62, null[INTEGER] AS languages.byte#63, null[LONG] AS languages.long#64, null[INTEGER] AS languages.short#65, null[KEYWORD] AS last_name#66, null[INTEGER] AS salary#67, null[DOUBLE] AS salary_change#68, null[INTEGER] AS salary_change.int#69, null[KEYWORD] AS salary_change.keyword#70, null[LONG] AS salary_change.long#71, null[BOOLEAN] AS still_hired#72]] + \_Subquery[] + \_Project[[language_code{f(EsField)}#73]] + \_EsRelation[languages][language_code{f}#73, language_name{f}#75, does_not_exist{f}#76] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testSubqueryKeepUnmapped/load/query.esql b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testSubqueryKeepUnmapped/load/query.esql index de7a454b426f7..1b76ece4d7ba5 100644 --- a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testSubqueryKeepUnmapped/load/query.esql +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testSubqueryKeepUnmapped/load/query.esql @@ -1,2 +1,2 @@ -SET unmapped_fields="load"; FROM employees, (FROM languages | KEEP language_code, does_not_exist) +SET unmapped_fields="load"; FROM employees, (FROM languages | KEEP language_code) | KEEP emp_no, language_code, does_not_exist diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testSubqueryKeepUnmapped/nullify/analysis.expected b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testSubqueryKeepUnmapped/nullify/analysis.expected index 6efd06cbbc7de..5d191d8cee373 100644 --- a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testSubqueryKeepUnmapped/nullify/analysis.expected +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testSubqueryKeepUnmapped/nullify/analysis.expected @@ -5,8 +5,10 @@ Limit[1000[INTEGER],false,false] | \_Eval[[null[INTEGER] AS language_code#48, null[NULL] AS does_not_exist#49]] | \_EsRelation[employees][avg_worked_seconds{f}#25, birth_date{f}#26, emp_no{f}#27, first_name{f}#28, gender{f}#29, height{f}#30, height.float{f}#31, height.half_float{f}#32, height.scaled_float{f}#33, hire_date{f}#34, is_rehired{f}#35, job_positions{f}#36, languages{f}#37, languages.byte{f}#38, languages.long{f}#39, languages.short{f}#40, last_name{f}#41, salary{f}#42, salary_change{f}#43, salary_change.int{f}#44, salary_change.keyword{f}#45, salary_change.long{f}#46, still_hired{f}#47] \_Project[[avg_worked_seconds{r}#50, birth_date{r}#51, emp_no{r}#52, first_name{r}#53, gender{r}#54, height{r}#55, height.float{r}#56, height.half_float{r}#57, height.scaled_float{r}#58, hire_date{r}#59, is_rehired{r}#60, job_positions{r}#61, languages{r}#62, languages.byte{r}#63, languages.long{r}#64, languages.short{r}#65, last_name{r}#66, salary{r}#67, salary_change{r}#68, salary_change.int{r}#69, salary_change.keyword{r}#70, salary_change.long{r}#71, still_hired{r}#72, language_code{f(EsField)}#73, does_not_exist{r}#74]] - \_Eval[[null[LONG] AS avg_worked_seconds#50, null[DATETIME] AS birth_date#51, null[INTEGER] AS emp_no#52, null[KEYWORD] AS first_name#53, null[KEYWORD] AS gender#54, null[DOUBLE] AS height#55, null[DOUBLE] AS height.float#56, null[DOUBLE] AS height.half_float#57, null[DOUBLE] AS height.scaled_float#58, null[DATETIME] AS hire_date#59, null[BOOLEAN] AS is_rehired#60, null[KEYWORD] AS job_positions#61, null[INTEGER] AS languages#62, null[INTEGER] AS languages.byte#63, null[LONG] AS languages.long#64, null[INTEGER] AS languages.short#65, null[KEYWORD] AS last_name#66, null[INTEGER] AS salary#67, null[DOUBLE] AS salary_change#68, null[INTEGER] AS salary_change.int#69, null[KEYWORD] AS salary_change.keyword#70, null[LONG] AS salary_change.long#71, null[BOOLEAN] AS still_hired#72]] - \_Subquery[] - \_Project[[language_code{f(EsField)}#73, does_not_exist{r}#74]] - \_Eval[[null[NULL] AS does_not_exist#74]] - \_EsRelation[languages][language_code{f}#73, language_name{f}#75] \ No newline at end of file + \_Eval[[null[NULL] AS does_not_exist#74]] + \_Project[[avg_worked_seconds{r}#50, birth_date{r}#51, emp_no{r}#52, first_name{r}#53, gender{r}#54, height{r}#55, height.float{r}#56, height.half_float{r}#57, height.scaled_float{r}#58, hire_date{r}#59, is_rehired{r}#60, job_positions{r}#61, languages{r}#62, languages.byte{r}#63, languages.long{r}#64, languages.short{r}#65, last_name{r}#66, salary{r}#67, salary_change{r}#68, salary_change.int{r}#69, salary_change.keyword{r}#70, salary_change.long{r}#71, still_hired{r}#72, language_code{f(EsField)}#73]] + \_Eval[[null[LONG] AS avg_worked_seconds#50, null[DATETIME] AS birth_date#51, null[INTEGER] AS emp_no#52, null[KEYWORD] AS first_name#53, null[KEYWORD] AS gender#54, null[DOUBLE] AS height#55, null[DOUBLE] AS height.float#56, null[DOUBLE] AS height.half_float#57, null[DOUBLE] AS height.scaled_float#58, null[DATETIME] AS hire_date#59, null[BOOLEAN] AS is_rehired#60, null[KEYWORD] AS job_positions#61, null[INTEGER] AS languages#62, null[INTEGER] AS languages.byte#63, null[LONG] AS languages.long#64, null[INTEGER] AS languages.short#65, null[KEYWORD] AS last_name#66, null[INTEGER] AS salary#67, null[DOUBLE] AS salary_change#68, null[INTEGER] AS salary_change.int#69, null[KEYWORD] AS salary_change.keyword#70, null[LONG] AS salary_change.long#71, null[BOOLEAN] AS still_hired#72]] + \_Subquery[] + \_Project[[language_code{f(EsField)}#73]] + \_Eval[[null[NULL] AS does_not_exist#75]] + \_EsRelation[languages][language_code{f}#73, language_name{f}#76] \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testSubqueryKeepUnmapped/nullify/query.esql b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testSubqueryKeepUnmapped/nullify/query.esql index 8aa4d0fd116ce..b1c83359017cb 100644 --- a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testSubqueryKeepUnmapped/nullify/query.esql +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testSubqueryKeepUnmapped/nullify/query.esql @@ -1,2 +1,2 @@ -SET unmapped_fields="nullify"; FROM employees, (FROM languages | KEEP language_code, does_not_exist) +SET unmapped_fields="nullify"; FROM employees, (FROM languages | KEEP language_code) | KEEP emp_no, language_code, does_not_exist diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testTBucketFromIndexWithoutMappedTimestamp/load/query.esql b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testTBucketFromIndexWithoutMappedTimestamp/load/query.esql new file mode 100644 index 0000000000000..f2fed1cf47861 --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testTBucketFromIndexWithoutMappedTimestamp/load/query.esql @@ -0,0 +1,2 @@ +SET unmapped_fields="load"; FROM employees +| STATS c = COUNT(*) BY tbucket(1 hour) diff --git a/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testTBucketFromIndexWithoutMappedTimestamp/nullify/query.esql b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testTBucketFromIndexWithoutMappedTimestamp/nullify/query.esql new file mode 100644 index 0000000000000..8f4b99c0e762b --- /dev/null +++ b/x-pack/plugin/esql/src/test/resources/org/elasticsearch/xpack/esql/analysis/golden_tests/AnalyzerUnmappedGoldenTests/testTBucketFromIndexWithoutMappedTimestamp/nullify/query.esql @@ -0,0 +1,2 @@ +SET unmapped_fields="nullify"; FROM employees +| STATS c = COUNT(*) BY tbucket(1 hour) diff --git a/x-pack/plugin/sql/qa/server/src/main/resources/apps.csv b/x-pack/plugin/sql/qa/server/src/main/resources/apps.csv index 9bd4123424f02..7fefd7bfb316f 100644 --- a/x-pack/plugin/sql/qa/server/src/main/resources/apps.csv +++ b/x-pack/plugin/sql/qa/server/src/main/resources/apps.csv @@ -1,4 +1,4 @@ -id,version,name +id,version2,name 1,1,aaaaa 2,2.1,bbbbb 3,2.3.4,ccccc From 9aaca405d06fc297250e537a0796151026d58f0a Mon Sep 17 00:00:00 2001 From: Gal Lalouche Date: Fri, 6 Feb 2026 20:13:56 +0200 Subject: [PATCH 24/25] Added some nullify tests, fix CsvTests bug --- .idea/inspectionProfiles/Project_Default.xml | 15 --- .../xpack/esql/qa/rest/EsqlSpecTestCase.java | 3 + .../main/resources/unmapped-nullify.csv-spec | 106 ++++++++++++++++++ .../elasticsearch/xpack/esql/CsvTests.java | 27 ++++- .../analysis/AnalyzerUnmappedGoldenTests.java | 25 ++++- .../TestPhysicalOperationProviders.java | 42 +++++-- 6 files changed, 181 insertions(+), 37 deletions(-) delete mode 100644 .idea/inspectionProfiles/Project_Default.xml diff --git a/.idea/inspectionProfiles/Project_Default.xml b/.idea/inspectionProfiles/Project_Default.xml deleted file mode 100644 index c99248332b8a9..0000000000000 --- a/.idea/inspectionProfiles/Project_Default.xml +++ /dev/null @@ -1,15 +0,0 @@ - - - - \ No newline at end of file diff --git a/x-pack/plugin/esql/qa/server/src/main/java/org/elasticsearch/xpack/esql/qa/rest/EsqlSpecTestCase.java b/x-pack/plugin/esql/qa/server/src/main/java/org/elasticsearch/xpack/esql/qa/rest/EsqlSpecTestCase.java index fdddd59d84255..a6d5dfa6fe30b 100644 --- a/x-pack/plugin/esql/qa/server/src/main/java/org/elasticsearch/xpack/esql/qa/rest/EsqlSpecTestCase.java +++ b/x-pack/plugin/esql/qa/server/src/main/java/org/elasticsearch/xpack/esql/qa/rest/EsqlSpecTestCase.java @@ -371,6 +371,9 @@ protected void doTest() throws Throwable { } protected final void doTest(String query) throws Throwable { + if (query.toUpperCase().startsWith("SET") == false) { + query = "SET unmapped_fields=\"load\"; " + query; + } RequestObjectBuilder builder = new RequestObjectBuilder(randomFrom(XContentType.values())); if (query.toUpperCase(Locale.ROOT).contains("LOOKUP_\uD83D\uDC14")) { diff --git a/x-pack/plugin/esql/qa/testFixtures/src/main/resources/unmapped-nullify.csv-spec b/x-pack/plugin/esql/qa/testFixtures/src/main/resources/unmapped-nullify.csv-spec index b2644559ad26a..48f0e0db265fa 100644 --- a/x-pack/plugin/esql/qa/testFixtures/src/main/resources/unmapped-nullify.csv-spec +++ b/x-pack/plugin/esql/qa/testFixtures/src/main/resources/unmapped-nullify.csv-spec @@ -12,6 +12,22 @@ null null ; +partialMappingUnmappedFromSource +required_capability: optional_fields_nullify_tech_preview + +SET unmapped_fields="nullify"\; +FROM partial_mapping_sample_data +| KEEP @timestamp, unmapped_message +| SORT @timestamp DESC +| LIMIT 3 +; + +@timestamp:date | unmapped_message:null +2024-10-23T13:55:01.543Z | null +2024-10-23T13:53:55.832Z | null +2024-10-23T13:52:55.015Z | null +; + keepStar required_capability: optional_fields_nullify_tech_preview @@ -482,3 +498,93 @@ ROW x = 1 x:integer |does_not_exist:null |y:keyword | language_name:keyword 1 |null |null |null ; + +partiallyUnmappedKeywordMultiIndex +required_capability: optional_fields_nullify_tech_preview +required_capability: index_metadata_field + +SET unmapped_fields="nullify"\; +FROM sample_data, no_mapping_sample_data METADATA _index +| KEEP _index, @timestamp, message +| SORT _index, @timestamp DESC +; + +_index:keyword | @timestamp:date | message:keyword +no_mapping_sample_data | null | null +no_mapping_sample_data | null | null +no_mapping_sample_data | null | null +no_mapping_sample_data | null | null +no_mapping_sample_data | null | null +no_mapping_sample_data | null | null +no_mapping_sample_data | null | null +sample_data | 2023-10-23T13:55:01.543Z | Connected to 10.1.0.1 +sample_data | 2023-10-23T13:53:55.832Z | Connection error +sample_data | 2023-10-23T13:52:55.015Z | Connection error +sample_data | 2023-10-23T13:51:54.732Z | Connection error +sample_data | 2023-10-23T13:33:34.937Z | Disconnected +sample_data | 2023-10-23T12:27:28.948Z | Connected to 10.1.0.2 +sample_data | 2023-10-23T12:15:03.360Z | Connected to 10.1.0.3 +; + +partiallyUnmappedNonKeywordMultiIndexCast +required_capability: optional_fields_nullify_tech_preview +required_capability: index_metadata_field + +SET unmapped_fields="nullify"\; +FROM sample_data, no_mapping_sample_data METADATA _index +| EVAL duration = event_duration::DOUBLE +| KEEP _index, @timestamp, duration +| SORT _index, @timestamp DESC +; + +_index:keyword | @timestamp:date | duration:double +no_mapping_sample_data | null | null +no_mapping_sample_data | null | null +no_mapping_sample_data | null | null +no_mapping_sample_data | null | null +no_mapping_sample_data | null | null +no_mapping_sample_data | null | null +no_mapping_sample_data | null | null +sample_data | 2023-10-23T13:55:01.543Z | 1756467.0 +sample_data | 2023-10-23T13:53:55.832Z | 5033755.0 +sample_data | 2023-10-23T13:52:55.015Z | 8268153.0 +sample_data | 2023-10-23T13:51:54.732Z | 725448.0 +sample_data | 2023-10-23T13:33:34.937Z | 1232382.0 +sample_data | 2023-10-23T12:27:28.948Z | 2764889.0 +sample_data | 2023-10-23T12:15:03.360Z | 3450233.0 +; + +partiallyUnmappedMixedTypesMultiIndexCast +required_capability: optional_fields_nullify_tech_preview +required_capability: index_metadata_field + +SET unmapped_fields="nullify"\; +FROM sample_data, logs, no_mapping_sample_data METADATA _index +| EVAL msg = message::KEYWORD +| KEEP _index, @timestamp, msg +| SORT _index, @timestamp DESC +; + +_index:keyword | @timestamp:date | msg:keyword +logs | 2023-10-23T13:57:01.544Z | Running cats (cycle 3) +logs | 2023-10-23T13:56:01.544Z | Running cats (cycle 2) +logs | 2023-10-23T13:56:01.543Z | No response +logs | 2023-10-23T13:55:01.546Z | More java stuff +logs | 2023-10-23T13:55:01.545Z | Doing java stuff for 192.168.86.038 +logs | 2023-10-23T13:55:01.544Z | Running cats (cycle 1) +logs | 2023-10-23T13:55:01.543Z | Pinging 192.168.86.046 +no_mapping_sample_data | null | null +no_mapping_sample_data | null | null +no_mapping_sample_data | null | null +no_mapping_sample_data | null | null +no_mapping_sample_data | null | null +no_mapping_sample_data | null | null +no_mapping_sample_data | null | null +sample_data | 2023-10-23T13:55:01.543Z | Connected to 10.1.0.1 +sample_data | 2023-10-23T13:53:55.832Z | Connection error +sample_data | 2023-10-23T13:52:55.015Z | Connection error +sample_data | 2023-10-23T13:51:54.732Z | Connection error +sample_data | 2023-10-23T13:33:34.937Z | Disconnected +sample_data | 2023-10-23T12:27:28.948Z | Connected to 10.1.0.2 +sample_data | 2023-10-23T12:15:03.360Z | Connected to 10.1.0.3 +; diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/CsvTests.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/CsvTests.java index bb3eb9518bd29..521f794233f25 100644 --- a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/CsvTests.java +++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/CsvTests.java @@ -720,19 +720,35 @@ public static Map testDa private static TestPhysicalOperationProviders testOperationProviders( FoldContext foldCtx, - Map allDatasets + Map allDatasets, + UnmappedResolution unmappedResolution ) throws Exception { var indexPages = new ArrayList(); for (CsvTestsDataLoader.MultiIndexTestDataset datasets : allDatasets.values()) { for (CsvTestsDataLoader.TestDataset dataset : datasets.datasets()) { var testData = loadPageFromCsv(CsvTests.class.getResource("/data/" + dataset.dataFileName()), dataset.typeMapping()); - Set mappedFields = loadMapping(dataset.mappingFileName()).keySet(); + Set mappedFields = flattenMappingNames(loadMapping(dataset.mappingFileName())); indexPages.add( new TestPhysicalOperationProviders.IndexPage(dataset.indexName(), testData.v1(), testData.v2(), mappedFields) ); } } - return TestPhysicalOperationProviders.create(foldCtx, indexPages); + return TestPhysicalOperationProviders.create(foldCtx, indexPages, unmappedResolution); + } + + private static Set flattenMappingNames(Map mapping) { + Set result = new HashSet<>(); + for (Map.Entry entry : mapping.entrySet()) { + collectFieldNames(entry.getKey(), entry.getValue(), result); + } + return result; + } + + private static void collectFieldNames(String prefix, EsField field, Set result) { + result.add(prefix); + for (Map.Entry sub : field.getProperties().entrySet()) { + collectFieldNames(prefix + "." + sub.getKey(), sub.getValue(), result); + } } private ActualResults executePlan(BigArrays bigArrays) throws Exception { @@ -748,7 +764,8 @@ private ActualResults executePlan(BigArrays bigArrays) throws Exception { var testDatasets = testDatasets(plan); // Specifically use the newest transport version; the csv tests correspond to a single node cluster on the current version. TransportVersion minimumVersion = TransportVersion.current(); - LogicalPlan analyzed = analyzedPlan(plan, statement.setting(UNMAPPED_FIELDS), configuration, testDatasets, minimumVersion); + var unmappedResolution = statement.setting(UNMAPPED_FIELDS); + LogicalPlan analyzed = analyzedPlan(plan, unmappedResolution, configuration, testDatasets, minimumVersion); FoldContext foldCtx = FoldContext.small(); EsqlSession session = new EsqlSession( @@ -767,7 +784,7 @@ private ActualResults executePlan(BigArrays bigArrays) throws Exception { null, EsqlTestUtils.MOCK_TRANSPORT_ACTION_SERVICES ); - TestPhysicalOperationProviders physicalOperationProviders = testOperationProviders(foldCtx, testDatasets); + TestPhysicalOperationProviders physicalOperationProviders = testOperationProviders(foldCtx, testDatasets, unmappedResolution); PlainActionFuture listener = new PlainActionFuture<>(); var logicalPlanPreOptimizer = new LogicalPlanPreOptimizer( diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/analysis/AnalyzerUnmappedGoldenTests.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/analysis/AnalyzerUnmappedGoldenTests.java index 8aad5cdec6b1c..7db188b55c045 100644 --- a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/analysis/AnalyzerUnmappedGoldenTests.java +++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/analysis/AnalyzerUnmappedGoldenTests.java @@ -429,9 +429,8 @@ public void testMappedToNonKeywordInOneIndexOnly() throws Exception { """); } - @AwaitsFix(bugUrl = "https://github.com/elastic/elasticsearch/pull/141912") public void testMappedToNonKeywordInOneIndexOnlyCast() throws Exception { - runTests(""" + runTestsLoadOnly(""" FROM sample_data, no_mapping_sample_data | EVAL x = event_duration :: DOUBLE """); @@ -460,8 +459,8 @@ private static String setUnmappedLoad(String query) { } private void runTests(String query) { - var nullifyException = runTestsNullifyOnly(query); - var loadException = runTestsLoadOnly(query); + var nullifyException = tryRunTestsNullifyOnly(query); + var loadException = tryRunTestsLoadOnly(query); if (nullifyException.isPresent() && loadException.isPresent()) { throw new AssertionError("Both nullify and load modes failed", nullifyException.get()); } else if (nullifyException.isPresent()) { @@ -471,13 +470,27 @@ private void runTests(String query) { } } - private Optional runTestsNullifyOnly(String query) { + private void runTestsNullifyOnly(String query) { + var nullifyException = tryRunTestsNullifyOnly(query); + if (nullifyException.isPresent()) { + throw new RuntimeException("Nullify mode failed", nullifyException.get()); + } + } + + private Optional tryRunTestsNullifyOnly(String query) { return EsqlCapabilities.Cap.OPTIONAL_FIELDS_NULLIFY_TECH_PREVIEW.isEnabled() ? builder(setUnmappedNullify(query)).nestedPath("nullify").stages(STAGES).tryRun() : Optional.empty(); } - private Optional runTestsLoadOnly(String query) { + private void runTestsLoadOnly(String query) { + var loadException = tryRunTestsLoadOnly(query); + if (loadException.isPresent()) { + throw new RuntimeException("Load mode failed", loadException.get()); + } + } + + private Optional tryRunTestsLoadOnly(String query) { return EsqlCapabilities.Cap.OPTIONAL_FIELDS.isEnabled() ? builder(setUnmappedLoad(query)).nestedPath("load").stages(STAGES).tryRun() : Optional.empty(); diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/planner/TestPhysicalOperationProviders.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/planner/TestPhysicalOperationProviders.java index 9d6815b74af5e..fc9e383e95021 100644 --- a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/planner/TestPhysicalOperationProviders.java +++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/planner/TestPhysicalOperationProviders.java @@ -43,6 +43,7 @@ import org.elasticsearch.plugins.scanners.StablePluginsRegistry; import org.elasticsearch.xpack.cluster.routing.allocation.mapper.DataTierFieldMapper; import org.elasticsearch.xpack.esql.EsqlIllegalArgumentException; +import org.elasticsearch.xpack.esql.analysis.UnmappedResolution; import org.elasticsearch.xpack.esql.core.expression.Attribute; import org.elasticsearch.xpack.esql.core.expression.FieldAttribute; import org.elasticsearch.xpack.esql.core.expression.FoldContext; @@ -77,14 +78,25 @@ public class TestPhysicalOperationProviders extends AbstractPhysicalOperationProviders { private final List indexPages; + private final UnmappedResolution unmappedResolution; - private TestPhysicalOperationProviders(FoldContext foldContext, List indexPages, AnalysisRegistry analysisRegistry) { + private TestPhysicalOperationProviders( + FoldContext foldContext, + List indexPages, + UnmappedResolution unmappedResolution, + AnalysisRegistry analysisRegistry + ) { super(foldContext, analysisRegistry); this.indexPages = indexPages; + this.unmappedResolution = unmappedResolution; } - public static TestPhysicalOperationProviders create(FoldContext foldContext, List indexPages) throws IOException { - return new TestPhysicalOperationProviders(foldContext, indexPages, createAnalysisRegistry()); + public static TestPhysicalOperationProviders create( + FoldContext foldContext, + List indexPages, + UnmappedResolution unmappedResolution + ) throws IOException { + return new TestPhysicalOperationProviders(foldContext, indexPages, unmappedResolution, createAnalysisRegistry()); } public record IndexPage(String index, Page page, List columnNames, Set mappedFields) { @@ -92,6 +104,7 @@ Optional columnIndex(String columnName) { var result = IntStream.range(0, columnNames.size()).filter(i -> columnNames.get(i).equals(columnName)).findFirst(); return result.isPresent() ? Optional.of(result.getAsInt()) : Optional.empty(); } + } private static AnalysisRegistry createAnalysisRegistry() throws IOException { @@ -283,11 +296,16 @@ private BiFunction getBlockExtraction(DriverCo } } return (indexDoc, blockCopier) -> switch (extractBlockForSingleDoc(indexDoc, attribute.name(), blockCopier)) { - case BlockResultMissing missing -> throw new EsqlIllegalArgumentException( - "Cannot find column named [{}] in {}", - missing.columnName, - missing.columnNames - ); + case BlockResultMissing missing -> { + if (unmappedResolution == UnmappedResolution.NULLIFY) { + yield getNullsBlock(indexDoc); + } + throw new EsqlIllegalArgumentException( + "Cannot find column named [{}] in {}", + missing.columnName, + missing.columnNames + ); + } case BlockResultSuccess success -> success.block; }; } @@ -338,9 +356,11 @@ private BlockResult extractBlockForSingleDoc(DocBlock docBlock, String columnNam docBlock.blockFactory() .newConstantBytesRefBlockWith(new BytesRef("data_content"), blockCopier.docIndices.getPositionCount()) ); - default -> indexPage.columnIndex(columnName) - .map(columnIndex -> new BlockResultSuccess(blockCopier.copyBlock(indexPage.page.getBlock(columnIndex)))) - .orElseGet(() -> new BlockResultMissing(columnName, indexPage.columnNames())); + default -> unmappedResolution == UnmappedResolution.NULLIFY && indexPage.mappedFields().contains(columnName) == false + ? new BlockResultMissing(columnName, indexPage.columnNames()) + : indexPage.columnIndex(columnName) + .map(columnIndex -> new BlockResultSuccess(blockCopier.copyBlock(indexPage.page.getBlock(columnIndex)))) + .orElseGet(() -> new BlockResultMissing(columnName, indexPage.columnNames())); }; } From 7a3b810c7ca25aab38df7d96bd47484971d3f86e Mon Sep 17 00:00:00 2001 From: elasticsearchmachine Date: Fri, 6 Feb 2026 18:21:57 +0000 Subject: [PATCH 25/25] [CI] Auto commit changes from spotless --- .../xpack/esql/planner/TestPhysicalOperationProviders.java | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/planner/TestPhysicalOperationProviders.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/planner/TestPhysicalOperationProviders.java index fc9e383e95021..da247eb443ecc 100644 --- a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/planner/TestPhysicalOperationProviders.java +++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/planner/TestPhysicalOperationProviders.java @@ -300,11 +300,7 @@ private BiFunction getBlockExtraction(DriverCo if (unmappedResolution == UnmappedResolution.NULLIFY) { yield getNullsBlock(indexDoc); } - throw new EsqlIllegalArgumentException( - "Cannot find column named [{}] in {}", - missing.columnName, - missing.columnNames - ); + throw new EsqlIllegalArgumentException("Cannot find column named [{}] in {}", missing.columnName, missing.columnNames); } case BlockResultSuccess success -> success.block; };