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 4527c52bcfefa..79ddee43fff65 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,7 +58,11 @@ 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.function.BiFunction; +import java.util.regex.Matcher; import java.util.regex.Pattern; import java.util.stream.Collectors; @@ -384,23 +388,64 @@ 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); + String full = plan.toString(Node.NodeStringFormat.FULL); + Files.writeString(output, normalizeNameIds(normalizeSyntheticNames(full)), 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(""); + /** + * Rewrites node IDs ({@code #n}) in the plan string to a stable numbering by order of first appearance. + * Actual IDs assigned during plan building can vary between runs, so this is needed to keep golden output deterministic. + */ + private static String normalizeNameIds(String planString) { + return replaceMatches(planString, IDENTIFIER_PATTERN, (matcher, idMap) -> { + int originalId = Integer.parseInt(matcher.group().substring(1)); // Drop the initial '#' prefix + return "#" + idMap.getId(originalId); + }); + } + + /** + * 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) { + return replaceMatches(full, SYNTHETIC_PATTERN, (matcher, idMap) -> { + String firstSegment = matcher.group(1); + return "$$" + firstSegment + "$" + idMap.getId(firstSegment); + }); + } + + private static String replaceMatches(String input, Pattern pattern, BiFunction, String> replacer) { + var idMap = new IdMap(); + Matcher matcher = pattern.matcher(input); + StringBuilder sb = new StringBuilder(); + int lastEnd = 0; + while (matcher.find()) { + sb.append(input, lastEnd, matcher.start()); + sb.append(replacer.apply(matcher, idMap)); + lastEnd = matcher.end(); + } + sb.append(input, lastEnd, input.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 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(toString(plan)); + String full = plan.toString(Node.NodeStringFormat.FULL); + String testString = normalize(normalizeNameIds(normalizeSyntheticNames(full))); 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 723ce904e88d3..fb387032f3d2a 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[[_doc{f}, hire_date{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[[_doc{f}#0, hire_date{f}#1],false] +\_ProjectExec[[_doc{f}#0, hire_date{f}#1]] + \_FieldExtractExec[hire_date{f}#1]<[],[]> + \_EsQueryExec[employees], indexMode[standard], [_doc{f}#0], 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 391e45f5b0835..9db0da8910f5b 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[[_doc{f}, hire_date{f}],false] +ExchangeSinkExec[[_doc{f}#0, hire_date{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}#0, hire_date{f}#1]] +\_TopN[[Order[hire_date{f}#1,ASC,LAST]],20[INTEGER],false] + \_EsRelation[employees][_doc{f}#0, 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}#1, 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/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 9bd1091990166..0315e1603645a 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[[_doc{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[[_doc{f}#0, $$order_by$0{r}#1],false] +\_ProjectExec[[_doc{f}#0, $$order_by$0{r}#1]] + \_TopNExec[[Order[$$order_by$0{r}#1,ASC,LAST]],20[INTEGER],36] + \_EvalExec[[SIN(height{f}#2) * 2[INTEGER] AS $$order_by$0#1]] + \_FieldExtractExec[height{f}#2]<[],[]> + \_EsQueryExec[employees], indexMode[standard], [_doc{f}#0], 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 edd351fd4feb2..42e09257b6138 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[[_doc{f}, $$order_by{r}],false] +ExchangeSinkExec[[_doc{f}#0, $$order_by$0{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}#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][_doc{f}#0, 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}#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/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..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}, $$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{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/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..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}]] -\_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{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}, $$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{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 18dffd6ba00d3..f1a5151c994d2 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[[_doc{f}, height{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[[_doc{f}#0, height{f}#1, $$order_by$0{r}#2],false] +\_ProjectExec[[_doc{f}#0, height{f}#1, $$order_by$0{r}#2]] + \_TopNExec[[Order[$$order_by$0{r}#2,ASC,LAST]],20[INTEGER],36] + \_EvalExec[[SIN(height{f}#1) * 2[INTEGER] AS $$order_by$0#2]] + \_FieldExtractExec[height{f}#1]<[],[]> + \_EsQueryExec[employees], indexMode[standard], [_doc{f}#0], 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 450d2bf335b05..202cc12a29fe2 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[[_doc{f}, height{f}, $$order_by{r}],false] +ExchangeSinkExec[[_doc{f}#0, height{f}#1, $$order_by$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}#0, height{f}#1, $$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][_doc{f}#0, 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}#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/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..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}, 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{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/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..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}, 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{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}, 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{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 16144b0f1de0f..0b739f1210f4d 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[[_doc{f}, emp_no{f}, languages{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[[_doc{f}#0, emp_no{f}#1, languages{f}#2, language_code{r}#3, language_name{f}#4],false] +\_ProjectExec[[_doc{f}#0, emp_no{f}#1, languages{f}#2, language_code{r}#3, language_name{f}#4]] + \_TopNExec[[Order[emp_no{f}#1,ASC,LAST]],20[INTEGER],82] + \_FieldExtractExec[emp_no{f}#1]<[],[]> + \_LookupJoinExec[[language_code{r}#3],[language_code{f}#5],[language_name{f}#4],null] + |_EvalExec[[languages{f}#2 AS language_code#3]] + | \_FieldExtractExec[languages{f}#2]<[],[]> + | \_EsQueryExec[employees], indexMode[standard], [_doc{f}#0], limit[], sort[] estimatedRowSize[66] queryBuilderAndTags [[QueryBuilderAndTags[query={ "esql_single_value" : { "field" : "emp_no", "next" : { @@ -22,4 +22,4 @@ ExchangeSinkExec[[_doc{f}, emp_no{f}, languages{f}, language_code{r}, language_n } }, 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}#5, language_name{f}#4]<>]] \ 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 d8621a842a5f3..8f1164f38c747 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[[_doc{f}, emp_no{f}, languages{f}, language_code{r}, language_name{f}],false] +ExchangeSinkExec[[_doc{f}#0, emp_no{f}#1, languages{f}#2, language_code{r}#3, language_name{f}#4],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}#0, emp_no{f}#1, languages{f}#2, language_code{r}#3, language_name{f}#4]] +\_TopN[[Order[emp_no{f}#1,ASC,LAST]],20[INTEGER],false] + \_Join[LEFT,[language_code{r}#3],[language_code{f}#5],null] + |_Eval[[languages{f}#2 AS language_code#3]] + | \_Filter[emp_no{f}#1 >= 10091[INTEGER] AND emp_no{f}#1 < 10094[INTEGER]] + | \_EsRelation[employees][_doc{f}#0, 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}#2, 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] + \_EsRelation[languages_lookup][LOOKUP][language_code{f}#5, language_name{f}#4]<>]] \ 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 8d71c6318ff7d..1c5150bf358d7 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[[_doc{f}, hire_date{f}, height{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[[_doc{f}#0, hire_date{f}#1, height{f}#2],false] +\_ProjectExec[[_doc{f}#0, hire_date{f}#1, height{f}#2]] + \_FieldExtractExec[hire_date{f}#1, height{f}#2]<[],[]> + \_EsQueryExec[employees], indexMode[standard], [_doc{f}#0], limit[20], sort[[FieldSort[field=hire_date{f}#1, direction=ASC, nulls=LAST], FieldSort[field=height{f}#2, 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 5ecfdc0e91ea9..494a0526f6dd3 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[[_doc{f}, hire_date{f}, height{f}],false] +ExchangeSinkExec[[_doc{f}#0, hire_date{f}#1, height{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}#0, hire_date{f}#1, height{f}#2]] +\_TopN[[Order[hire_date{f}#1,ASC,LAST], Order[height{f}#2,ASC,LAST]],20[INTEGER],false] + \_EsRelation[employees][_doc{f}#0, 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}#1, 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 723ce904e88d3..fb387032f3d2a 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[[_doc{f}, hire_date{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[[_doc{f}#0, hire_date{f}#1],false] +\_ProjectExec[[_doc{f}#0, hire_date{f}#1]] + \_FieldExtractExec[hire_date{f}#1]<[],[]> + \_EsQueryExec[employees], indexMode[standard], [_doc{f}#0], 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 391e45f5b0835..9db0da8910f5b 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[[_doc{f}, hire_date{f}],false] +ExchangeSinkExec[[_doc{f}#0, hire_date{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}#0, hire_date{f}#1]] +\_TopN[[Order[hire_date{f}#1,ASC,LAST]],20[INTEGER],false] + \_EsRelation[employees][_doc{f}#0, 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}#1, 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/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 b3b5c1a34e4bc..d345864f4bcb2 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[[_doc{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[[_doc{f}#0, height{f}#1],false] +\_ProjectExec[[_doc{f}#0, height{f}#1]] + \_FieldExtractExec[height{f}#1]<[],[]> + \_EsQueryExec[employees], indexMode[standard], [_doc{f}#0], 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 99ac7bd279208..8abcf07553c66 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[[_doc{f}, height{f}],false] +ExchangeSinkExec[[_doc{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}#0, height{f}#1]] +\_TopN[[Order[height{f}#1,ASC,LAST]],20[INTEGER],false] + \_EsRelation[employees][_doc{f}#0, avg_worked_seconds{f}#2, birth_date{f}#3, emp_no{f}#4, 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 81d5401085264..2022c5678fda7 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[[_doc{f}, salary{f}, hire_date{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[[_doc{f}#0, salary{f}#1, hire_date{f}#2],false] +\_ProjectExec[[_doc{f}#0, salary{f}#1, hire_date{f}#2]] + \_FieldExtractExec[salary{f}#1, hire_date{f}#2]<[],[]> + \_EsQueryExec[employees], indexMode[standard], [_doc{f}#0], limit[20], sort[[FieldSort[field=hire_date{f}#2, 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 435ccfdcf08e0..a3bf3dbd30194 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[[_doc{f}, salary{f}, hire_date{f}],false] +ExchangeSinkExec[[_doc{f}#0, salary{f}#1, hire_date{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}#0, salary{f}#1, hire_date{f}#2]] +\_TopN[[Order[hire_date{f}#2,ASC,LAST]],20[INTEGER],false] + \_Filter[salary{f}#1 > 10000[INTEGER]] + \_EsRelation[employees][_doc{f}#0, 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}#2, 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/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 723ce904e88d3..fb387032f3d2a 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[[_doc{f}, hire_date{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[[_doc{f}#0, hire_date{f}#1],false] +\_ProjectExec[[_doc{f}#0, hire_date{f}#1]] + \_FieldExtractExec[hire_date{f}#1]<[],[]> + \_EsQueryExec[employees], indexMode[standard], [_doc{f}#0], 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/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 391e45f5b0835..9db0da8910f5b 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[[_doc{f}, hire_date{f}],false] +ExchangeSinkExec[[_doc{f}#0, hire_date{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}#0, hire_date{f}#1]] +\_TopN[[Order[hire_date{f}#1,ASC,LAST]],20[INTEGER],false] + \_EsRelation[employees][_doc{f}#0, 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}#1, 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/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 5aa4ef96b07c0..80a4e9f155b81 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[[_doc{f}, hire_date{f}],false] -\_ProjectExec[[_doc{f}, hire_date{r}]] - \_EvalExec[[null[DATETIME] AS hire_date]] - \_EsQueryExec[employees], indexMode[standard], [_doc{f}], limit[20], sort[] estimatedRowSize[12] queryBuilderAndTags [[QueryBuilderAndTags[query=null, tags=[]]]] \ No newline at end of file +ExchangeSinkExec[[_doc{f}#0, hire_date{f}#1],false] +\_ProjectExec[[_doc{f}#0, hire_date{r}#1]] + \_EvalExec[[null[DATETIME] AS hire_date#1]] + \_EsQueryExec[employees], indexMode[standard], [_doc{f}#0], 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 391e45f5b0835..9db0da8910f5b 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[[_doc{f}, hire_date{f}],false] +ExchangeSinkExec[[_doc{f}#0, hire_date{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}#0, hire_date{f}#1]] +\_TopN[[Order[hire_date{f}#1,ASC,LAST]],20[INTEGER],false] + \_EsRelation[employees][_doc{f}#0, 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}#1, 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/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