From 214db2db4a628752411867a2f79384bbe59c31a9 Mon Sep 17 00:00:00 2001 From: Mark Tozzi Date: Mon, 4 Aug 2025 16:08:39 -0400 Subject: [PATCH 1/3] javadoc formatting --- .../optimizer/LogicalPlanOptimizerTests.java | 645 ++++++++++++++++-- 1 file changed, 602 insertions(+), 43 deletions(-) diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/optimizer/LogicalPlanOptimizerTests.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/optimizer/LogicalPlanOptimizerTests.java index 4c707ca977501..40920e9a1962e 100644 --- a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/optimizer/LogicalPlanOptimizerTests.java +++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/optimizer/LogicalPlanOptimizerTests.java @@ -232,10 +232,13 @@ public void testEmptyProjectionInStat() { /** * Expects * + *
+     * {@code
      * EsqlProject[[x{r}#6]]
      * \_Eval[[1[INTEGER] AS x]]
      *   \_Limit[1000[INTEGER]]
-     *     \_LocalRelation[[{e}#18],[ConstantNullBlock[positions=1]]]
+     *     \_LocalRelation[[{e}#18],[ConstantNullBlock[positions=1]]]}
+     * 
*/ public void testEmptyProjectInStatWithEval() { var plan = plan(""" @@ -263,13 +266,16 @@ public void testEmptyProjectInStatWithEval() { /** * Expects - * + *
+     * {@code
      * EsqlProject[[x{r}#8]]
      * \_Eval[[1[INTEGER] AS x]]
      *   \_Limit[1000[INTEGER]]
      *     \_Aggregate[[emp_no{f}#15],[emp_no{f}#15]]
      *       \_Filter[languages{f}#18 > 1[INTEGER]]
      *         \_EsRelation[test][_meta_field{f}#21, emp_no{f}#15, first_name{f}#16, ..]
+     * }
+     * 
*/ public void testEmptyProjectInStatWithGroupAndEval() { var plan = plan(""" @@ -316,9 +322,13 @@ public void testCombineProjections() { /** * Expects + *
+     * {@code
      * Project[[languages{f}#12 AS f2]]
      * \_Limit[1000[INTEGER]]
      *   \_EsRelation[test][_meta_field{f}#15, emp_no{f}#9, first_name{f}#10, g..]
+     * }
+     * 
*/ public void testCombineProjectionsWithEvalAndDrop() { var plan = plan(""" @@ -337,10 +347,14 @@ public void testCombineProjectionsWithEvalAndDrop() { /** * Expects + *
+     * {@code
      * Project[[last_name{f}#26, languages{f}#25 AS f2, f4{r}#13]]
      * \_Eval[[languages{f}#25 + 3[INTEGER] AS f4]]
      *   \_Limit[1000[INTEGER]]
      *     \_EsRelation[test][_meta_field{f}#28, emp_no{f}#22, first_name{f}#23, ..]
+     * }
+     * 
*/ public void testCombineProjectionsWithEval() { var plan = plan(""" @@ -404,10 +418,14 @@ public void testCombineProjectionWithAggregation() { /** * Expects + *
+     * {@code
      * Limit[1000[INTEGER]]
      * \_Aggregate[[last_name{f}#23, first_name{f}#20],[SUM(salary{f}#24) AS s, last_name{f}#23, first_name{f}#20, first_name{f}#2
      * 0 AS k]]
      *   \_EsRelation[test][_meta_field{f}#25, emp_no{f}#19, first_name{f}#20, ..]
+     * }
+     * 
*/ public void testCombineProjectionWithAggregationAndEval() { var plan = plan(""" @@ -425,9 +443,13 @@ public void testCombineProjectionWithAggregationAndEval() { /** * Expects + *
+     * {@code
      * TopN[[Order[x{r}#10,ASC,LAST]],1000[INTEGER]]
      * \_Aggregate[[languages{f}#16],[MAX(emp_no{f}#13) AS x, languages{f}#16]]
      *   \_EsRelation[test][_meta_field{f}#19, emp_no{f}#13, first_name{f}#14, ..]
+     * }
+     * 
*/ public void testRemoveOverridesInAggregate() throws Exception { var plan = plan(""" @@ -455,9 +477,13 @@ public void testRemoveOverridesInAggregate() throws Exception { /** * Expects + *
+     * {@code
      * TopN[[Order[b{r}#10,ASC,LAST]],1000[INTEGER]]
      * \_Aggregate[[b{r}#10],[languages{f}#16 AS b]]
      *   \_EsRelation[test][_meta_field{f}#19, emp_no{f}#13, first_name{f}#14, ..]
+     * }
+     * 
*/ public void testAggsWithOverridingInputAndGrouping() throws Exception { var plan = plan(""" @@ -479,10 +505,14 @@ public void testAggsWithOverridingInputAndGrouping() throws Exception { } /** + *
+     * {@code
      * Project[[s{r}#4 AS d, s{r}#4, last_name{f}#21, first_name{f}#18]]
      * \_Limit[1000[INTEGER]]
      *   \_Aggregate[[last_name{f}#21, first_name{f}#18],[SUM(salary{f}#22) AS s, last_name{f}#21, first_name{f}#18]]
      *     \_EsRelation[test][_meta_field{f}#23, emp_no{f}#17, first_name{f}#18, ..]
+     * }
+     * 
*/ public void testCombineProjectionWithDuplicateAggregation() { var plan = plan(""" @@ -501,10 +531,14 @@ public void testCombineProjectionWithDuplicateAggregation() { } /** + *
+     * {@code
      * Limit[1000[INTEGER]]
      * \_Aggregate[STANDARD,[],[SUM(salary{f}#12,true[BOOLEAN]) AS sum(salary), SUM(salary{f}#12,last_name{f}#11 == [44 6f 65][KEYW
      * ORD]) AS sum(salary) WheRe last_name ==   "Doe"]]
      *   \_EsRelation[test][_meta_field{f}#13, emp_no{f}#7, first_name{f}#8, ge..]
+     * }
+     * 
*/ public void testStatsWithFilteringDefaultAliasing() { var plan = plan(""" @@ -518,9 +552,13 @@ public void testStatsWithFilteringDefaultAliasing() { assertThat(Expressions.names(agg.aggregates()), contains("sum(salary)", "sum(salary) WheRe last_name == \"Doe\"")); } - /* + /** + *
+     * {@code
      * Limit[1000[INTEGER]]
      * \_LocalRelation[[sum(salary) where false{r}#26],[ConstantNullBlock[positions=1]]]
+     * }
+     * 
*/ public void testReplaceStatsFilteredAggWithEvalSingleAgg() { var plan = plan(""" @@ -537,11 +575,15 @@ public void testReplaceStatsFilteredAggWithEvalSingleAgg() { assertTrue(blocks[0].areAllValuesNull()); } - /* + /** + *
+     * {@code
      * Project[[sum(salary) + 1 where false{r}#68]]
      * \_Eval[[$$SUM$sum(salary)_+_1$0{r$}#79 + 1[INTEGER] AS sum(salary) + 1 where false]]
      *   \_Limit[1000[INTEGER]]
      *     \_LocalRelation[[$$SUM$sum(salary)_+_1$0{r$}#79],[ConstantNullBlock[positions=1]]]
+     * }
+     * 
*/ public void testReplaceStatsFilteredAggWithEvalSingleAggWithExpression() { var plan = plan(""" @@ -569,12 +611,16 @@ public void testReplaceStatsFilteredAggWithEvalSingleAggWithExpression() { assertTrue(blocks[0].areAllValuesNull()); } - /* + /** + *
+     * {@code
      * Project[[sum(salary) + 1 where false{r}#4, sum(salary) + 2{r}#6, emp_no{f}#7]]
      * \_Eval[[null[LONG] AS sum(salary) + 1 where false, $$SUM$sum(salary)_+_2$1{r$}#18 + 2[INTEGER] AS sum(salary) + 2]]
      *   \_Limit[1000[INTEGER]]
      *     \_Aggregate[STANDARD,[emp_no{f}#7],[SUM(salary{f}#12,true[BOOLEAN]) AS $$SUM$sum(salary)_+_2$1, emp_no{f}#7]]
      *       \_EsRelation[test][_meta_field{f}#13, emp_no{f}#7, first_name{f}#8, ge..]
+     * }
+     * 
*/ public void testReplaceStatsFilteredAggWithEvalMixedFilterAndNoFilter() { var plan = plan(""" @@ -602,13 +648,18 @@ public void testReplaceStatsFilteredAggWithEvalMixedFilterAndNoFilter() { var source = as(aggregate.child(), EsRelation.class); } - /* + /** + *
+     * {@code
      * Project[[sum(salary) + 1 where false{r}#3, sum(salary) + 3{r}#5, sum(salary) + 2 where false{r}#7]]
      * \_Eval[[null[LONG] AS sum(salary) + 1 where false, $$SUM$sum(salary)_+_3$1{r$}#19 + 3[INTEGER] AS sum(salary) + 3, nu
      * ll[LONG] AS sum(salary) + 2 where false]]
      *   \_Limit[1000[INTEGER]]
      *     \_Aggregate[STANDARD,[],[SUM(salary{f}#13,true[BOOLEAN]) AS $$SUM$sum(salary)_+_3$1]]
      *       \_EsRelation[test][_meta_field{f}#14, emp_no{f}#8, first_name{f}#9, ge..]
+     *       }
+     * 
+     *
      */
     public void testReplaceStatsFilteredAggWithEvalFilterFalseAndNull() {
         var plan = plan("""
@@ -644,9 +695,13 @@ public void testReplaceStatsFilteredAggWithEvalFilterFalseAndNull() {
         var source = as(aggregate.child(), EsRelation.class);
     }
 
-    /*
+    /**
+     * 
+     * {@code
      * Limit[1000[INTEGER]]
      * \_LocalRelation[[count(salary) where false{r}#3],[LongVectorBlock[vector=ConstantLongVector[positions=1, value=0]]]]
+     * }
+     * 
*/ public void testReplaceStatsFilteredAggWithEvalCount() { var plan = plan(""" @@ -664,11 +719,15 @@ public void testReplaceStatsFilteredAggWithEvalCount() { assertThat(block.asVector().getLong(0), is(0L)); } - /* + /** + *
+     * {@code
      * Project[[count_distinct(salary + 2) + 3 where false{r}#3]]
      * \_Eval[[$$COUNTDISTINCT$count_distinct(>$0{r$}#15 + 3[INTEGER] AS count_distinct(salary + 2) + 3 where false]]
      *   \_Limit[1000[INTEGER]]
      *     \_LocalRelation[[$$COUNTDISTINCT$count_distinct(>$0{r$}#15],[LongVectorBlock[vector=ConstantLongVector[positions=1, value=0]]]]
+     * }
+     * 
*/ public void testReplaceStatsFilteredAggWithEvalCountDistinctInExpression() { var plan = plan(""" @@ -697,13 +756,17 @@ public void testReplaceStatsFilteredAggWithEvalCountDistinctInExpression() { assertThat(block.asVector().getLong(0), is(0L)); } - /* + /** + *
+     * {@code
      * Project[[max{r}#91, max_a{r}#94, min{r}#97, min_a{r}#100, emp_no{f}#101]]
      * \_Eval[[null[INTEGER] AS max_a, null[INTEGER] AS min_a]]
      *   \_Limit[1000[INTEGER]]
      *     \_Aggregate[STANDARD,[emp_no{f}#101],[MAX(salary{f}#106,true[BOOLEAN]) AS max, MIN(salary{f}#106,true[BOOLEAN]) AS min, emp_
      * no{f}#101]]
      *       \_EsRelation[test][_meta_field{f}#107, emp_no{f}#101, first_name{f}#10..]
+     * }
+     * 
*/ public void testReplaceStatsFilteredAggWithEvalSameAggWithAndWithoutFilter() { var plan = plan(""" @@ -738,9 +801,13 @@ public void testReplaceStatsFilteredAggWithEvalSameAggWithAndWithoutFilter() { var source = as(aggregate.child(), EsRelation.class); } - /* + /** + *
+     * {@code
      * Limit[1000[INTEGER]]
      * \_LocalRelation[[count{r}#7],[LongVectorBlock[vector=ConstantLongVector[positions=1, value=0]]]]
+     * }
+     * 
*/ @AwaitsFix(bugUrl = "https://github.com/elastic/elasticsearch/issues/100634") // i.e. PropagateEvalFoldables applicability to Aggs public void testReplaceStatsFilteredAggWithEvalFilterUsingEvaledValue() { @@ -760,12 +827,17 @@ public void testReplaceStatsFilteredAggWithEvalFilterUsingEvaledValue() { assertThat(block.asVector().getLong(0), is(0L)); } - /* + /** + * + *
+     * {@code
      * Project[[c{r}#67, emp_no{f}#68]]
      * \_Eval[[0[LONG] AS c]]
      *   \_Limit[1000[INTEGER]]
      *     \_Aggregate[STANDARD,[emp_no{f}#68],[emp_no{f}#68]]
      *       \_EsRelation[test][_meta_field{f}#74, emp_no{f}#68, first_name{f}#69, ..]
+     * }
+     * 
*/ public void testReplaceStatsFilteredAggWithEvalSingleAggWithGroup() { var plan = plan(""" @@ -1101,9 +1173,13 @@ public void testCombineDisjunctionToInFromIn() { /** * Expects + *
+     * {@code
      * Limit[1000[INTEGER]]
      * \_Aggregate[[first_name{f}#12],[COUNT(salary{f}#16) AS count(salary), first_name{f}#12 AS x]]
      *   \_EsRelation[test][_meta_field{f}#17, emp_no{f}#11, first_name{f}#12, ..]
+     * }
+     * 
*/ public void testCombineProjectionWithPruning() { var plan = plan(""" @@ -1125,9 +1201,13 @@ public void testCombineProjectionWithPruning() { /** * Expects + *
+     * {@code
      * Limit[1000[INTEGER]]
      * \_Aggregate[[first_name{f}#16],[SUM(emp_no{f}#15) AS s, COUNT(first_name{f}#16) AS c, first_name{f}#16 AS f]]
      *   \_EsRelation[test][_meta_field{f}#21, emp_no{f}#15, first_name{f}#16, ..]
+     * }
+     * 
*/ public void testCombineProjectionWithAggregationFirstAndAliasedGroupingUsedInAgg() { var plan = plan(""" @@ -1155,9 +1235,13 @@ public void testCombineProjectionWithAggregationFirstAndAliasedGroupingUsedInAgg /** * Expects + *
+     * {@code
      * Limit[1000[INTEGER]]
      * \_Aggregate[STANDARD,[CATEGORIZE(first_name{f}#18) AS cat],[SUM(salary{f}#22,true[BOOLEAN]) AS s, cat{r}#10]]
      *   \_EsRelation[test][_meta_field{f}#23, emp_no{f}#17, first_name{f}#18, ..]
+     * }
+     * 
*/ public void testCombineProjectionWithCategorizeGrouping() { var plan = plan(""" @@ -1182,9 +1266,13 @@ public void testCombineProjectionWithCategorizeGrouping() { /** * Expects + *
+ * {@code * Limit[1000[INTEGER]] * \_Aggregate[[first_name{f}#16],[SUM(emp_no{f}#15) AS s, first_name{f}#16 AS f]] * \_EsRelation[test][_meta_field{f}#21, emp_no{f}#15, first_name{f}#16, ..] + * } + *
*/ public void testCombineProjectionWithAggregationFirstAndAliasedGroupingUnused() { var plan = plan(""" @@ -1208,10 +1296,14 @@ public void testCombineProjectionWithAggregationFirstAndAliasedGroupingUnused() /** * Expects + *
+     * {@code
      * EsqlProject[[x{r}#3, y{r}#6]]
      * \_Eval[[emp_no{f}#9 + 2[INTEGER] AS x, salary{f}#14 + 3[INTEGER] AS y]]
      *   \_Limit[10000[INTEGER]]
      *     \_EsRelation[test][_meta_field{f}#15, emp_no{f}#9, first_name{f}#10, g..]
+     * }
+     * 
*/ public void testCombineEvals() { var plan = plan(""" @@ -1764,9 +1856,13 @@ public void testCombineOrderByThroughFilter() { /** * Expected + *
+     * {@code
      * TopN[[Order[first_name{r}#5575,ASC,LAST]],1000[INTEGER]]
      * \_MvExpand[first_name{f}#5565,first_name{r}#5575,null]
      *   \_EsRelation[test][_meta_field{f}#5570, emp_no{f}#5564, first_name{f}#..]
+     * }
+     * 
*/ public void testDontCombineOrderByThroughMvExpand() { LogicalPlan plan = optimizedPlan(""" @@ -1783,11 +1879,15 @@ public void testDontCombineOrderByThroughMvExpand() { /** * Expected + *
+     * {@code
      * Limit[1000[INTEGER],true]
      * \_MvExpand[x{r}#4,x{r}#19]
      *   \_EsqlProject[[first_name{f}#9 AS x]]
      *     \_Limit[1000[INTEGER],false]
      *       \_EsRelation[test][_meta_field{f}#14, emp_no{f}#8, first_name{f}#9, ge..]
+     * }
+     * 
*/ public void testCopyDefaultLimitPastMvExpand() { LogicalPlan plan = optimizedPlan(""" @@ -1806,13 +1906,16 @@ public void testCopyDefaultLimitPastMvExpand() { /** * Expected - * + *
+     * {@code
      * Project[[languages{f}#10 AS language_code#4, language_name{f}#19]]
      * \_Limit[1000[INTEGER],true]
      *   \_Join[LEFT,[languages{f}#10],[languages{f}#10],[language_code{f}#18]]
      *     |_Limit[1000[INTEGER],false]
      *     | \_EsRelation[test][_meta_field{f}#13, emp_no{f}#7, first_name{f}#8, ge..]
      *     \_EsRelation[languages_lookup][LOOKUP][language_code{f}#18, language_name{f}#19]
+     * }
+     * 
*/ public void testCopyDefaultLimitPastLookupJoin() { LogicalPlan plan = optimizedPlan(""" @@ -1831,11 +1934,15 @@ public void testCopyDefaultLimitPastLookupJoin() { /** * Expected + *
+     * {@code
      * Limit[10[INTEGER],true]
      * \_MvExpand[first_name{f}#7,first_name{r}#17]
      *   \_EsqlProject[[first_name{f}#7, last_name{f}#10]]
      *     \_Limit[1[INTEGER],false]
      *       \_EsRelation[test][_meta_field{f}#12, emp_no{f}#6, first_name{f}#7, ge..]
+     * }
+     * 
*/ public void testDontPushDownLimitPastMvExpand() { LogicalPlan plan = optimizedPlan(""" @@ -1855,13 +1962,16 @@ public void testDontPushDownLimitPastMvExpand() { /** * Expected - * + *
+     * {@code
      * Project[[languages{f}#11 AS language_code#4, last_name{f}#12, language_name{f}#20]]
      * \_Limit[10[INTEGER],true]
      *   \_Join[LEFT,[languages{f}#11],[languages{f}#11],[language_code{f}#19]]
      *     |_Limit[1[INTEGER],false]
      *     | \_EsRelation[test][_meta_field{f}#14, emp_no{f}#8, first_name{f}#9, ge..]
      *     \_EsRelation[languages_lookup][LOOKUP][language_code{f}#19, language_name{f}#20]
+     * }
+     * 
*/ public void testDontPushDownLimitPastLookupJoin() { LogicalPlan plan = optimizedPlan(""" @@ -1882,6 +1992,8 @@ public void testDontPushDownLimitPastLookupJoin() { /** * Expected + *
+     * {@code
      * EsqlProject[[emp_no{f}#19, first_name{r}#30, languages{f}#22, lll{r}#9, salary{r}#31]]
      * \_TopN[[Order[salary{r}#31,DESC,FIRST]],5[INTEGER]]
      *   \_Limit[5[INTEGER],true]
@@ -1894,6 +2006,8 @@ public void testDontPushDownLimitPastLookupJoin() {
      *                 \_TopN[[Order[emp_no{f}#19,DESC,FIRST]],10[INTEGER]]
      *                   \_Filter[emp_no{f}#19 ≤ 10006[INTEGER]]
      *                     \_EsRelation[test][_meta_field{f}#25, emp_no{f}#19, first_name{f}#20, ..]
+     * }
+     * 
*/ public void testMultipleMvExpandWithSortAndLimit() { LogicalPlan plan = optimizedPlan(""" @@ -1931,6 +2045,8 @@ public void testMultipleMvExpandWithSortAndLimit() { /** * Expected * + *
+     * {@code
      * Project[[emp_no{f}#24, first_name{f}#25, languages{f}#27, lll{r}#11, salary{f}#29, language_name{f}#38]]
      * \_TopN[[Order[salary{f}#29,DESC,FIRST]],5[INTEGER]]
      *   \_Limit[5[INTEGER],true]
@@ -1945,6 +2061,8 @@ public void testMultipleMvExpandWithSortAndLimit() {
      *       |         |   \_EsRelation[test][_meta_field{f}#30, emp_no{f}#24, first_name{f}#25, ..]
      *       |         \_EsRelation[languages_lookup][LOOKUP][language_code{f}#35]
      *       \_EsRelation[languages_lookup][LOOKUP][language_code{f}#37, language_name{f}#38]
+     * }
+     * 
*/ public void testMultipleLookupJoinWithSortAndLimit() { LogicalPlan plan = optimizedPlan(""" @@ -1983,10 +2101,14 @@ public void testMultipleLookupJoinWithSortAndLimit() { } /** + *
+     * {@code
      * EsqlProject[[emp_no{f}#10, first_name{r}#21, salary{f}#15]]
      * \_TopN[[Order[salary{f}#15,ASC,LAST], Order[first_name{r}#21,ASC,LAST]],5[INTEGER]]
      *   \_MvExpand[first_name{f}#11,first_name{r}#21,null]
      *     \_EsRelation[test][_meta_field{f}#16, emp_no{f}#10, first_name{f}#11, ..]
+     * }
+     * 
*/ public void testPushDownLimitThroughMultipleSort_AfterMvExpand() { LogicalPlan plan = optimizedPlan(""" @@ -2007,11 +2129,15 @@ public void testPushDownLimitThroughMultipleSort_AfterMvExpand() { /** * Expected + *
+     * {@code
      * EsqlProject[[emp_no{f}#2560, first_name{r}#2571, salary{f}#2565]]
      * \_TopN[[Order[first_name{r}#2571,ASC,LAST]],5[INTEGER]]
      *   \_TopN[[Order[salary{f}#2565,ASC,LAST]],5[INTEGER]]
      *     \_MvExpand[first_name{f}#2561,first_name{r}#2571,null]
      *       \_EsRelation[test][_meta_field{f}#2566, emp_no{f}#2560, first_name{f}#..]
+     * }
+     * 
*/ public void testPushDownLimitThroughMultipleSort_AfterMvExpand2() { LogicalPlan plan = optimizedPlan(""" @@ -2038,12 +2164,16 @@ public void testPushDownLimitThroughMultipleSort_AfterMvExpand2() { * TODO: Push down the filter correctly https://github.com/elastic/elasticsearch/issues/115311 * * Expected + *
+     * {@code
      * Limit[5[INTEGER]]
      * \_Filter[ISNOTNULL(first_name{r}#23)]
      *   \_Aggregate[STANDARD,[first_name{r}#23],[MAX(salary{f}#18,true[BOOLEAN]) AS max_s, first_name{r}#23]]
      *     \_MvExpand[first_name{f}#14,first_name{r}#23]
      *       \_TopN[[Order[emp_no{f}#13,ASC,LAST]],50[INTEGER]]
      *         \_EsRelation[test][_meta_field{f}#19, emp_no{f}#13, first_name{f}#14, ..]
+     * }
+     * 
*/ public void testDontPushDownLimitPastAggregate_AndMvExpand() { LogicalPlan plan = optimizedPlan(""" @@ -2071,6 +2201,7 @@ public void testDontPushDownLimitPastAggregate_AndMvExpand() { * TODO: Push down the filter correctly https://github.com/elastic/elasticsearch/issues/115311 * * Expected + * * Limit[5[INTEGER],false] * \_Filter[ISNOTNULL(first_name{r}#23)] * \_Aggregate[STANDARD,[first_name{r}#23],[MAX(salary{f}#17,true[BOOLEAN]) AS max_s, first_name{r}#23]] @@ -2103,6 +2234,8 @@ public void testPushDown_TheRightLimit_PastMvExpand() { * * Expected * + *
+     * {@code
      * Limit[5[INTEGER],false]
      * \_Filter[ISNOTNULL(first_name{f}#15)]
      *   \_Aggregate[[first_name{f}#15],[MAX(salary{f}#19,true[BOOLEAN]) AS max_s#12, first_name{f}#15]]
@@ -2111,6 +2244,8 @@ public void testPushDown_TheRightLimit_PastMvExpand() {
      *         |_Limit[50[INTEGER],false]
      *         | \_EsRelation[test][_meta_field{f}#20, emp_no{f}#14, first_name{f}#15, ..]
      *         \_EsRelation[languages_lookup][LOOKUP][language_code{f}#25]
+     * }
+     * 
*/ public void testPushDown_TheRightLimit_PastLookupJoin() { LogicalPlan plan = optimizedPlan(""" @@ -2134,11 +2269,15 @@ public void testPushDown_TheRightLimit_PastLookupJoin() { /** * Expected + *
+     * {@code
      * EsqlProject[[first_name{f}#11, emp_no{f}#10, salary{f}#12, b{r}#4]]
      *  \_TopN[[Order[salary{f}#12,ASC,LAST]],5[INTEGER]]
      *    \_Eval[[100[INTEGER] AS b]]
      *      \_MvExpand[first_name{f}#11]
      *        \_EsRelation[employees][emp_no{f}#10, first_name{f}#11, salary{f}#12]
+     * }
+     * 
*/ public void testPushDownLimit_PastEvalAndMvExpand() { LogicalPlan plan = optimizedPlan(""" @@ -2161,11 +2300,15 @@ public void testPushDownLimit_PastEvalAndMvExpand() { /** * Expected + *
+     * {@code
      * EsqlProject[[emp_no{f}#5885, first_name{r}#5896, salary{f}#5890]]
      * \_TopN[[Order[salary{f}#5890,ASC,LAST], Order[first_name{r}#5896,ASC,LAST]],1000[INTEGER]]
      *   \_Filter[gender{f}#5887 == [46][KEYWORD] AND WILDCARDLIKE(first_name{r}#5896)]
      *     \_MvExpand[first_name{f}#5886,first_name{r}#5896,null]
      *       \_EsRelation[test][_meta_field{f}#5891, emp_no{f}#5885, first_name{f}#..]
+     * }
+     * 
*/ public void testRedundantSort_BeforeMvExpand_WithFilterOnExpandedField_ResultTruncationDefaultSize() { LogicalPlan plan = optimizedPlan(""" @@ -2190,11 +2333,15 @@ public void testRedundantSort_BeforeMvExpand_WithFilterOnExpandedField_ResultTru /** * Expected * + *
+     * {@code
      * Limit[10[INTEGER],true]
      * \_MvExpand[first_name{f}#7,first_name{r}#17]
      *   \_TopN[[Order[emp_no{f}#6,DESC,FIRST]],10[INTEGER]]
      *     \_Filter[emp_no{f}#6 ≤ 10006[INTEGER]]
      *       \_EsRelation[test][_meta_field{f}#12, emp_no{f}#6, first_name{f}#7, ge..]
+     * }
+     * 
*/ public void testFilterWithSortBeforeMvExpand() { LogicalPlan plan = optimizedPlan(""" @@ -2216,6 +2363,8 @@ public void testFilterWithSortBeforeMvExpand() { /** * Expected * + *
+     * {@code
      * Project[[_meta_field{f}#14, emp_no{f}#8, first_name{f}#9, gender{f}#10, hire_date{f}#15, job{f}#16, job.raw{f}#17,
      *          languages{f}#11 AS language_code#6, last_name{f}#12, long_noidx{f}#18, salary{f}#13, language_name{f}#20]]
      * \_Limit[10[INTEGER],true]
@@ -2224,6 +2373,8 @@ public void testFilterWithSortBeforeMvExpand() {
      *     | \_Filter[emp_no{f}#8 ≤ 10006[INTEGER]]
      *     |   \_EsRelation[test][_meta_field{f}#14, emp_no{f}#8, first_name{f}#9, ge..]
      *     \_EsRelation[languages_lookup][LOOKUP][language_code{f}#19, language_name{f}#20]
+     * }
+     * 
*/ public void testFilterWithSortBeforeLookupJoin() { LogicalPlan plan = optimizedPlan(""" @@ -2247,11 +2398,15 @@ public void testFilterWithSortBeforeLookupJoin() { /** * Expected * + *
+     * {@code
      * TopN[[Order[first_name{f}#10,ASC,LAST]],500[INTEGER]]
      * \_MvExpand[last_name{f}#13,last_name{r}#20,null]
      *   \_Filter[emp_no{r}#19 > 10050[INTEGER]]
      *     \_MvExpand[emp_no{f}#9,emp_no{r}#19,null]
      *       \_EsRelation[test][_meta_field{f}#15, emp_no{f}#9, first_name{f}#10, g..]
+     * }
+     * 
*/ public void testMultiMvExpand_SortDownBelow() { LogicalPlan plan = optimizedPlan(""" @@ -2274,6 +2429,8 @@ public void testMultiMvExpand_SortDownBelow() { /** * Expected * + *
+     * {@code
      * Limit[10000[INTEGER],true]
      * \_MvExpand[c{r}#7,c{r}#16]
      *   \_EsqlProject[[c{r}#7, a{r}#3]]
@@ -2284,7 +2441,8 @@ public void testMultiMvExpand_SortDownBelow() {
      *             \_LocalRelation[[a{r}#3, b{r}#5, c{r}#7],[ConstantNullBlock[positions=1],
      *               IntVectorBlock[vector=ConstantIntVector[positions=1, value=123]],
      *               IntVectorBlock[vector=ConstantIntVector[positions=1, value=234]]]]
-     *
+     * }
+     * 
*/ public void testLimitThenSortBeforeMvExpand() { LogicalPlan plan = optimizedPlan(""" @@ -2310,6 +2468,8 @@ public void testLimitThenSortBeforeMvExpand() { /** * Expects * + *
+     * {@code
      * Project[[c{r}#7 AS language_code#14, a{r}#3, language_name{f}#19]]
      * \_Limit[10000[INTEGER],true]
      *   \_Join[LEFT,[c{r}#7],[c{r}#7],[language_code{f}#18]]
@@ -2322,6 +2482,8 @@ public void testLimitThenSortBeforeMvExpand() {
      *                                                                   IntVectorBlock[vector=ConstantIntVector[positions=1, value=234]]]]
      *     |     \_EsRelation[languages_lookup][LOOKUP][language_code{f}#16]
      *     \_EsRelation[languages_lookup][LOOKUP][language_code{f}#18, language_name{f}#19]
+     * }
+     * 
*/ public void testLimitThenSortBeforeLookupJoin() { LogicalPlan plan = optimizedPlan(""" @@ -2348,9 +2510,13 @@ public void testLimitThenSortBeforeLookupJoin() { /** * Expected + *
+     * {@code
      * TopN[[Order[first_name{r}#16,ASC,LAST]],10000[INTEGER]]
      * \_MvExpand[first_name{f}#7,first_name{r}#16]
      *   \_EsRelation[test][_meta_field{f}#12, emp_no{f}#6, first_name{f}#7, ge..]
+     * }
+     * 
*/ public void testRemoveUnusedSortBeforeMvExpand_DefaultLimit10000() { LogicalPlan plan = optimizedPlan(""" @@ -2369,11 +2535,15 @@ public void testRemoveUnusedSortBeforeMvExpand_DefaultLimit10000() { /** * Expected + *
+     *  {@code
      * EsqlProject[[emp_no{f}#3517, first_name{r}#3528, salary{f}#3522]]
      * \_TopN[[Order[salary{f}#3522,ASC,LAST], Order[first_name{r}#3528,ASC,LAST]],15[INTEGER]]
      *   \_Filter[gender{f}#3519 == [46][KEYWORD] AND WILDCARDLIKE(first_name{r}#3528)]
      *     \_MvExpand[first_name{f}#3518,first_name{r}#3528,null]
      *       \_EsRelation[test][_meta_field{f}#3523, emp_no{f}#3517, first_name{f}#..]
+     *  }
+     * 
*/ public void testRedundantSort_BeforeMvExpand_WithFilterOnExpandedField() { LogicalPlan plan = optimizedPlan(""" @@ -2398,11 +2568,15 @@ public void testRedundantSort_BeforeMvExpand_WithFilterOnExpandedField() { /** * Expected + *
+     * {@code
      * EsqlProject[[emp_no{f}#3421, first_name{r}#3432, salary{f}#3426]]
      * \_TopN[[Order[salary{f}#3426,ASC,LAST], Order[first_name{r}#3432,ASC,LAST]],15[INTEGER]]
      *   \_Filter[gender{f}#3423 == [46][KEYWORD] AND salary{f}#3426 > 60000[INTEGER]]
      *     \_MvExpand[first_name{f}#3422,first_name{r}#3432,null]
      *       \_EsRelation[test][_meta_field{f}#3427, emp_no{f}#3421, first_name{f}#..]
+     * }
+     * 
*/ public void testRedundantSort_BeforeMvExpand_WithFilter_NOT_OnExpandedField() { LogicalPlan plan = optimizedPlan(""" @@ -2427,11 +2601,15 @@ public void testRedundantSort_BeforeMvExpand_WithFilter_NOT_OnExpandedField() { /** * Expected + *
+     * {@code
      * EsqlProject[[emp_no{f}#2085, first_name{r}#2096 AS x, salary{f}#2090]]
      * \_TopN[[Order[salary{f}#2090,ASC,LAST], Order[first_name{r}#2096,ASC,LAST]],15[INTEGER]]
      *   \_Filter[gender{f}#2087 == [46][KEYWORD] AND WILDCARDLIKE(first_name{r}#2096)]
      *     \_MvExpand[first_name{f}#2086,first_name{r}#2096,null]
      *       \_EsRelation[test][_meta_field{f}#2091, emp_no{f}#2085, first_name{f}#..]
+     * }
+     * 
*/ public void testRedundantSort_BeforeMvExpand_WithFilterOnExpandedFieldAlias() { LogicalPlan plan = optimizedPlan(""" @@ -2457,10 +2635,14 @@ public void testRedundantSort_BeforeMvExpand_WithFilterOnExpandedFieldAlias() { /** * Expected: + *
+     * {@code
      * Limit[1000[INTEGER],true]
      * \_MvExpand[a{r}#3,a{r}#7]
      *   \_TopN[[Order[a{r}#3,ASC,LAST]],1000[INTEGER]]
      *     \_LocalRelation[[a{r}#3],[IntVectorBlock[vector=ConstantIntVector[positions=1, value=1]]]]
+     * }
+     * 
*/ public void testSortMvExpand() { LogicalPlan plan = optimizedPlan(""" @@ -2477,11 +2659,15 @@ public void testSortMvExpand() { /** * Expected: + *
+     * {@code
      * Limit[1000[INTEGER],true]
      * \_Join[LEFT,[language_code{r}#3],[language_code{r}#3],[language_code{f}#6]]
      *   |_TopN[[Order[language_code{r}#3,ASC,LAST]],1000[INTEGER]]
      *   | \_LocalRelation[[language_code{r}#3],[IntVectorBlock[vector=ConstantIntVector[positions=1, value=1]]]]
      *   \_EsRelation[languages_lookup][LOOKUP][language_code{f}#6, language_name{f}#7]
+     * }
+     * 
*/ public void testSortLookupJoin() { LogicalPlan plan = optimizedPlan(""" @@ -2498,10 +2684,14 @@ public void testSortLookupJoin() { /** * Expected: + *
+     * {@code
      * Limit[20[INTEGER],true]
      * \_MvExpand[emp_no{f}#5,emp_no{r}#16]
      *   \_TopN[[Order[emp_no{f}#5,ASC,LAST]],20[INTEGER]]
      *     \_EsRelation[test][_meta_field{f}#11, emp_no{f}#5, first_name{f}#6, ge..]
+     * }
+     * 
*/ public void testSortMvExpandLimit() { LogicalPlan plan = optimizedPlan(""" @@ -2520,6 +2710,8 @@ public void testSortMvExpandLimit() { /** * Expected: * + *
+     * {@code
      * Project[[_meta_field{f}#13, emp_no{f}#7 AS language_code#5, first_name{f}#8, gender{f}#9, hire_date{f}#14, job{f}#15,
      *          job.raw{f}#16, languages{f}#10, last_name{f}#11, long_noidx{f}#17, salary{f}#12, language_name{f}#19]]
      * \_Limit[20[INTEGER],true]
@@ -2527,6 +2719,8 @@ public void testSortMvExpandLimit() {
      *     |_TopN[[Order[emp_no{f}#7,ASC,LAST]],20[INTEGER]]
      *     | \_EsRelation[test][_meta_field{f}#13, emp_no{f}#7, first_name{f}#8, ge..]
      *     \_EsRelation[languages_lookup][LOOKUP][language_code{f}#18, language_name{f}#19]
+     * }
+     * 
*/ public void testSortLookupJoinLimit() { LogicalPlan plan = optimizedPlan(""" @@ -2546,13 +2740,17 @@ public void testSortLookupJoinLimit() { /** * Expected: + *
+     * {@code
      * Limit[1000[INTEGER],true]
      * \_MvExpand[b{r}#5,b{r}#9]
      *   \_Limit[1000[INTEGER],false]
      *     \_LocalRelation[[a{r}#3, b{r}#5],[IntVectorBlock[vector=ConstantIntVector[positions=1, value=1]],
      *       IntVectorBlock[vector=ConstantIntVector[positions=1, value=-15]]]]
+     * }
+     * 
* - * see https://github.com/elastic/elasticsearch/issues/102084 + * see https://github.com/elastic/elasticsearch/issues/102084 */ public void testWhereMvExpand() { LogicalPlan plan = optimizedPlan(""" @@ -2569,12 +2767,16 @@ public void testWhereMvExpand() { /** * Expected: + *
+     * {@code
      * Limit[1000[INTEGER],true]
      * \_Join[LEFT,[language_code{r}#5],[language_code{r}#5],[language_code{f}#8]]
      *   |_Limit[1000[INTEGER],false]
      *   | \_LocalRelation[[a{r}#3, language_code{r}#5],[IntVectorBlock[vector=ConstantIntVector[positions=1, value=1]], IntVectorBlock[ve
      * ctor=ConstantIntVector[positions=1, value=-15]]]]
      *   \_EsRelation[languages_lookup][LOOKUP][language_code{f}#8, language_name{f}#9]
+     * }
+     * 
*/ public void testWhereLookupJoin() { LogicalPlan plan = optimizedPlan(""" @@ -2591,11 +2793,15 @@ public void testWhereLookupJoin() { /** * Expects + *
+     * {@code
      * TopN[[Order[language_code{r}#7,ASC,LAST]],1[INTEGER]]
      * \_Limit[1[INTEGER],true]
      *   \_MvExpand[language_code{r}#3,language_code{r}#7]
      *     \_Limit[1[INTEGER],false]
      *       \_LocalRelation[[language_code{r}#3],[IntVectorBlock[vector=ConstantIntVector[positions=1, value=1]]]]
+     * }
+     * 
* * Notice that the `TopN` at the very top has limit 1, not 3! */ @@ -2617,12 +2823,16 @@ public void testDescendantLimitMvExpand() { /** * Expects + *
+     * {@code
      * TopN[[Order[language_code{r}#3,ASC,LAST]],1[INTEGER]]
      * \_Limit[1[INTEGER],true]
      *   \_Join[LEFT,[language_code{r}#3],[language_code{r}#3],[language_code{f}#6]]
      *     |_Limit[1[INTEGER],false]
      *     | \_LocalRelation[[language_code{r}#3],[IntVectorBlock[vector=ConstantIntVector[positions=1, value=1]]]]
      *     \_EsRelation[languages_lookup][LOOKUP][language_code{f}#6, language_name{f}#7]
+     * }
+     * 
* * Notice that the `TopN` at the very top has limit 1, not 3! */ @@ -2642,11 +2852,15 @@ public void testDescendantLimitLookupJoin() { var localRelation = as(limitBefore.child(), LocalRelation.class); } - /* + /** + *
+     * {@code
      * EsqlProject[[emp_no{f}#9, first_name{f}#10, languages{f}#12, language_code{r}#3, language_name{r}#22]]
      * \_Eval[[null[INTEGER] AS language_code#3, null[KEYWORD] AS language_name#22]]
      *   \_Limit[1000[INTEGER],false]
      *     \_EsRelation[test][_meta_field{f}#15, emp_no{f}#9, first_name{f}#10, g..]
+     * }
+     * 
*/ public void testPruneJoinOnNullMatchingField() { var plan = optimizedPlan(""" @@ -2663,11 +2877,15 @@ public void testPruneJoinOnNullMatchingField() { var source = as(limit.child(), EsRelation.class); } - /* + /** + *
+     * {@code
      * Project[[emp_no{f}#15, first_name{f}#16, my_null{r}#3 AS language_code#9, language_name{r}#27]]
      * \_Eval[[null[INTEGER] AS my_null#3, null[KEYWORD] AS language_name#27]]
      *   \_Limit[1000[INTEGER],false]
      *     \_EsRelation[test][_meta_field{f}#21, emp_no{f}#15, first_name{f}#16, ..]
+     * }
+     * 
*/ public void testPruneJoinOnNullAssignedMatchingField() { var plan = optimizedPlan(""" @@ -2692,9 +2910,13 @@ private static List orderNames(TopN topN) { /** * Expects + *
+     * {@code
      * Eval[[2[INTEGER] AS x]]
      * \_Limit[1000[INTEGER],false]
      *   \_LocalRelation[[{e}#9],[ConstantNullBlock[positions=1]]]
+     * }
+     * 
*/ public void testEvalAfterStats() { var plan = optimizedPlan(""" @@ -2710,10 +2932,14 @@ public void testEvalAfterStats() { /** * Expects + *
+     * {@code
      * Eval[[2[INTEGER] AS x]]
      * \_Limit[1000[INTEGER],false]
      *   \_Aggregate[[foo{r}#3],[foo{r}#3 AS x]]
      *     \_LocalRelation[[foo{r}#3],[IntVectorBlock[vector=ConstantIntVector[positions=1, value=1]]]]
+     * }
+     * 
*/ public void testEvalAfterGroupBy() { var plan = optimizedPlan(""" @@ -3196,12 +3422,16 @@ public void testEnrichNotNullFilter() { /** * Expects + *
+     * {@code
      * EsqlProject[[a{r}#3, last_name{f}#9]]
      * \_Eval[[__a_SUM_123{r}#12 / __a_COUNT_150{r}#13 AS a]]
      *   \_Limit[10000[INTEGER]]
      *     \_Aggregate[[last_name{f}#9],[SUM(salary{f}#10) AS __a_SUM_123, COUNT(salary{f}#10) AS __a_COUNT_150, last_nam
      * e{f}#9]]
      *       \_EsRelation[test][_meta_field{f}#11, emp_no{f}#5, first_name{f}#6, !g..]
+     * }
+     * 
*/ public void testSimpleAvgReplacement() { var plan = plan(""" @@ -3231,11 +3461,15 @@ public void testSimpleAvgReplacement() { /** * Expects + *
+     * {@code
      * EsqlProject[[a{r}#3, c{r}#6, s{r}#9, last_name{f}#15]]
      * \_Eval[[s{r}#9 / c{r}#6 AS a]]
      *   \_Limit[10000[INTEGER]]
      *     \_Aggregate[[last_name{f}#15],[COUNT(salary{f}#16) AS c, SUM(salary{f}#16) AS s, last_name{f}#15]]
      *       \_EsRelation[test][_meta_field{f}#17, emp_no{f}#11, first_name{f}#12, ..]
+     * }
+     * 
*/ public void testClashingAggAvgReplacement() { var plan = plan(""" @@ -3257,12 +3491,16 @@ public void testClashingAggAvgReplacement() { /** * Expects + *
+     * {@code
      * EsqlProject[[a{r}#3, c{r}#6, s{r}#9, last_name{f}#15]]
      * \_Eval[[s{r}#9 / __a_COUNT@xxx{r}#18 AS a]]
      *   \_Limit[10000[INTEGER]]
      *     \_Aggregate[[last_name{f}#15],[COUNT(salary{f}#16) AS __a_COUNT@xxx, COUNT(languages{f}#14) AS c, SUM(salary{f}#16) AS
      *  s, last_name{f}#15]]
      *       \_EsRelation[test][_meta_field{f}#17, emp_no{f}#11, first_name{f}#12, ..]
+     * }
+     * 
*/ public void testSemiClashingAvgReplacement() { var plan = plan(""" @@ -3293,9 +3531,13 @@ public void testSemiClashingAvgReplacement() { /** * Expected + *
+     * {@code
      * Limit[10000[INTEGER]]
      * \_Aggregate[[last_name{f}#9],[PERCENTILE(salary{f}#10,50[INTEGER]) AS m, last_name{f}#9]]
      *   \_EsRelation[test][_meta_field{f}#11, emp_no{f}#5, first_name{f}#6, !g..]
+     * }
+     * 
*/ public void testMedianReplacement() { var plan = plan(""" @@ -3404,9 +3646,13 @@ public void testPruneChainedEvalNoProjection() { /** * Expects + *
+     * {@code
      * Limit[1000[INTEGER]]
      * \_Aggregate[[],[COUNT(salary{f}#1345) AS c]]
      *   \_EsRelation[test][_meta_field{f}#1346, emp_no{f}#1340, first_name{f}#..]
+     * }
+     * 
*/ public void testPruneEvalDueToStats() { var plan = plan(""" @@ -3443,9 +3689,13 @@ public void testPruneUnusedAggSimple() { /** * Expects + *
+     * {@code
      * Limit[1000[INTEGER]]
      * \_Aggregate[[],[COUNT(salary{f}#19) AS x]]
      *   \_EsRelation[test][_meta_field{f}#20, emp_no{f}#14, first_name{f}#15, ..]
+     * }
+     * 
*/ public void testPruneUnusedAggMixedWithEval() { var plan = plan(""" @@ -3487,11 +3737,15 @@ public void testPruneUnusedAggsChainedAgg() { /** * Expects + *
+     * {@code
      * Project[[c{r}#342]]
      * \_Limit[1000[INTEGER]]
      *   \_Filter[min{r}#348 > 10[INTEGER]]
      *     \_Aggregate[[],[COUNT(salary{f}#367) AS c, MIN(salary{f}#367) AS min]]
      *       \_EsRelation[test][_meta_field{f}#368, emp_no{f}#362, first_name{f}#36..]
+     * }
+     * 
*/ public void testPruneMixedAggInsideUnusedEval() { var plan = plan(""" @@ -3518,10 +3772,14 @@ public void testPruneMixedAggInsideUnusedEval() { /** * Expects + *
+     * {@code
      * Eval[[max{r}#6 + min{r}#9 + c{r}#3 AS x, min{r}#9 AS y, c{r}#3 AS z]]
      * \_Limit[1000[INTEGER]]
      *   \_Aggregate[[],[COUNT(salary{f}#26) AS c, MAX(salary{f}#26) AS max, MIN(salary{f}#26) AS min]]
      *     \_EsRelation[test][_meta_field{f}#27, emp_no{f}#21, first_name{f}#22, ..]
+     * }
+     * 
*/ public void testNoPruningWhenDealingJustWithEvals() { var plan = plan(""" @@ -3539,10 +3797,14 @@ public void testNoPruningWhenDealingJustWithEvals() { /** * Expects + *
+     * {@code
      * Project[[y{r}#6 AS z]]
      * \_Eval[[emp_no{f}#11 + 1[INTEGER] AS y]]
      *   \_Limit[1000[INTEGER]]
      *     \_EsRelation[test][_meta_field{f}#17, emp_no{f}#11, first_name{f}#12, ..]
+     * }
+     * 
*/ public void testNoPruningWhenChainedEvals() { var plan = plan(""" @@ -3561,9 +3823,13 @@ public void testNoPruningWhenChainedEvals() { /** * Expects + *
+     * {@code
      * Project[[salary{f}#20 AS x, emp_no{f}#15 AS y]]
      * \_Limit[1000[INTEGER]]
      *   \_EsRelation[test][_meta_field{f}#21, emp_no{f}#15, first_name{f}#16, ..]
+     * }
+     * 
*/ public void testPruningDuplicateEvals() { var plan = plan(""" @@ -3588,9 +3854,13 @@ public void testPruningDuplicateEvals() { /** * Expects + *
+     * {@code
      * Limit[1000[INTEGER]]
      * \_Aggregate[[],[COUNT(salary{f}#24) AS cx, COUNT(emp_no{f}#19) AS cy]]
      *   \_EsRelation[test][_meta_field{f}#25, emp_no{f}#19, first_name{f}#20, ..]
+     * }
+     * 
*/ public void testPruneEvalAliasOnAggUngrouped() { var plan = plan(""" @@ -3612,9 +3882,13 @@ public void testPruneEvalAliasOnAggUngrouped() { /** * Expects + *
+     * {@code
      * Limit[1000[INTEGER]]
      * \_Aggregate[[x{r}#6],[COUNT(emp_no{f}#17) AS cy, salary{f}#22 AS x]]
      *   \_EsRelation[test][_meta_field{f}#23, emp_no{f}#17, first_name{f}#18, ..]
+     * }
+     * 
*/ public void testPruneEvalAliasOnAggGroupedByAlias() { var plan = plan(""" @@ -3637,9 +3911,13 @@ public void testPruneEvalAliasOnAggGroupedByAlias() { /** * Expects + *
+     * {@code
      * Limit[1000[INTEGER]]
      * \_Aggregate[[gender{f}#22],[COUNT(emp_no{f}#20) AS cy, MIN(salary{f}#25) AS cx, gender{f}#22]]
      *   \_EsRelation[test][_meta_field{f}#26, emp_no{f}#20, first_name{f}#21, ..]
+     * }
+     * 
*/ public void testPruneEvalAliasOnAggGrouped() { var plan = plan(""" @@ -3663,9 +3941,13 @@ public void testPruneEvalAliasOnAggGrouped() { /** * Expects + *
+     * {@code
      * Limit[1000[INTEGER]]
      * \_Aggregate[[gender{f}#21],[COUNT(emp_no{f}#19) AS cy, MIN(salary{f}#24) AS cx, gender{f}#21]]
      *   \_EsRelation[test][_meta_field{f}#25, emp_no{f}#19, first_name{f}#20, ..]
+     * }
+     * 
*/ public void testPruneEvalAliasMixedWithRenameOnAggGrouped() { var plan = plan(""" @@ -3689,10 +3971,14 @@ public void testPruneEvalAliasMixedWithRenameOnAggGrouped() { /** * Expects + *
+     * {@code
      * Limit[1000[INTEGER]]
      * \_Aggregate[[gender{f}#19],[COUNT(x{r}#3) AS cy, MIN(x{r}#3) AS cx, gender{f}#19]]
      *   \_Eval[[emp_no{f}#17 + 1[INTEGER] AS x]]
      *     \_EsRelation[test][_meta_field{f}#23, emp_no{f}#17, first_name{f}#18, ..]
+     * }
+     * 
*/ public void testEvalAliasingAcrossCommands() { var plan = plan(""" @@ -3718,10 +4004,14 @@ public void testEvalAliasingAcrossCommands() { /** * Expects + *
+     * {@code
      * Limit[1000[INTEGER]]
      * \_Aggregate[[gender{f}#19],[COUNT(x{r}#3) AS cy, MIN(x{r}#3) AS cx, gender{f}#19]]
      *   \_Eval[[emp_no{f}#17 + 1[INTEGER] AS x]]
      *     \_EsRelation[test][_meta_field{f}#23, emp_no{f}#17, first_name{f}#18, ..]
+     * }
+     * 
*/ public void testEvalAliasingInsideSameCommand() { var plan = plan(""" @@ -3745,10 +4035,14 @@ public void testEvalAliasingInsideSameCommand() { /** * Expects + *
+     * {@code
      * Limit[1000[INTEGER]]
      * \_Aggregate[[gender{f}#22],[COUNT(z{r}#9) AS cy, MIN(x{r}#3) AS cx, gender{f}#22]]
      *   \_Eval[[emp_no{f}#20 + 1[INTEGER] AS x, x{r}#3 + 1[INTEGER] AS z]]
      *     \_EsRelation[test][_meta_field{f}#26, emp_no{f}#20, first_name{f}#21, ..]
+     * }
+     * 
*/ public void testEvalAliasingInsideSameCommandWithShadowing() { var plan = plan(""" @@ -3790,9 +4084,13 @@ public void testPruneRenameOnAgg() { /** * Expects + *
+     * {@code
      * Limit[1000[INTEGER]]
      * \_Aggregate[[gender{f}#14],[COUNT(salary{f}#17) AS cy, MIN(emp_no{f}#12) AS cx, gender{f}#14]]
      *   \_EsRelation[test][_meta_field{f}#18, emp_no{f}#12, first_name{f}#13, ..]
+     * }
+     * 
*/ public void testPruneRenameOnAggBy() { var plan = plan(""" @@ -3816,11 +4114,15 @@ public void testPruneRenameOnAggBy() { /** * Expects + *
+     * {@code
      * Project[[c1{r}#2, c2{r}#4, cs{r}#6, cm{r}#8, cexp{r}#10]]
      * \_Eval[[c1{r}#2 AS c2, c1{r}#2 AS cs, c1{r}#2 AS cm, c1{r}#2 AS cexp]]
      *   \_Limit[1000[INTEGER]]
      *     \_Aggregate[[],[COUNT([2a][KEYWORD]) AS c1]]
      *       \_EsRelation[test][_meta_field{f}#17, emp_no{f}#11, first_name{f}#12, ..]
+     * }
+     * 
*/ @AwaitsFix(bugUrl = "https://github.com/elastic/elasticsearch/issues/100634") public void testEliminateDuplicateAggsCountAll() { @@ -3847,11 +4149,15 @@ public void testEliminateDuplicateAggsCountAll() { /** * Expects + *
+     * {@code
      * Project[[c1{r}#7, cx{r}#10, cs{r}#12, cy{r}#15]]
      * \_Eval[[c1{r}#7 AS cx, c1{r}#7 AS cs, c1{r}#7 AS cy]]
      *   \_Limit[1000[INTEGER]]
      *     \_Aggregate[[],[COUNT([2a][KEYWORD]) AS c1]]
      *       \_EsRelation[test][_meta_field{f}#22, emp_no{f}#16, first_name{f}#17, ..]
+     * }
+     * 
*/ @AwaitsFix(bugUrl = "https://github.com/elastic/elasticsearch/issues/100634") public void testEliminateDuplicateAggsWithAliasedFields() { @@ -3880,10 +4186,14 @@ public void testEliminateDuplicateAggsWithAliasedFields() { /** * Expects + *
+     * {@code
      * Project[[min{r}#1385, max{r}#1388, min{r}#1385 AS min2, max{r}#1388 AS max2, gender{f}#1398]]
      * \_Limit[1000[INTEGER]]
      *   \_Aggregate[[gender{f}#1398],[MIN(salary{f}#1401) AS min, MAX(salary{f}#1401) AS max, gender{f}#1398]]
      *     \_EsRelation[test][_meta_field{f}#1402, emp_no{f}#1396, first_name{f}#..]
+     * }
+     * 
*/ public void testEliminateDuplicateAggsMixed() { var plan = plan(""" @@ -3910,9 +4220,13 @@ public void testEliminateDuplicateAggsMixed() { /** * Expects + *
+     * {@code
      * EsqlProject[[a{r}#5, c{r}#8]]
      * \_Eval[[null[INTEGER] AS x]]
      *   \_EsRelation[test][_meta_field{f}#15, emp_no{f}#9, first_name{f}#10, g..]
+     * }
+     * 
*/ @AwaitsFix(bugUrl = "https://github.com/elastic/elasticsearch/issues/100634") public void testEliminateDuplicateAggWithNull() { @@ -3926,10 +4240,14 @@ public void testEliminateDuplicateAggWithNull() { /** * Expects + *
+     * {@code
      * Project[[max(x){r}#11, max(x){r}#11 AS max(y), max(x){r}#11 AS max(z)]]
      * \_Limit[1000[INTEGER]]
      *   \_Aggregate[[],[MAX(salary{f}#21) AS max(x)]]
      *     \_EsRelation[test][_meta_field{f}#22, emp_no{f}#16, first_name{f}#17, ..]
+     * }
+     * 
*/ public void testEliminateDuplicateAggsNonCount() { var plan = plan(""" @@ -3957,9 +4275,13 @@ public void testEliminateDuplicateAggsNonCount() { /** * Expects + *
+     * {@code
      * Limit[1000[INTEGER]]
      * \_Aggregate[[salary{f}#12],[salary{f}#12, salary{f}#12 AS x]]
      *   \_EsRelation[test][_meta_field{f}#13, emp_no{f}#7, first_name{f}#8, ge..]
+     * }
+     * 
*/ public void testEliminateDuplicateRenamedGroupings() { var plan = plan(""" @@ -3978,10 +4300,14 @@ public void testEliminateDuplicateRenamedGroupings() { /** * Expected + *
+     * {@code
      * Limit[2[INTEGER]]
      * \_Filter[a{r}#6 > 2[INTEGER]]
      *   \_MvExpand[a{r}#2,a{r}#6]
      *     \_Row[[[1, 2, 3][INTEGER] AS a]]
+     * }
+     * 
*/ public void testMvExpandFoldable() { LogicalPlan plan = optimizedPlan(""" @@ -4002,9 +4328,13 @@ public void testMvExpandFoldable() { /** * Expected + *
+     * {@code
      * Limit[1000[INTEGER]]
      * \_Aggregate[[a{r}#2],[COUNT([2a][KEYWORD]) AS bar]]
      *   \_Row[[1[INTEGER] AS a]]
+     * }
+     * 
*/ public void testRenameStatsDropGroup() { LogicalPlan plan = optimizedPlan(""" @@ -4021,9 +4351,13 @@ public void testRenameStatsDropGroup() { /** * Expected + *
+     * {@code
      * Limit[1000[INTEGER]]
      * \_Aggregate[[a{r}#3, b{r}#5],[COUNT([2a][KEYWORD]) AS baz, b{r}#5 AS bar]]
      *   \_Row[[1[INTEGER] AS a, 2[INTEGER] AS b]]
+     * }
+     * 
*/ public void testMultipleRenameStatsDropGroup() { LogicalPlan plan = optimizedPlan(""" @@ -4040,9 +4374,13 @@ public void testMultipleRenameStatsDropGroup() { /** * Expected + *
+     * {@code
      * Limit[1000[INTEGER]]
      * \_Aggregate[[emp_no{f}#14, gender{f}#16],[MAX(salary{f}#19) AS baz, gender{f}#16 AS bar]]
      *   \_EsRelation[test][_meta_field{f}#20, emp_no{f}#14, first_name{f}#15, ..]
+     * }
+     * 
*/ public void testMultipleRenameStatsDropGroupMultirow() { LogicalPlan plan = optimizedPlan(""" @@ -4082,9 +4420,13 @@ private void aggFieldName(Expression exp, Class /** * Expects + *
+     * {@code
      * Limit[1000[INTEGER]]
      * \_Aggregate[[],[SUM(emp_no{f}#4) AS sum(emp_no)]]
      *   \_EsRelation[test][_meta_field{f}#10, emp_no{f}#4, first_name{f}#5, ge..]
+     * }
+     * 
*/ public void testIsNotNullConstraintForStatsWithoutGrouping() { var plan = optimizedPlan(""" @@ -4114,9 +4456,13 @@ public void testIsNotNullConstraintForStatsWithGrouping() { /** * Expected + *
+     * {@code
      * Limit[1000[INTEGER]]
      * \_Aggregate[[salary{f}#1185],[SUM(salary{f}#1185) AS sum(salary), salary{f}#1185]]
      *   \_EsRelation[test][_meta_field{f}#1186, emp_no{f}#1180, first_name{f}#..]
+     * }
+     * 
*/ public void testIsNotNullConstraintForStatsWithAndOnGrouping() { var plan = optimizedPlan(""" @@ -4133,9 +4479,13 @@ public void testIsNotNullConstraintForStatsWithAndOnGrouping() { /** * Expects + *
+     * {@code
      * Limit[1000[INTEGER]]
      * \_Aggregate[[salary{f}#13],[SUM(salary{f}#13) AS sum(salary), salary{f}#13 AS x]]
      *   \_EsRelation[test][_meta_field{f}#14, emp_no{f}#8, first_name{f}#9, ge..]
+     * }
+     * 
*/ public void testIsNotNullConstraintForStatsWithAndOnGroupingAlias() { var plan = optimizedPlan(""" @@ -4153,9 +4503,13 @@ public void testIsNotNullConstraintForStatsWithAndOnGroupingAlias() { /** * Expects + *
+     * {@code
      * Limit[1000[INTEGER]]
      * \_Aggregate[[salary{f}#13],[SUM(emp_no{f}#8) AS sum(x), salary{f}#13]]
      *   \_EsRelation[test][_meta_field{f}#14, emp_no{f}#8, first_name{f}#9, ge..]
+     * }
+     * 
*/ public void testIsNotNullConstraintSkippedForStatsWithAlias() { var plan = optimizedPlan(""" @@ -4175,9 +4529,13 @@ public void testIsNotNullConstraintSkippedForStatsWithAlias() { /** * Expects + *
+     * {@code
      * Limit[1000[INTEGER]]
      * \_Aggregate[[],[SUM(emp_no{f}#8) AS a, MIN(salary{f}#13) AS b]]
      *   \_EsRelation[test][_meta_field{f}#14, emp_no{f}#8, first_name{f}#9, ge..]
+     * }
+     * 
*/ public void testIsNotNullConstraintForStatsWithMultiAggWithoutGrouping() { var plan = optimizedPlan(""" @@ -4194,9 +4552,13 @@ public void testIsNotNullConstraintForStatsWithMultiAggWithoutGrouping() { /** * Expects + *
+     * {@code
      * Limit[1000[INTEGER]]
      * \_Aggregate[[gender{f}#11],[SUM(emp_no{f}#9) AS a, MIN(salary{f}#14) AS b, gender{f}#11]]
      *   \_EsRelation[test][_meta_field{f}#15, emp_no{f}#9, first_name{f}#10, g..]
+     * }
+     * 
*/ public void testIsNotNullConstraintForStatsWithMultiAggWithGrouping() { var plan = optimizedPlan(""" @@ -4213,9 +4575,13 @@ public void testIsNotNullConstraintForStatsWithMultiAggWithGrouping() { /** * Expects + *
+     * {@code
      * Limit[1000[INTEGER]]
      * \_Aggregate[[emp_no{f}#9],[SUM(emp_no{f}#9) AS a, MIN(salary{f}#14) AS b, emp_no{f}#9]]
      *   \_EsRelation[test][_meta_field{f}#15, emp_no{f}#9, first_name{f}#10, g..]
+     * }
+     * 
*/ public void testIsNotNullConstraintForStatsWithMultiAggWithAndOnGrouping() { var plan = optimizedPlan(""" @@ -4232,11 +4598,15 @@ public void testIsNotNullConstraintForStatsWithMultiAggWithAndOnGrouping() { /** * Expects + *
+     * {@code
      * Limit[1000[INTEGER]]
      * \_Aggregate[[w{r}#14, g{r}#16],[COUNT(b{r}#24) AS c, w{r}#14, gender{f}#32 AS g]]
      *   \_Eval[[emp_no{f}#30 / 10[INTEGER] AS x, x{r}#4 + salary{f}#35 AS y, y{r}#8 / 4[INTEGER] AS z, z{r}#11 * 2[INTEGER] +
      *  3[INTEGER] AS w, salary{f}#35 + 4[INTEGER] / 2[INTEGER] AS a, a{r}#21 + 3[INTEGER] AS b]]
      *     \_EsRelation[test][_meta_field{f}#36, emp_no{f}#30, first_name{f}#31, ..]
+     * }
+     * 
*/ public void testIsNotNullConstraintForAliasedExpressions() { var plan = optimizedPlan(""" @@ -4260,9 +4630,13 @@ public void testIsNotNullConstraintForAliasedExpressions() { /** * Expects + *
+     * {@code
      * Limit[1000[INTEGER]]
      * \_Aggregate[[],[SPATIALCENTROID(location{f}#9) AS centroid]]
      *   \_EsRelation[airports][abbrev{f}#5, location{f}#9, name{f}#6, scalerank{f}..]
+     * }
+     * 
*/ public void testSpatialTypesAndStatsUseDocValues() { var plan = planAirports(""" @@ -4285,9 +4659,13 @@ public void testSpatialTypesAndStatsUseDocValues() { /** * Expects + *
+     * {@code
      * Limit[1000[INTEGER]]
      * \_Aggregate[[],[SPATIALCENTROID(location{f}#9) AS centroid]]
      *   \_EsRelation[airports][abbrev{f}#5, location{f}#9, name{f}#6, scalerank{f}..]
+     * }
+     * 
*/ public void testSpatialTypesAndStatsUseDocValuesWithEval() { var plan = planAirports(""" @@ -4310,9 +4688,13 @@ public void testSpatialTypesAndStatsUseDocValuesWithEval() { /** * Expects: + *
+     * {@code
      * Eval[[types.type{f}#5 AS new_types.type]]
      * \_Limit[1000[INTEGER]]
      *   \_EsRelation[test][_meta_field{f}#11, emp_no{f}#5, first_name{f}#6, ge..]
+     * }
+     * 
* NOTE: The convert function to_type is removed, since the types match * This does not work for to_string(text) since that converts text to keyword */ @@ -4338,10 +4720,14 @@ public void testTrivialTypeConversionWrittenAway() { /** * Expects + *
+     * {@code
      * Limit[1000[INTEGER]]
      * \_Aggregate[[emp_no%2{r}#6],[COUNT(salary{f}#12) AS c, emp_no%2{r}#6]]
      *   \_Eval[[emp_no{f}#7 % 2[INTEGER] AS emp_no%2]]
      *     \_EsRelation[test][_meta_field{f}#13, emp_no{f}#7, first_name{f}#8, ge..]
+     * }
+     * 
*/ public void testNestedExpressionsInGroups() { var plan = optimizedPlan(""" @@ -4363,11 +4749,15 @@ public void testNestedExpressionsInGroups() { /** * Expects + *
+     * {@code
      * Limit[1000[INTEGER],false]
      * \_Aggregate[[CATEGORIZE($$CONCAT(first_na>$CATEGORIZE(CONC>$0{r$}#1590) AS CATEGORIZE(CONCAT(first_name, "abc"))],[COUNT(sa
      * lary{f}#1584,true[BOOLEAN]) AS c, CATEGORIZE(CONCAT(first_name, "abc")){r}#1574]]
      *   \_Eval[[CONCAT(first_name{f}#1580,[61 62 63][KEYWORD]) AS $$CONCAT(first_na>$CATEGORIZE(CONC>$0]]
      *     \_EsRelation[test][_meta_field{f}#1585, emp_no{f}#1579, first_name{f}#..]
+     * }
+     * 
*/ public void testNestedExpressionsInGroupsWithCategorize() { var plan = optimizedPlan(""" @@ -4396,10 +4786,14 @@ public void testNestedExpressionsInGroupsWithCategorize() { /** * Expects + *
+     * {@code
      * Limit[1000[INTEGER]]
      * \_Aggregate[[emp_no{f}#6],[COUNT(__c_COUNT@1bd45f36{r}#16) AS c, emp_no{f}#6]]
      *   \_Eval[[salary{f}#11 + 1[INTEGER] AS __c_COUNT@1bd45f36]]
      *     \_EsRelation[test][_meta_field{f}#12, emp_no{f}#6, first_name{f}#7, ge..]
+     * }
+     * 
*/ public void testNestedExpressionsInAggs() { var plan = optimizedPlan(""" @@ -4421,11 +4815,15 @@ public void testNestedExpressionsInAggs() { } /** + *
+     * {@code
      * Limit[1000[INTEGER]]
      * \_Aggregate[[emp_no%2{r}#7],[COUNT(__c_COUNT@fb7855b0{r}#18) AS c, emp_no%2{r}#7]]
      *   \_Eval[[emp_no{f}#8 % 2[INTEGER] AS emp_no%2, 100[INTEGER] / languages{f}#11 + salary{f}#13 + 1[INTEGER] AS __c_COUNT
      * @fb7855b0]]
      *     \_EsRelation[test][_meta_field{f}#14, emp_no{f}#8, first_name{f}#9, ge..]
+     * }
+     * 
*/ public void testNestedExpressionsInBothAggsAndGroups() { var plan = optimizedPlan(""" @@ -4467,10 +4865,14 @@ public void testNestedMultiExpressionsInGroupingAndAggs() { /** * Expects + *
+     * {@code
      * Limit[1000[INTEGER]]
      * \_Aggregate[[g{r}#8],[COUNT($$emp_no_%_2_+_la>$COUNT$0{r}#20) AS c, g{r}#8]]
      *   \_Eval[[emp_no{f}#10 % 2[INTEGER] AS g, languages{f}#13 + emp_no{f}#10 % 2[INTEGER] AS $$emp_no_%_2_+_la>$COUNT$0]]
      *     \_EsRelation[test][_meta_field{f}#16, emp_no{f}#10, first_name{f}#11, ..]
+     * }
+     * 
*/ public void testNestedExpressionsWithGroupingKeyInAggs() { var plan = optimizedPlan(""" @@ -4502,12 +4904,16 @@ public void testNestedExpressionsWithGroupingKeyInAggs() { /** * Expects + *
+     * {@code
      * Limit[1000[INTEGER]]
      * \_Aggregate[[emp_no % 2{r}#12, languages + salary{r}#15],[MAX(languages + salary{r}#15) AS m, COUNT($$languages_+_sal>$COUN
      * T$0{r}#28) AS c, emp_no % 2{r}#12, languages + salary{r}#15]]
      *   \_Eval[[emp_no{f}#18 % 2[INTEGER] AS emp_no % 2, languages{f}#21 + salary{f}#23 AS languages + salary, languages{f}#2
      * 1 + salary{f}#23 + emp_no{f}#18 % 2[INTEGER] AS $$languages_+_sal>$COUNT$0]]
      *     \_EsRelation[test][_meta_field{f}#24, emp_no{f}#18, first_name{f}#19, ..]
+     * }
+     * 
*/ @AwaitsFix(bugUrl = "disabled since canonical representation relies on hashing which is runtime defined") public void testNestedExpressionsWithMultiGrouping() { @@ -4548,6 +4954,8 @@ public void testNestedExpressionsWithMultiGrouping() { /** * Expects + *
+     * {@code
      * Project[[e{r}#5, languages + emp_no{r}#8]]
      * \_Eval[[$$MAX$max(languages_+>$0{r}#20 + 1[INTEGER] AS e]]
      *   \_Limit[1000[INTEGER]]
@@ -4555,6 +4963,8 @@ public void testNestedExpressionsWithMultiGrouping() {
      * r}#8]]
      *       \_Eval[[languages{f}#13 + emp_no{f}#10 AS languages + emp_no]]
      *         \_EsRelation[test][_meta_field{f}#16, emp_no{f}#10, first_name{f}#11, ..]
+     * }
+     * 
*/ public void testNestedExpressionsInStatsWithExpression() { var plan = optimizedPlan(""" @@ -4599,13 +5009,17 @@ public void testBucketFailsOnFieldArgument() { ); } - /* + /** + *
+     * {@code
      * Project[[bucket(salary, 1000.) + 1{r}#3, bucket(salary, 1000.){r}#5]]
-        \_Eval[[bucket(salary, 1000.){r}#5 + 1[INTEGER] AS bucket(salary, 1000.) + 1]]
-          \_Limit[1000[INTEGER]]
-            \_Aggregate[[bucket(salary, 1000.){r}#5],[bucket(salary, 1000.){r}#5]]
-              \_Eval[[BUCKET(salary{f}#12,1000.0[DOUBLE]) AS bucket(salary, 1000.)]]
-                \_EsRelation[test][_meta_field{f}#13, emp_no{f}#7, first_name{f}#8, ge..]
+     *  \_Eval[[bucket(salary, 1000.){r}#5 + 1[INTEGER] AS bucket(salary, 1000.) + 1]]
+     *    \_Limit[1000[INTEGER]]
+     *      \_Aggregate[[bucket(salary, 1000.){r}#5],[bucket(salary, 1000.){r}#5]]
+     *        \_Eval[[BUCKET(salary{f}#12,1000.0[DOUBLE]) AS bucket(salary, 1000.)]]
+     *          \_EsRelation[test][_meta_field{f}#13, emp_no{f}#7, first_name{f}#8, ge..]
+     * }
+     * 
*/ public void testBucketWithAggExpression() { var plan = plan(""" @@ -4682,6 +5096,8 @@ private String typesError(String query) { /** * Expects + *
+     * {@code
      * Project[[x{r}#5]]
      * \_Eval[[____x_AVG@9efc3cf3_SUM@daf9f221{r}#18 / ____x_AVG@9efc3cf3_COUNT@53cd08ed{r}#19 AS __x_AVG@9efc3cf3, __x_AVG@
      * 9efc3cf3{r}#16 / 2[INTEGER] + __x_MAX@475d0e4d{r}#17 AS x]]
@@ -4689,6 +5105,8 @@ private String typesError(String query) {
      *     \_Aggregate[[],[SUM(salary{f}#11) AS ____x_AVG@9efc3cf3_SUM@daf9f221, COUNT(salary{f}#11) AS ____x_AVG@9efc3cf3_COUNT@53cd0
      * 8ed, MAX(salary{f}#11) AS __x_MAX@475d0e4d]]
      *       \_EsRelation[test][_meta_field{f}#12, emp_no{f}#6, first_name{f}#7, ge..]
+     * }
+     * 
*/ public void testStatsExpOverAggs() { var plan = optimizedPlan(""" @@ -4719,6 +5137,8 @@ public void testStatsExpOverAggs() { /** * Expects + *
+     * {@code
      * Project[[x{r}#5, y{r}#9, z{r}#12]]
      * \_Eval[[$$SUM$$$AVG$avg(salary_%_3)>$0$0{r}#29 / $$COUNT$$$AVG$avg(salary_%_3)>$0$1{r}#30 AS $$AVG$avg(salary_%_3)>$0,
      *   $$AVG$avg(salary_%_3)>$0{r}#23 + $$MAX$avg(salary_%_3)>$1{r}#24 AS x,
@@ -4733,6 +5153,8 @@ public void testStatsExpOverAggs() {
      *       salary{f}#18 % 3[INTEGER] AS $$salary_%_3$AVG$0,
      *       emp_no{f}#13 / 3[INTEGER] AS $$emp_no_/_3$MIN$1]]
      *         \_EsRelation[test][_meta_field{f}#19, emp_no{f}#13, first_name{f}#14, ..]
+     * }
+     * 
*/ public void testStatsExpOverAggsMulti() { var plan = optimizedPlan(""" @@ -4775,6 +5197,8 @@ public void testStatsExpOverAggsMulti() { /** * Expects + *
+     * {@code
      * Project[[x{r}#5, y{r}#9, z{r}#12]]
      * \_Eval[[$$SUM$$$AVG$CONCAT(TO_STRIN>$0$0{r}#29 / $$COUNT$$$AVG$CONCAT(TO_STRIN>$0$1{r}#30 AS $$AVG$CONCAT(TO_STRIN>$0,
      *        CONCAT(TOSTRING($$AVG$CONCAT(TO_STRIN>$0{r}#23),TOSTRING($$MAX$CONCAT(TO_STRIN>$1{r}#24)) AS x,
@@ -4790,6 +5214,8 @@ public void testStatsExpOverAggsMulti() {
      *       salary{f}#18 % 3[INTEGER] AS $$salary_%_3$AVG$0,
      *       emp_no{f}#13 / 3[INTEGER] AS $$emp_no_/_3$MIN$1]]
      *         \_EsRelation[test][_meta_field{f}#19, emp_no{f}#13, first_name{f}#14, ..]
+     * }
+     * 
*/ public void testStatsExpOverAggsWithScalars() { var plan = optimizedPlan(""" @@ -4837,6 +5263,8 @@ public void testStatsExpOverAggsWithScalars() { /** * Expects + *
+     * {@code
      * Project[[a{r}#5, b{r}#9, $$max(salary)_+_3>$COUNT$2{r}#46 AS d, $$count(salary)_->$MIN$3{r}#47 AS e, $$avg(salary)_+_m
      * >$MAX$1{r}#45 AS g]]
      * \_Eval[[$$$$avg(salary)_+_m>$AVG$0$SUM$0{r}#48 / $$max(salary)_+_3>$COUNT$2{r}#46 AS $$avg(salary)_+_m>$AVG$0, $$avg(
@@ -4847,6 +5275,8 @@ public void testStatsExpOverAggsWithScalars() {
      * , COUNT(salary{f}#39) AS $$max(salary)_+_3>$COUNT$2, MIN(salary{f}#39) AS $$count(salary)_->$MIN$3]]
      *       \_Eval[[languages{f}#37 % 2[INTEGER] AS w]]
      *         \_EsRelation[test][_meta_field{f}#40, emp_no{f}#34, first_name{f}#35, ..]
+     * }
+     * 
*/ public void testStatsExpOverAggsWithScalarAndDuplicateAggs() { var plan = optimizedPlan(""" @@ -4908,11 +5338,15 @@ public void testStatsExpOverAggsWithScalarAndDuplicateAggs() { /** * Expects + *
+     * {@code
      * Project[[a{r}#5, a{r}#5 AS b, w{r}#12]]
      * \_Limit[1000[INTEGER]]
      *   \_Aggregate[[w{r}#12],[SUM($$salary_/_2_+_la>$SUM$0{r}#26) AS a, w{r}#12]]
      *     \_Eval[[emp_no{f}#16 % 2[INTEGER] AS w, salary{f}#21 / 2[INTEGER] + languages{f}#19 AS $$salary_/_2_+_la>$SUM$0]]
      *       \_EsRelation[test][_meta_field{f}#22, emp_no{f}#16, first_name{f}#17, ..]
+     * }
+     * 
*/ public void testStatsWithCanonicalAggregate() throws Exception { var plan = optimizedPlan(""" @@ -4944,6 +5378,8 @@ public void testStatsWithCanonicalAggregate() throws Exception { /** * Expects after running the {@link LogicalPlanOptimizer#substitutions()}: * + *
+     * {@code
      * Limit[1000[INTEGER]]
      * \_EsqlProject[[s{r}#3, s_expr{r}#5, s_null{r}#7, w{r}#10]]
      *   \_Project[[s{r}#3, s_expr{r}#5, s_null{r}#7, w{r}#10]]
@@ -4952,6 +5388,8 @@ public void testStatsWithCanonicalAggregate() throws Exception {
      *       \_Aggregate[[w{r}#10],[COUNT(*[KEYWORD]) AS $$COUNT$s$0, w{r}#10]]
      *         \_Eval[[emp_no{f}#16 % 2[INTEGER] AS w]]
      *           \_EsRelation[test][_meta_field{f}#22, emp_no{f}#16, first_name{f}#17, ..]
+     * }
+     * 
*/ public void testCountOfLiteral() { var plan = plan(""" @@ -5014,6 +5452,8 @@ public void testCountOfLiteral() { /** * Expects after running the {@link LogicalPlanOptimizer#substitutions()}: * + *
+     * {@code
      * Limit[1000[INTEGER]]
      * \_EsqlProject[[s{r}#3, s_expr{r}#5, s_null{r}#7, w{r}#10]]
      *   \_Project[[s{r}#3, s_expr{r}#5, s_null{r}#7, w{r}#10]]
@@ -5022,6 +5462,8 @@ public void testCountOfLiteral() {
      *       \_Aggregate[[w{r}#10],[COUNT(*[KEYWORD]) AS $$COUNT$s$0, w{r}#10]]
      *         \_Eval[[emp_no{f}#15 % 2[INTEGER] AS w]]
      *           \_EsRelation[test][_meta_field{f}#21, emp_no{f}#15, first_name{f}#16, ..]
+     * }
+     * 
*/ public void testSumOfLiteral() { var plan = plan(""" @@ -5109,14 +5551,18 @@ private record AggOfLiteralTestCase( /** * Aggs of literals in case that the agg can be simply replaced by a corresponding mv-function; * e.g. avg([1,2,3]) which is equivalent to mv_avg([1,2,3]). - * + *

* Expects after running the {@link LogicalPlanOptimizer#substitutions()}: * + *

+     * {@code
      * Limit[1000[INTEGER]]
      * \_EsqlProject[[s{r}#3, s_expr{r}#5, s_null{r}#7]]
      *   \_Project[[s{r}#3, s_expr{r}#5, s_null{r}#7]]
      *     \_Eval[[MVAVG([1, 2][INTEGER]) AS s, MVAVG(314.0[DOUBLE] / 100[INTEGER]) AS s_expr, MVAVG(null[NULL]) AS s_null]]
      *       \_LocalRelation[[{e}#21],[ConstantNullBlock[positions=1]]]
+     * }
+     * 
*/ public void testAggOfLiteral() { for (AggOfLiteralTestCase testCase : AGG_OF_CONST_CASES) { @@ -5153,15 +5599,19 @@ public void testAggOfLiteral() { /** * Like {@link LogicalPlanOptimizerTests#testAggOfLiteral()} but with a grouping key. - * + *

* Expects after running the {@link LogicalPlanOptimizer#substitutions()}: * + *

+     * {@code
      * Limit[1000[INTEGER]]
      * \_EsqlProject[[s{r}#3, s_expr{r}#5, s_null{r}#7, emp_no{f}#13]]
      *   \_Project[[s{r}#3, s_expr{r}#5, s_null{r}#7, emp_no{f}#13]]
      *     \_Eval[[MVAVG([1, 2][INTEGER]) AS s, MVAVG(314.0[DOUBLE] / 100[INTEGER]) AS s_expr, MVAVG(null[NULL]) AS s_null]]
      *       \_Aggregate[[emp_no{f}#13],[emp_no{f}#13]]
      *         \_EsRelation[test][_meta_field{f}#19, emp_no{f}#13, first_name{f}#14, ..]
+     * }
+     * 
*/ public void testAggOfLiteralGrouped() { for (AggOfLiteralTestCase testCase : AGG_OF_CONST_CASES) { @@ -5311,6 +5761,8 @@ public void testPlanSanityCheck() throws Exception { /** * Before we alter the plan to make it invalid, we expect * + *
+     * {@code
      * Project[[_meta_field{f}#12, emp_no{f}#6, first_name{f}#7, gender{f}#8, hire_date{f}#13, job{f}#14, job.raw{f}#15,
      *          languages{f}#9 AS language_code#4, last_name{f}#10, long_noidx{f}#16, salary{f}#11, language_name{f}#18]]
      * \_Limit[1000[INTEGER],true]
@@ -5318,7 +5770,8 @@ public void testPlanSanityCheck() throws Exception {
      *     |_Limit[1000[INTEGER],false]
      *     | \_EsRelation[test][_meta_field{f}#12, emp_no{f}#6, first_name{f}#7, ge..]
      *     \_EsRelation[languages_lookup][LOOKUP][language_code{f}#17, language_name{f}#18]
-     *
+     * }
+     * 
*/ public void testPlanSanityCheckWithBinaryPlans() { assumeTrue("Requires LOOKUP JOIN", EsqlCapabilities.Cap.JOIN_LOOKUP_V12.isEnabled()); @@ -5361,15 +5814,19 @@ public void testNoWrongIsNotNullPruning() { /** * Pushing down EVAL/GROK/DISSECT/ENRICH must not accidentally shadow attributes required by SORT. - * + *

* For DISSECT expects the following; the others are similar. * + *

+     * {@code
      * Project[[first_name{f}#37, emp_no{r}#30, salary{r}#31]]
      * \_TopN[[Order[$$order_by$temp_name$0{r}#46,ASC,LAST], Order[$$order_by$temp_name$1{r}#47,DESC,FIRST]],3[INTEGER]]
      *   \_Dissect[first_name{f}#37,Parser[pattern=%{emp_no} %{salary}, appendSeparator=,
      *   parser=org.elasticsearch.dissect.DissectParser@87f460f],[emp_no{r}#30, salary{r}#31]]
      *     \_Eval[[emp_no{f}#36 + salary{f}#41 * 13[INTEGER] AS $$order_by$temp_name$0, NEG(salary{f}#41) AS $$order_by$temp_name$1]]
      *       \_EsRelation[test][_meta_field{f}#42, emp_no{f}#36, first_name{f}#37, ..]
+     * }
+     * 
*/ public void testPushdownWithOverwrittenName() { List overwritingCommands = List.of( @@ -5542,15 +5999,23 @@ record PushdownShadowingGeneratingPlanTestCase( /** * Consider * + *
+     * {@code
      * Eval[[TO_INTEGER(x{r}#2) AS y, y{r}#4 + 1[INTEGER] AS y]]
      * \_Project[[y{r}#3, x{r}#2]]
      * \_Row[[1[INTEGER] AS x, 2[INTEGER] AS y]]
+     * }
+     * 
* * We can freely push down the Eval without renaming, but need to update the Project's references. * + *
+     * {@code
      * Project[[x{r}#2, y{r}#6 AS y]]
      * \_Eval[[TO_INTEGER(x{r}#2) AS y, y{r}#4 + 1[INTEGER] AS y]]
      * \_Row[[1[INTEGER] AS x, 2[INTEGER] AS y]]
+     * }
+     * 
* * And similarly for dissect, grok and enrich. */ @@ -5589,15 +6054,23 @@ public void testPushShadowingGeneratingPlanPastProject() { /** * Consider * + *
+     * {@code
      * Eval[[TO_INTEGER(x{r}#2) AS y, y{r}#4 + 1[INTEGER] AS y]]
      * \_Project[[x{r}#2, y{r}#3, y{r}#3 AS z]]
      * \_Row[[1[INTEGER] AS x, 2[INTEGER] AS y]]
+     * }
+     * 
* * To push down the Eval, we must not shadow the reference y{r}#3, so we rename. * + *
+     * {@code
      * Project[[x{r}#2, y{r}#3 AS z, $$y$temp_name$10{r}#12 AS y]]
      * Eval[[TO_INTEGER(x{r}#2) AS $$y$temp_name$10, $$y$temp_name$10{r}#11 + 1[INTEGER] AS $$y$temp_name$10]]
      * \_Row[[1[INTEGER] AS x, 2[INTEGER] AS y]]
+     * }
+     * 
* * And similarly for dissect, grok and enrich. */ @@ -5646,16 +6119,24 @@ public void testPushShadowingGeneratingPlanPastRenamingProject() { /** * Consider * + *
+     * {@code
      * Eval[[TO_INTEGER(x{r}#2) AS y, y{r}#3 + 1[INTEGER] AS y]]
      * \_Project[[y{r}#1, y{r}#1 AS x]]
      * \_Row[[2[INTEGER] AS y]]
+     * }
+     * 
* * To push down the Eval, we must not shadow the reference y{r}#1, so we rename. * Additionally, the rename "y AS x" needs to be propagated into the Eval. * + *
+     * {@code
      * Project[[y{r}#1 AS x, $$y$temp_name$10{r}#12 AS y]]
      * Eval[[TO_INTEGER(y{r}#1) AS $$y$temp_name$10, $$y$temp_name$10{r}#11 + 1[INTEGER] AS $$y$temp_name$10]]
      * \_Row[[2[INTEGER] AS y]]
+     * }
+     * 
* * And similarly for dissect, grok and enrich. */ @@ -5699,11 +6180,15 @@ public void testPushShadowingGeneratingPlanPastRenamingProjectWithResolution() { /** * Expects + *
+     * {@code
      * Project[[min{r}#4, languages{f}#11]]
      * \_TopN[[Order[$$order_by$temp_name$0{r}#18,ASC,LAST]],1000[INTEGER]]
      *   \_Eval[[min{r}#4 + languages{f}#11 AS $$order_by$temp_name$0]]
      *     \_Aggregate[[languages{f}#11],[MIN(salary{f}#13) AS min, languages{f}#11]]
      *       \_EsRelation[test][_meta_field{f}#14, emp_no{f}#8, first_name{f}#9, ge..]
+     * }
+     * 
*/ public void testReplaceSortByExpressionsWithStats() { var plan = optimizedPlan(""" @@ -5734,7 +6219,9 @@ public void testReplaceSortByExpressionsWithStats() { as(aggregate.child(), EsRelation.class); } - /* + /** + *
+     * {@code
      * Limit[1000[INTEGER],true]
      * \_InlineJoin[LEFT,[emp_no % 2{r}#6],[emp_no % 2{r}#6],[emp_no % 2{r}#6]]
      *   |_Eval[[emp_no{f}#7 % 2[INTEGER] AS emp_no % 2#6]]
@@ -5743,6 +6230,8 @@ public void testReplaceSortByExpressionsWithStats() {
      *   \_Aggregate[[emp_no % 2{r}#6],[COUNT(salary{f}#12,true[BOOLEAN]) AS c#4, emp_no % 2{r}#6]]
      *     \_StubRelation[[_meta_field{f}#13, emp_no{f}#7, first_name{f}#8, gender{f}#9, hire_date{f}#14, job{f}#15, job.raw{f}#16, lang
      *          uages{f}#10, last_name{f}#11, long_noidx{f}#17, salary{f}#12, emp_no % 2{r}#6]]
+     * }
+     * 
*/ public void testInlinestatsNestedExpressionsInGroups() { var query = """ @@ -5777,10 +6266,14 @@ private static boolean releaseBuildForInlinestats(String query) { return false; } - /* + /** + *
+     * {@code
      * Project[[emp_no{f}#12 AS x#8, emp_no{f}#12]]
      * \_TopN[[Order[emp_no{f}#12,ASC,LAST]],1[INTEGER]]
      *   \_EsRelation[test][_meta_field{f}#18, emp_no{f}#12, first_name{f}#13, ..]
+     * }
+     * 
*/ public void testInlinestatsGetsPrunedEntirely() { var query = """ @@ -5827,7 +6320,9 @@ public void testDoubleInlinestatsGetsPrunedEntirely() { var relation = as(topN.child(), EsRelation.class); } - /* + /** + *
+     * {@code
      * Project[[emp_no{f}#15 AS x#11, a{r}#7, emp_no{f}#15]]
      * \_Limit[1[INTEGER],true]
      *   \_InlineJoin[LEFT,[emp_no{f}#15],[emp_no{f}#15],[emp_no{r}#15]]
@@ -5836,6 +6331,8 @@ public void testDoubleInlinestatsGetsPrunedEntirely() {
      *     \_Aggregate[[emp_no{f}#15],[COUNTDISTINCT(languages{f}#18,true[BOOLEAN]) AS a#7, emp_no{f}#15]]
      *       \_StubRelation[[_meta_field{f}#21, emp_no{f}#15, first_name{f}#16, gender{f}#17, hire_date{f}#22, job{f}#23, job.raw{f}#24, l
      *          anguages{f}#18, last_name{f}#19, long_noidx{f}#25, salary{f}#20]]
+     * }
+     * 
*/ public void testInlinestatsGetsPrunedPartially() { var query = """ @@ -5896,12 +6393,16 @@ public void testTrippleInlinestatsGetsPrunedPartially() { var stub = as(agg.child(), StubRelation.class); } - /* + /** + *
+     * {@code
      * Project[[abbrev{f}#19, scalerank{f}#21 AS backup_scalerank#4, language_name{f}#28 AS scalerank#11]]
      * \_TopN[[Order[abbrev{f}#19,DESC,FIRST]],5[INTEGER]]
      *   \_Join[LEFT,[scalerank{f}#21],[scalerank{f}#21],[language_code{f}#27]]
      *     |_EsRelation[airports][abbrev{f}#19, city{f}#25, city_location{f}#26, coun..]
      *     \_EsRelation[languages_lookup][LOOKUP][language_code{f}#27, language_name{f}#28]
+     * }
+     * 
*/ public void testInlinestatsWithLookupJoin() { var query = """ @@ -5938,7 +6439,9 @@ public void testInlinestatsWithLookupJoin() { assertThat(right.concreteIndices(), is(Set.of("languages_lookup"))); } - /* + /** + *
+     * {@code
      * EsqlProject[[avg{r}#4, emp_no{f}#9, first_name{f}#10]]
      * \_Limit[10[INTEGER],true]
      *   \_InlineJoin[LEFT,[emp_no{f}#9],[emp_no{f}#9],[emp_no{r}#9]]
@@ -5950,6 +6453,8 @@ public void testInlinestatsWithLookupJoin() {
      *              avg$1#21, emp_no{f}#9]]
      *           \_StubRelation[[_meta_field{f}#15, emp_no{f}#9, first_name{f}#10, gender{f}#11, hire_date{f}#16, job{f}#17, job.raw{f}#18,
      *              languages{f}#12, last_name{f}#13, long_noidx{f}#19, salary{f}#14]]
+     * }
+     * 
*/ public void testInlinestatsWithAvg() { var query = """ @@ -5981,11 +6486,15 @@ public void testInlinestatsWithAvg() { var stub = as(agg.child(), StubRelation.class); } - /* + /** + *
+     * {@code
      * EsqlProject[[emp_no{r}#5]]
      * \_Limit[1000[INTEGER],false]
      *   \_LocalRelation[[salary{r}#3, emp_no{r}#5, gender{r}#7],
      *      org.elasticsearch.xpack.esql.plan.logical.local.CopyingLocalSupplier@9d5b596d]
+     * }
+     * 
*/ public void testInlinestatsWithRow() { var query = """ @@ -6016,10 +6525,14 @@ public void testInlinestatsWithRow() { /** * Expects * + *
+     * {@code
      * Project[[salary{f}#19, languages{f}#17, emp_no{f}#14]]
      * \_TopN[[Order[$$order_by$0$0{r}#24,ASC,LAST], Order[emp_no{f}#14,DESC,FIRST]],1000[INTEGER]]
      *   \_Eval[[salary{f}#19 / 10000[INTEGER] + languages{f}#17 AS $$order_by$0$0]]
      *     \_EsRelation[test][_meta_field{f}#20, emp_no{f}#14, first_name{f}#15, ..]
+     * }
+     * 
*/ public void testReplaceSortByExpressionsMultipleSorts() { var plan = optimizedPlan(""" @@ -6067,12 +6580,16 @@ public void testReplaceSortByExpressionsMultipleSorts() { /** * For DISSECT expects the following; the others are similar. * + *
+     * {@code
      * Project[[first_name{f}#37, emp_no{r}#30, salary{r}#31]]
      * \_TopN[[Order[$$order_by$temp_name$0{r}#46,ASC,LAST], Order[$$order_by$temp_name$1{r}#47,DESC,FIRST]],3[INTEGER]]
      *   \_Dissect[first_name{f}#37,Parser[pattern=%{emp_no} %{salary}, appendSeparator=,
      *   parser=org.elasticsearch.dissect.DissectParser@87f460f],[emp_no{r}#30, salary{r}#31]]
      *     \_Eval[[emp_no{f}#36 + salary{f}#41 * 13[INTEGER] AS $$order_by$temp_name$0, NEG(salary{f}#41) AS $$order_by$temp_name$1]]
      *       \_EsRelation[test][_meta_field{f}#42, emp_no{f}#36, first_name{f}#37, ..]
+     * }
+     * 
*/ public void testReplaceSortByExpressions() { List overwritingCommands = List.of( @@ -6443,6 +6960,7 @@ protected List filteredWarnings() { /** * Expects + *
      * {@code
      * Join[JoinConfig[type=LEFT OUTER, matchFields=[int{r}#4], conditions=[LOOKUP int_number_names ON int]]]
      * |_EsqlProject[[_meta_field{f}#12, emp_no{f}#6, first_name{f}#7, gender{f}#8, job{f}#13, job.raw{f}#14, languages{f}#9 AS int
@@ -6452,6 +6970,7 @@ protected List filteredWarnings() {
      * \_LocalRelation[[int{f}#16, name{f}#17],[IntVectorBlock[vector=IntArrayVector[positions=10, values=[0, 1, 2, 3, 4, 5, 6, 7, 8,
      * 9]]], BytesRefVectorBlock[vector=BytesRefArrayVector[positions=10]]]]
      * }
+     * 
*/ @AwaitsFix(bugUrl = "lookup functionality is not yet implemented") public void testLookupSimple() { @@ -6522,6 +7041,7 @@ public void testLookupSimple() { /** * Expects + *
      * {@code
      * Limit[1000[INTEGER]]
      * \_Aggregate[[name{r}#20],[MIN(emp_no{f}#9) AS MIN(emp_no), name{r}#20]]
@@ -6532,6 +7052,7 @@ public void testLookupSimple() {
      *     \_LocalRelation[[int{f}#19, name{f}#20],[IntVectorBlock[vector=IntArrayVector[positions=10, values=[0, 1, 2, 3, 4, 5, 6, 7, 8,
      * 9]]], BytesRefVectorBlock[vector=BytesRefArrayVector[positions=10]]]]
      * }
+     * 
*/ @AwaitsFix(bugUrl = "lookup functionality is not yet implemented") public void testLookupStats() { @@ -6613,9 +7134,11 @@ public void testLookupStats() { /** * Filter on join keys should be pushed down - * + *

* Expects * + *

+     * {@code
      * Project[[_meta_field{f}#13, emp_no{f}#7, first_name{f}#8, gender{f}#9, hire_date{f}#14, job{f}#15, job.raw{f}#16,
      *          languages{f}#10 AS language_code#4, last_name{f}#11, long_noidx{f}#17, salary{f}#12, language_name{f}#19]]
      * \_Limit[1000[INTEGER],true]
@@ -6624,6 +7147,8 @@ public void testLookupStats() {
      *     | \_Filter[languages{f}#10 > 1[INTEGER]]
      *     |   \_EsRelation[test][_meta_field{f}#13, emp_no{f}#7, first_name{f}#8, ge..]
      *     \_EsRelation[languages_lookup][LOOKUP][language_code{f}#18, language_name{f}#19]
+     * }
+     * 
*/ public void testLookupJoinPushDownFilterOnJoinKeyWithRename() { assumeTrue("Requires LOOKUP JOIN", EsqlCapabilities.Cap.JOIN_LOOKUP_V12.isEnabled()); @@ -6658,6 +7183,8 @@ public void testLookupJoinPushDownFilterOnJoinKeyWithRename() { * Filter on on left side fields (outside the join key) should be pushed down * Expects * + *
+     * {@code
      * Project[[_meta_field{f}#13, emp_no{f}#7, first_name{f}#8, gender{f}#9, hire_date{f}#14, job{f}#15, job.raw{f}#16,
      *          languages{f}#10 AS language_code#4, last_name{f}#11, long_noidx{f}#17, salary{f}#12, language_name{f}#19]]
      * \_Limit[1000[INTEGER],true]
@@ -6667,6 +7194,8 @@ public void testLookupJoinPushDownFilterOnJoinKeyWithRename() {
      *     |   \_EsRelation[test][_meta_field{f}#13, emp_no{f}#7, first_name{f}#8, ge..]
      *     \_EsRelation[languages_lookup][LOOKUP][language_code{f}#18, language_name{f}#19]
      *
+     * }
+     * 
*/ public void testLookupJoinPushDownFilterOnLeftSideField() { assumeTrue("Requires LOOKUP JOIN", EsqlCapabilities.Cap.JOIN_LOOKUP_V12.isEnabled()); @@ -6700,9 +7229,11 @@ public void testLookupJoinPushDownFilterOnLeftSideField() { /** * Filter works on the right side fields and thus cannot be pushed down - * + *

* Expects * + *

+     * {@code
      * Project[[_meta_field{f}#13, emp_no{f}#7, first_name{f}#8, gender{f}#9, hire_date{f}#14, job{f}#15, job.raw{f}#16,
      *          languages{f}#10 AS language_code#4, last_name{f}#11, long_noidx{f}#17, salary{f}#12, language_name{f}#19]]
      * \_Limit[1000[INTEGER],false]
@@ -6710,6 +7241,8 @@ public void testLookupJoinPushDownFilterOnLeftSideField() {
      *     \_Join[LEFT,[languages{f}#10],[languages{f}#10],[language_code{f}#18]]
      *       |_EsRelation[test][_meta_field{f}#13, emp_no{f}#7, first_name{f}#8, ge..]
      *       \_EsRelation[languages_lookup][LOOKUP][language_code{f}#18, language_name{f}#19]
+     * }
+     * 
*/ public void testLookupJoinPushDownDisabledForLookupField() { assumeTrue("Requires LOOKUP JOIN", EsqlCapabilities.Cap.JOIN_LOOKUP_V12.isEnabled()); @@ -6742,9 +7275,10 @@ public void testLookupJoinPushDownDisabledForLookupField() { /** * Split the conjunction into pushable and non pushable filters. - * + *

* Expects * + *

{@code
      * Project[[_meta_field{f}#14, emp_no{f}#8, first_name{f}#9, gender{f}#10, hire_date{f}#15, job{f}#16, job.raw{f}#17,
      *          languages{f}#11 AS language_code#4, last_name{f}#12, long_noidx{f}#18, salary{f}#13, language_name{f}#20]]
      * \_Limit[1000[INTEGER],false]
@@ -6753,6 +7287,7 @@ public void testLookupJoinPushDownDisabledForLookupField() {
      *       |_Filter[emp_no{f}#8 > 1[INTEGER]]
      *       | \_EsRelation[test][_meta_field{f}#14, emp_no{f}#8, first_name{f}#9, ge..]
      *       \_EsRelation[languages_lookup][LOOKUP][language_code{f}#19, language_name{f}#20]
+     * }
*/ public void testLookupJoinPushDownSeparatedForConjunctionBetweenLeftAndRightField() { assumeTrue("Requires LOOKUP JOIN", EsqlCapabilities.Cap.JOIN_LOOKUP_V12.isEnabled()); @@ -6793,9 +7328,10 @@ public void testLookupJoinPushDownSeparatedForConjunctionBetweenLeftAndRightFiel /** * Disjunctions however keep the filter in place, even on pushable fields - * + *

* Expects * + *

{@code
      * Project[[_meta_field{f}#14, emp_no{f}#8, first_name{f}#9, gender{f}#10, hire_date{f}#15, job{f}#16, job.raw{f}#17,
      *          languages{f}#11 AS language_code#4, last_name{f}#12, long_noidx{f}#18, salary{f}#13, language_name{f}#20]]
      * \_Limit[1000[INTEGER],false]
@@ -6803,6 +7339,7 @@ public void testLookupJoinPushDownSeparatedForConjunctionBetweenLeftAndRightFiel
      *     \_Join[LEFT,[languages{f}#11],[languages{f}#11],[language_code{f}#19]]
      *       |_EsRelation[test][_meta_field{f}#14, emp_no{f}#8, first_name{f}#9, ge..]
      *       \_EsRelation[languages_lookup][LOOKUP][language_code{f}#19, language_name{f}#20]
+     * }
*/ public void testLookupJoinPushDownDisabledForDisjunctionBetweenLeftAndRightField() { assumeTrue("Requires LOOKUP JOIN", EsqlCapabilities.Cap.JOIN_LOOKUP_V12.isEnabled()); @@ -6845,8 +7382,9 @@ public void testLookupJoinPushDownDisabledForDisjunctionBetweenLeftAndRightField /** * When dropping lookup fields, the lookup relation shouldn't include them. * At least until we can implement InsertFieldExtract there. - * + *

* Expects + *

{@code
      * EsqlProject[[languages{f}#21]]
      * \_Limit[1000[INTEGER],true]
      *   \_Join[LEFT,[language_code{r}#4],[language_code{r}#4],[language_code{f}#29]]
@@ -6855,6 +7393,7 @@ public void testLookupJoinPushDownDisabledForDisjunctionBetweenLeftAndRightField
      *     | \_Limit[1000[INTEGER],false]
      *     |   \_EsRelation[test][_meta_field{f}#24, emp_no{f}#18, first_name{f}#19, ..]
      *     \_EsRelation[languages_lookup][LOOKUP][language_code{f}#29]
+     * }
*/ public void testLookupJoinKeepNoLookupFields() { assumeTrue("Requires LOOKUP JOIN", EsqlCapabilities.Cap.JOIN_LOOKUP_V12.isEnabled()); @@ -6887,8 +7426,9 @@ public void testLookupJoinKeepNoLookupFields() { /** * Ensure a JOIN shadowed by another JOIN doesn't request the shadowed fields. - * + *

* Expected + *

{@code
      * Limit[1000[INTEGER],true]
      * \_Join[LEFT,[language_code{r}#4],[language_code{r}#4],[language_code{f}#20]]
      *   |_Limit[1000[INTEGER],true]
@@ -6898,6 +7438,7 @@ public void testLookupJoinKeepNoLookupFields() {
      *   |   |   \_EsRelation[test][_meta_field{f}#13, emp_no{f}#7, first_name{f}#8, ge..]
      *   |   \_EsRelation[languages_lookup][LOOKUP][language_code{f}#18]
      *   \_EsRelation[languages_lookup][LOOKUP][language_code{f}#20, language_name{f}#21]
+     * }
*/ public void testMultipleLookupShadowing() { assumeTrue("Requires LOOKUP JOIN", EsqlCapabilities.Cap.JOIN_LOOKUP_V12.isEnabled()); @@ -6932,10 +7473,6 @@ public void testMultipleLookupShadowing() { var limit3 = asLimit(eval.child(), 1000, false); } - // - // - // - public void testTranslateMetricsWithoutGrouping() { assumeTrue("requires snapshot builds", Build.current().isSnapshot()); var query = "TS k8s | STATS max(rate(network.total_bytes_in))"; @@ -7614,6 +8151,7 @@ public void testFunctionNamedParamsAsFunctionArgument1() { } /** + *
{@code
      * Project[[_meta_field{f}#17, emp_no{f}#11, first_name{f}#12, gender{f}#13, hire_date{f}#18, job{f}#19, job.raw{f}#20,
      *          languages{f}#14 AS language_code#5, last_name{f}#15, long_noidx{f}#21, salary{f}#16, foo{r}#7, language_name{f}#23]]
      * \_TopN[[Order[emp_no{f}#11,ASC,LAST]],1000[INTEGER]]
@@ -7622,6 +8160,7 @@ public void testFunctionNamedParamsAsFunctionArgument1() {
      *     | \_Filter[languages{f}#14 > 1[INTEGER]]
      *     |   \_EsRelation[test][_meta_field{f}#17, emp_no{f}#11, first_name{f}#12, ..]
      *     \_EsRelation[languages_lookup][LOOKUP][language_code{f}#22, language_name{f}#23]
+     * }
*/ public void testRedundantSortOnJoin() { assumeTrue("Requires LOOKUP JOIN", EsqlCapabilities.Cap.JOIN_LOOKUP_V12.isEnabled()); @@ -7647,11 +8186,13 @@ public void testRedundantSortOnJoin() { } /** + *
{@code
      * TopN[[Order[emp_no{f}#9,ASC,LAST]],1000[INTEGER]]
      * \_Filter[emp_no{f}#9 > 1[INTEGER]]
      *   \_MvExpand[languages{f}#12,languages{r}#20,null]
      *     \_Eval[[[62 61 72][KEYWORD] AS foo]]
      *       \_EsRelation[test][_meta_field{f}#15, emp_no{f}#9, first_name{f}#10, g..]
+     * }
*/ public void testRedundantSortOnMvExpand() { var plan = optimizedPlan(""" @@ -7671,6 +8212,7 @@ public void testRedundantSortOnMvExpand() { } /** + *
{@code
      * TopN[[Order[emp_no{f}#11,ASC,LAST]],1000[INTEGER]]
      * \_Join[LEFT,[language_code{r}#5],[language_code{r}#5],[language_code{f}#22]]
      *   |_Filter[emp_no{f}#11 > 1[INTEGER]]
@@ -7678,6 +8220,7 @@ public void testRedundantSortOnMvExpand() {
      *   |   \_Eval[[languages{f}#14 AS language_code]]
      *   |     \_EsRelation[test][_meta_field{f}#17, emp_no{f}#11, first_name{f}#12, ..]
      *   \_EsRelation[languages_lookup][LOOKUP][language_code{f}#22, language_name{f}#23]
+     * }
*/ public void testRedundantSortOnMvExpandAndJoin() { var plan = optimizedPlan(""" @@ -7699,6 +8242,7 @@ public void testRedundantSortOnMvExpandAndJoin() { } /** + *
{@code
      * TopN[[Order[emp_no{f}#12,ASC,LAST]],1000[INTEGER]]
      * \_Join[LEFT,[language_code{r}#5],[language_code{r}#5],[language_code{f}#23]]
      *   |_Filter[emp_no{f}#12 > 1[INTEGER]]
@@ -7706,6 +8250,7 @@ public void testRedundantSortOnMvExpandAndJoin() {
      *   |   \_Eval[[languages{f}#15 AS language_code]]
      *   |     \_EsRelation[test][_meta_field{f}#18, emp_no{f}#12, first_name{f}#13, ..]
      *   \_EsRelation[languages_lookup][LOOKUP][language_code{f}#23, language_name{f}#24]
+     * }
*/ public void testMultlipleRedundantSortOnMvExpandAndJoin() { var plan = optimizedPlan(""" @@ -7728,6 +8273,7 @@ public void testMultlipleRedundantSortOnMvExpandAndJoin() { } /** + *
{@code
      * TopN[[Order[emp_no{f}#16,ASC,LAST]],1000[INTEGER]]
      * \_Filter[emp_no{f}#16 > 1[INTEGER]]
      *   \_MvExpand[languages{f}#19,languages{r}#31]
@@ -7738,6 +8284,7 @@ public void testMultlipleRedundantSortOnMvExpandAndJoin() {
      * fields":["language_code","language_name"]}},{=languages_idx},[language_code{r}#29, language_name{r}#30]]
      *           \_Eval[[TOSTRING(languages{f}#19) AS foo]]
      *             \_EsRelation[test][_meta_field{f}#22, emp_no{f}#16, first_name{f}#17, ..]
+     * }
*/ public void testRedundantSortOnMvExpandEnrichGrokDissect() { var plan = optimizedPlan(""" @@ -7763,6 +8310,7 @@ public void testRedundantSortOnMvExpandEnrichGrokDissect() { } /** + *
{@code
      * TopN[[Order[emp_no{f}#20,ASC,LAST]],1000[INTEGER]]
      * \_Filter[emp_no{f}#20 > 1[INTEGER]]
      *   \_MvExpand[languages{f}#23,languages{r}#37]
@@ -7775,6 +8323,7 @@ public void testRedundantSortOnMvExpandEnrichGrokDissect() {
      *             |_Eval[[TOSTRING(languages{f}#23) AS foo, languages{f}#23 AS language_code]]
      *             | \_EsRelation[test][_meta_field{f}#26, emp_no{f}#20, first_name{f}#21, ..]
      *             \_EsRelation[languages_lookup][LOOKUP][language_code{f}#31]
+     * }
*/ public void testRedundantSortOnMvExpandJoinEnrichGrokDissect() { var plan = optimizedPlan(""" @@ -7804,6 +8353,7 @@ public void testRedundantSortOnMvExpandJoinEnrichGrokDissect() { /** * Expects * + *
{@code
      * TopN[[Order[emp_no{f}#23,ASC,LAST]],1000[INTEGER]]
      * \_Filter[emp_no{f}#23 > 1[INTEGER]]
      *   \_MvExpand[languages{f}#26,languages{r}#36]
@@ -7812,6 +8362,7 @@ public void testRedundantSortOnMvExpandJoinEnrichGrokDissect() {
      *         |_Eval[[TOSTRING(languages{f}#26) AS foo#5]]
      *         | \_EsRelation[test][_meta_field{f}#29, emp_no{f}#23, first_name{f}#24, ..]
      *         \_EsRelation[languages_lookup][LOOKUP][language_code{f}#34, language_name{f}#35]
+     * }
*/ public void testRedundantSortOnMvExpandJoinKeepDropRename() { var plan = optimizedPlan(""" @@ -7839,6 +8390,7 @@ public void testRedundantSortOnMvExpandJoinKeepDropRename() { } /** + *
{@code
      * TopN[[Order[emp_no{f}#15,ASC,LAST]],1000[INTEGER]]
      * \_Filter[emp_no{f}#15 > 1[INTEGER]]
      *   \_MvExpand[foo{r}#10,foo{r}#29]
@@ -7848,6 +8400,7 @@ public void testRedundantSortOnMvExpandJoinKeepDropRename() {
      *           |_Eval[[1[INTEGER] AS language_code]]
      *           | \_EsRelation[test][_meta_field{f}#21, emp_no{f}#15, first_name{f}#16, ..]
      *           \_EsRelation[languages_lookup][LOOKUP][language_code{f}#26, language_name{f}#27]
+     * }
*/ public void testEvalLookupMultipleSorts() { var plan = optimizedPlan(""" @@ -7962,10 +8515,12 @@ public void testPruneRedundantOrderBy() { } /** + *
{@code
      * Eval[[1[INTEGER] AS irrelevant1, 2[INTEGER] AS irrelevant2]]
      *    \_Limit[1000[INTEGER],false]
      *      \_Sample[0.015[DOUBLE],15[INTEGER]]
      *        \_EsRelation[test][_meta_field{f}#12, emp_no{f}#6, first_name{f}#7, ge..]
+     * }
*/ public void testSampleMerged() { assumeTrue("sample must be enabled", EsqlCapabilities.Cap.SAMPLE_V3.isEnabled()); @@ -8055,12 +8610,14 @@ public void testSampleNoPushDown() { } /** + *
{@code
      *    Limit[1000[INTEGER],false]
      *    \_Sample[0.5[DOUBLE],null]
      *      \_Join[LEFT,[language_code{r}#4],[language_code{r}#4],[language_code{f}#17]]
      *        |_Eval[[emp_no{f}#6 AS language_code]]
      *        | \_EsRelation[test][_meta_field{f}#12, emp_no{f}#6, first_name{f}#7, ge..]
      *        \_EsRelation[languages_lookup][LOOKUP][language_code{f}#17, language_name{f}#18]
+     * }
*/ public void testSampleNoPushDownLookupJoin() { assumeTrue("sample must be enabled", EsqlCapabilities.Cap.SAMPLE_V3.isEnabled()); @@ -8081,12 +8638,14 @@ public void testSampleNoPushDownLookupJoin() { } /** + *
{@code
      *    Limit[1000[INTEGER],false]
      *    \_Sample[0.5[DOUBLE],null]
      *      \_Limit[1000[INTEGER],false]
      *        \_ChangePoint[emp_no{f}#6,hire_date{f}#13,type{r}#4,pvalue{r}#5]
      *          \_TopN[[Order[hire_date{f}#13,ASC,ANY]],1001[INTEGER]]
      *            \_EsRelation[test][_meta_field{f}#12, emp_no{f}#6, first_name{f}#7, ge..]
+     * }
*/ public void testSampleNoPushDownChangePoint() { assumeTrue("sample must be enabled", EsqlCapabilities.Cap.SAMPLE_V3.isEnabled()); From 164a60351a242989eb684449f0bb50c5760096e1 Mon Sep 17 00:00:00 2001 From: Mark Tozzi Date: Mon, 4 Aug 2025 17:25:32 -0400 Subject: [PATCH 2/3] save some lines --- .../optimizer/LogicalPlanOptimizerTests.java | 805 ++++++------------ 1 file changed, 269 insertions(+), 536 deletions(-) diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/optimizer/LogicalPlanOptimizerTests.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/optimizer/LogicalPlanOptimizerTests.java index 40920e9a1962e..50419d4ae11bc 100644 --- a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/optimizer/LogicalPlanOptimizerTests.java +++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/optimizer/LogicalPlanOptimizerTests.java @@ -232,13 +232,12 @@ public void testEmptyProjectionInStat() { /** * Expects * - *
-     * {@code
+     * 
{@code
      * EsqlProject[[x{r}#6]]
      * \_Eval[[1[INTEGER] AS x]]
      *   \_Limit[1000[INTEGER]]
-     *     \_LocalRelation[[{e}#18],[ConstantNullBlock[positions=1]]]}
-     * 
+ * \_LocalRelation[[{e}#18],[ConstantNullBlock[positions=1]]] + * }
*/ public void testEmptyProjectInStatWithEval() { var plan = plan(""" @@ -266,16 +265,14 @@ public void testEmptyProjectInStatWithEval() { /** * Expects - *
-     * {@code
+     * 
{@code
      * EsqlProject[[x{r}#8]]
      * \_Eval[[1[INTEGER] AS x]]
      *   \_Limit[1000[INTEGER]]
      *     \_Aggregate[[emp_no{f}#15],[emp_no{f}#15]]
      *       \_Filter[languages{f}#18 > 1[INTEGER]]
      *         \_EsRelation[test][_meta_field{f}#21, emp_no{f}#15, first_name{f}#16, ..]
-     * }
-     * 
+ * }
*/ public void testEmptyProjectInStatWithGroupAndEval() { var plan = plan(""" @@ -322,13 +319,11 @@ public void testCombineProjections() { /** * Expects - *
-     * {@code
+     * 
{@code
      * Project[[languages{f}#12 AS f2]]
      * \_Limit[1000[INTEGER]]
      *   \_EsRelation[test][_meta_field{f}#15, emp_no{f}#9, first_name{f}#10, g..]
-     * }
-     * 
+ * }
*/ public void testCombineProjectionsWithEvalAndDrop() { var plan = plan(""" @@ -347,14 +342,12 @@ public void testCombineProjectionsWithEvalAndDrop() { /** * Expects - *
-     * {@code
+     * 
{@code
      * Project[[last_name{f}#26, languages{f}#25 AS f2, f4{r}#13]]
      * \_Eval[[languages{f}#25 + 3[INTEGER] AS f4]]
      *   \_Limit[1000[INTEGER]]
      *     \_EsRelation[test][_meta_field{f}#28, emp_no{f}#22, first_name{f}#23, ..]
-     * }
-     * 
+ * }
*/ public void testCombineProjectionsWithEval() { var plan = plan(""" @@ -418,14 +411,12 @@ public void testCombineProjectionWithAggregation() { /** * Expects - *
-     * {@code
+     * 
{@code
      * Limit[1000[INTEGER]]
      * \_Aggregate[[last_name{f}#23, first_name{f}#20],[SUM(salary{f}#24) AS s, last_name{f}#23, first_name{f}#20, first_name{f}#2
      * 0 AS k]]
      *   \_EsRelation[test][_meta_field{f}#25, emp_no{f}#19, first_name{f}#20, ..]
-     * }
-     * 
+ * }
*/ public void testCombineProjectionWithAggregationAndEval() { var plan = plan(""" @@ -443,13 +434,11 @@ public void testCombineProjectionWithAggregationAndEval() { /** * Expects - *
-     * {@code
+     * 
{@code
      * TopN[[Order[x{r}#10,ASC,LAST]],1000[INTEGER]]
      * \_Aggregate[[languages{f}#16],[MAX(emp_no{f}#13) AS x, languages{f}#16]]
      *   \_EsRelation[test][_meta_field{f}#19, emp_no{f}#13, first_name{f}#14, ..]
-     * }
-     * 
+ * }
*/ public void testRemoveOverridesInAggregate() throws Exception { var plan = plan(""" @@ -477,13 +466,11 @@ public void testRemoveOverridesInAggregate() throws Exception { /** * Expects - *
-     * {@code
+     * 
{@code
      * TopN[[Order[b{r}#10,ASC,LAST]],1000[INTEGER]]
      * \_Aggregate[[b{r}#10],[languages{f}#16 AS b]]
      *   \_EsRelation[test][_meta_field{f}#19, emp_no{f}#13, first_name{f}#14, ..]
-     * }
-     * 
+ * }
*/ public void testAggsWithOverridingInputAndGrouping() throws Exception { var plan = plan(""" @@ -505,14 +492,12 @@ public void testAggsWithOverridingInputAndGrouping() throws Exception { } /** - *
-     * {@code
+     * 
{@code
      * Project[[s{r}#4 AS d, s{r}#4, last_name{f}#21, first_name{f}#18]]
      * \_Limit[1000[INTEGER]]
      *   \_Aggregate[[last_name{f}#21, first_name{f}#18],[SUM(salary{f}#22) AS s, last_name{f}#21, first_name{f}#18]]
      *     \_EsRelation[test][_meta_field{f}#23, emp_no{f}#17, first_name{f}#18, ..]
-     * }
-     * 
+ * }
*/ public void testCombineProjectionWithDuplicateAggregation() { var plan = plan(""" @@ -531,14 +516,12 @@ public void testCombineProjectionWithDuplicateAggregation() { } /** - *
-     * {@code
+     * 
{@code
      * Limit[1000[INTEGER]]
      * \_Aggregate[STANDARD,[],[SUM(salary{f}#12,true[BOOLEAN]) AS sum(salary), SUM(salary{f}#12,last_name{f}#11 == [44 6f 65][KEYW
      * ORD]) AS sum(salary) WheRe last_name ==   "Doe"]]
      *   \_EsRelation[test][_meta_field{f}#13, emp_no{f}#7, first_name{f}#8, ge..]
-     * }
-     * 
+ * }
*/ public void testStatsWithFilteringDefaultAliasing() { var plan = plan(""" @@ -553,12 +536,10 @@ public void testStatsWithFilteringDefaultAliasing() { } /** - *
-     * {@code
+     * 
{@code
      * Limit[1000[INTEGER]]
      * \_LocalRelation[[sum(salary) where false{r}#26],[ConstantNullBlock[positions=1]]]
-     * }
-     * 
+ * }
*/ public void testReplaceStatsFilteredAggWithEvalSingleAgg() { var plan = plan(""" @@ -576,14 +557,12 @@ public void testReplaceStatsFilteredAggWithEvalSingleAgg() { } /** - *
-     * {@code
+     * 
{@code
      * Project[[sum(salary) + 1 where false{r}#68]]
      * \_Eval[[$$SUM$sum(salary)_+_1$0{r$}#79 + 1[INTEGER] AS sum(salary) + 1 where false]]
      *   \_Limit[1000[INTEGER]]
      *     \_LocalRelation[[$$SUM$sum(salary)_+_1$0{r$}#79],[ConstantNullBlock[positions=1]]]
-     * }
-     * 
+ * }
*/ public void testReplaceStatsFilteredAggWithEvalSingleAggWithExpression() { var plan = plan(""" @@ -612,15 +591,13 @@ public void testReplaceStatsFilteredAggWithEvalSingleAggWithExpression() { } /** - *
-     * {@code
+     * 
{@code
      * Project[[sum(salary) + 1 where false{r}#4, sum(salary) + 2{r}#6, emp_no{f}#7]]
      * \_Eval[[null[LONG] AS sum(salary) + 1 where false, $$SUM$sum(salary)_+_2$1{r$}#18 + 2[INTEGER] AS sum(salary) + 2]]
      *   \_Limit[1000[INTEGER]]
      *     \_Aggregate[STANDARD,[emp_no{f}#7],[SUM(salary{f}#12,true[BOOLEAN]) AS $$SUM$sum(salary)_+_2$1, emp_no{f}#7]]
      *       \_EsRelation[test][_meta_field{f}#13, emp_no{f}#7, first_name{f}#8, ge..]
-     * }
-     * 
+ * }
*/ public void testReplaceStatsFilteredAggWithEvalMixedFilterAndNoFilter() { var plan = plan(""" @@ -649,16 +626,14 @@ public void testReplaceStatsFilteredAggWithEvalMixedFilterAndNoFilter() { } /** - *
-     * {@code
+     * 
{@code
      * Project[[sum(salary) + 1 where false{r}#3, sum(salary) + 3{r}#5, sum(salary) + 2 where false{r}#7]]
      * \_Eval[[null[LONG] AS sum(salary) + 1 where false, $$SUM$sum(salary)_+_3$1{r$}#19 + 3[INTEGER] AS sum(salary) + 3, nu
      * ll[LONG] AS sum(salary) + 2 where false]]
      *   \_Limit[1000[INTEGER]]
      *     \_Aggregate[STANDARD,[],[SUM(salary{f}#13,true[BOOLEAN]) AS $$SUM$sum(salary)_+_3$1]]
      *       \_EsRelation[test][_meta_field{f}#14, emp_no{f}#8, first_name{f}#9, ge..]
-     *       }
-     * 
+     * }
* */ public void testReplaceStatsFilteredAggWithEvalFilterFalseAndNull() { @@ -696,12 +671,10 @@ public void testReplaceStatsFilteredAggWithEvalFilterFalseAndNull() { } /** - *
-     * {@code
+     * 
{@code
      * Limit[1000[INTEGER]]
      * \_LocalRelation[[count(salary) where false{r}#3],[LongVectorBlock[vector=ConstantLongVector[positions=1, value=0]]]]
-     * }
-     * 
+ * }
*/ public void testReplaceStatsFilteredAggWithEvalCount() { var plan = plan(""" @@ -720,14 +693,12 @@ public void testReplaceStatsFilteredAggWithEvalCount() { } /** - *
-     * {@code
+     * 
{@code
      * Project[[count_distinct(salary + 2) + 3 where false{r}#3]]
      * \_Eval[[$$COUNTDISTINCT$count_distinct(>$0{r$}#15 + 3[INTEGER] AS count_distinct(salary + 2) + 3 where false]]
      *   \_Limit[1000[INTEGER]]
      *     \_LocalRelation[[$$COUNTDISTINCT$count_distinct(>$0{r$}#15],[LongVectorBlock[vector=ConstantLongVector[positions=1, value=0]]]]
-     * }
-     * 
+ * }
*/ public void testReplaceStatsFilteredAggWithEvalCountDistinctInExpression() { var plan = plan(""" @@ -757,16 +728,14 @@ public void testReplaceStatsFilteredAggWithEvalCountDistinctInExpression() { } /** - *
-     * {@code
+     * 
{@code
      * Project[[max{r}#91, max_a{r}#94, min{r}#97, min_a{r}#100, emp_no{f}#101]]
      * \_Eval[[null[INTEGER] AS max_a, null[INTEGER] AS min_a]]
      *   \_Limit[1000[INTEGER]]
      *     \_Aggregate[STANDARD,[emp_no{f}#101],[MAX(salary{f}#106,true[BOOLEAN]) AS max, MIN(salary{f}#106,true[BOOLEAN]) AS min, emp_
      * no{f}#101]]
      *       \_EsRelation[test][_meta_field{f}#107, emp_no{f}#101, first_name{f}#10..]
-     * }
-     * 
+ * }
*/ public void testReplaceStatsFilteredAggWithEvalSameAggWithAndWithoutFilter() { var plan = plan(""" @@ -802,12 +771,10 @@ public void testReplaceStatsFilteredAggWithEvalSameAggWithAndWithoutFilter() { } /** - *
-     * {@code
+     * 
{@code
      * Limit[1000[INTEGER]]
      * \_LocalRelation[[count{r}#7],[LongVectorBlock[vector=ConstantLongVector[positions=1, value=0]]]]
-     * }
-     * 
+ * }
*/ @AwaitsFix(bugUrl = "https://github.com/elastic/elasticsearch/issues/100634") // i.e. PropagateEvalFoldables applicability to Aggs public void testReplaceStatsFilteredAggWithEvalFilterUsingEvaledValue() { @@ -829,15 +796,13 @@ public void testReplaceStatsFilteredAggWithEvalFilterUsingEvaledValue() { /** * - *
-     * {@code
+     * 
{@code
      * Project[[c{r}#67, emp_no{f}#68]]
      * \_Eval[[0[LONG] AS c]]
      *   \_Limit[1000[INTEGER]]
      *     \_Aggregate[STANDARD,[emp_no{f}#68],[emp_no{f}#68]]
      *       \_EsRelation[test][_meta_field{f}#74, emp_no{f}#68, first_name{f}#69, ..]
-     * }
-     * 
+ * }
*/ public void testReplaceStatsFilteredAggWithEvalSingleAggWithGroup() { var plan = plan(""" @@ -1173,13 +1138,11 @@ public void testCombineDisjunctionToInFromIn() { /** * Expects - *
-     * {@code
+     * 
{@code
      * Limit[1000[INTEGER]]
      * \_Aggregate[[first_name{f}#12],[COUNT(salary{f}#16) AS count(salary), first_name{f}#12 AS x]]
      *   \_EsRelation[test][_meta_field{f}#17, emp_no{f}#11, first_name{f}#12, ..]
-     * }
-     * 
+ * }
*/ public void testCombineProjectionWithPruning() { var plan = plan(""" @@ -1201,13 +1164,11 @@ public void testCombineProjectionWithPruning() { /** * Expects - *
-     * {@code
+     * 
{@code
      * Limit[1000[INTEGER]]
      * \_Aggregate[[first_name{f}#16],[SUM(emp_no{f}#15) AS s, COUNT(first_name{f}#16) AS c, first_name{f}#16 AS f]]
      *   \_EsRelation[test][_meta_field{f}#21, emp_no{f}#15, first_name{f}#16, ..]
-     * }
-     * 
+ * }
*/ public void testCombineProjectionWithAggregationFirstAndAliasedGroupingUsedInAgg() { var plan = plan(""" @@ -1235,13 +1196,11 @@ public void testCombineProjectionWithAggregationFirstAndAliasedGroupingUsedInAgg /** * Expects - *
-     * {@code
+     * 
{@code
      * Limit[1000[INTEGER]]
      * \_Aggregate[STANDARD,[CATEGORIZE(first_name{f}#18) AS cat],[SUM(salary{f}#22,true[BOOLEAN]) AS s, cat{r}#10]]
      *   \_EsRelation[test][_meta_field{f}#23, emp_no{f}#17, first_name{f}#18, ..]
-     * }
-     * 
+ * }
*/ public void testCombineProjectionWithCategorizeGrouping() { var plan = plan(""" @@ -1296,14 +1255,12 @@ public void testCombineProjectionWithAggregationFirstAndAliasedGroupingUnused() /** * Expects - *
-     * {@code
+     * 
{@code
      * EsqlProject[[x{r}#3, y{r}#6]]
      * \_Eval[[emp_no{f}#9 + 2[INTEGER] AS x, salary{f}#14 + 3[INTEGER] AS y]]
      *   \_Limit[10000[INTEGER]]
      *     \_EsRelation[test][_meta_field{f}#15, emp_no{f}#9, first_name{f}#10, g..]
-     * }
-     * 
+ * }
*/ public void testCombineEvals() { var plan = plan(""" @@ -1856,13 +1813,11 @@ public void testCombineOrderByThroughFilter() { /** * Expected - *
-     * {@code
+     * 
{@code
      * TopN[[Order[first_name{r}#5575,ASC,LAST]],1000[INTEGER]]
      * \_MvExpand[first_name{f}#5565,first_name{r}#5575,null]
      *   \_EsRelation[test][_meta_field{f}#5570, emp_no{f}#5564, first_name{f}#..]
-     * }
-     * 
+ * }
*/ public void testDontCombineOrderByThroughMvExpand() { LogicalPlan plan = optimizedPlan(""" @@ -1879,15 +1834,13 @@ public void testDontCombineOrderByThroughMvExpand() { /** * Expected - *
-     * {@code
+     * 
{@code
      * Limit[1000[INTEGER],true]
      * \_MvExpand[x{r}#4,x{r}#19]
      *   \_EsqlProject[[first_name{f}#9 AS x]]
      *     \_Limit[1000[INTEGER],false]
      *       \_EsRelation[test][_meta_field{f}#14, emp_no{f}#8, first_name{f}#9, ge..]
-     * }
-     * 
+ * }
*/ public void testCopyDefaultLimitPastMvExpand() { LogicalPlan plan = optimizedPlan(""" @@ -1906,16 +1859,14 @@ public void testCopyDefaultLimitPastMvExpand() { /** * Expected - *
-     * {@code
+     * 
{@code
      * Project[[languages{f}#10 AS language_code#4, language_name{f}#19]]
      * \_Limit[1000[INTEGER],true]
      *   \_Join[LEFT,[languages{f}#10],[languages{f}#10],[language_code{f}#18]]
      *     |_Limit[1000[INTEGER],false]
      *     | \_EsRelation[test][_meta_field{f}#13, emp_no{f}#7, first_name{f}#8, ge..]
      *     \_EsRelation[languages_lookup][LOOKUP][language_code{f}#18, language_name{f}#19]
-     * }
-     * 
+ * }
*/ public void testCopyDefaultLimitPastLookupJoin() { LogicalPlan plan = optimizedPlan(""" @@ -1934,15 +1885,13 @@ public void testCopyDefaultLimitPastLookupJoin() { /** * Expected - *
-     * {@code
+     * 
{@code
      * Limit[10[INTEGER],true]
      * \_MvExpand[first_name{f}#7,first_name{r}#17]
      *   \_EsqlProject[[first_name{f}#7, last_name{f}#10]]
      *     \_Limit[1[INTEGER],false]
      *       \_EsRelation[test][_meta_field{f}#12, emp_no{f}#6, first_name{f}#7, ge..]
-     * }
-     * 
+ * }
*/ public void testDontPushDownLimitPastMvExpand() { LogicalPlan plan = optimizedPlan(""" @@ -1962,16 +1911,14 @@ public void testDontPushDownLimitPastMvExpand() { /** * Expected - *
-     * {@code
+     * 
{@code
      * Project[[languages{f}#11 AS language_code#4, last_name{f}#12, language_name{f}#20]]
      * \_Limit[10[INTEGER],true]
      *   \_Join[LEFT,[languages{f}#11],[languages{f}#11],[language_code{f}#19]]
      *     |_Limit[1[INTEGER],false]
      *     | \_EsRelation[test][_meta_field{f}#14, emp_no{f}#8, first_name{f}#9, ge..]
      *     \_EsRelation[languages_lookup][LOOKUP][language_code{f}#19, language_name{f}#20]
-     * }
-     * 
+ * }
*/ public void testDontPushDownLimitPastLookupJoin() { LogicalPlan plan = optimizedPlan(""" @@ -1992,8 +1939,7 @@ public void testDontPushDownLimitPastLookupJoin() { /** * Expected - *
-     * {@code
+     * 
{@code
      * EsqlProject[[emp_no{f}#19, first_name{r}#30, languages{f}#22, lll{r}#9, salary{r}#31]]
      * \_TopN[[Order[salary{r}#31,DESC,FIRST]],5[INTEGER]]
      *   \_Limit[5[INTEGER],true]
@@ -2006,8 +1952,7 @@ public void testDontPushDownLimitPastLookupJoin() {
      *                 \_TopN[[Order[emp_no{f}#19,DESC,FIRST]],10[INTEGER]]
      *                   \_Filter[emp_no{f}#19 ≤ 10006[INTEGER]]
      *                     \_EsRelation[test][_meta_field{f}#25, emp_no{f}#19, first_name{f}#20, ..]
-     * }
-     * 
+ * }
*/ public void testMultipleMvExpandWithSortAndLimit() { LogicalPlan plan = optimizedPlan(""" @@ -2045,8 +1990,7 @@ public void testMultipleMvExpandWithSortAndLimit() { /** * Expected * - *
-     * {@code
+     * 
{@code
      * Project[[emp_no{f}#24, first_name{f}#25, languages{f}#27, lll{r}#11, salary{f}#29, language_name{f}#38]]
      * \_TopN[[Order[salary{f}#29,DESC,FIRST]],5[INTEGER]]
      *   \_Limit[5[INTEGER],true]
@@ -2061,8 +2005,7 @@ public void testMultipleMvExpandWithSortAndLimit() {
      *       |         |   \_EsRelation[test][_meta_field{f}#30, emp_no{f}#24, first_name{f}#25, ..]
      *       |         \_EsRelation[languages_lookup][LOOKUP][language_code{f}#35]
      *       \_EsRelation[languages_lookup][LOOKUP][language_code{f}#37, language_name{f}#38]
-     * }
-     * 
+ * }
*/ public void testMultipleLookupJoinWithSortAndLimit() { LogicalPlan plan = optimizedPlan(""" @@ -2101,14 +2044,12 @@ public void testMultipleLookupJoinWithSortAndLimit() { } /** - *
-     * {@code
+     * 
{@code
      * EsqlProject[[emp_no{f}#10, first_name{r}#21, salary{f}#15]]
      * \_TopN[[Order[salary{f}#15,ASC,LAST], Order[first_name{r}#21,ASC,LAST]],5[INTEGER]]
      *   \_MvExpand[first_name{f}#11,first_name{r}#21,null]
      *     \_EsRelation[test][_meta_field{f}#16, emp_no{f}#10, first_name{f}#11, ..]
-     * }
-     * 
+ * }
*/ public void testPushDownLimitThroughMultipleSort_AfterMvExpand() { LogicalPlan plan = optimizedPlan(""" @@ -2129,15 +2070,13 @@ public void testPushDownLimitThroughMultipleSort_AfterMvExpand() { /** * Expected - *
-     * {@code
+     * 
{@code
      * EsqlProject[[emp_no{f}#2560, first_name{r}#2571, salary{f}#2565]]
      * \_TopN[[Order[first_name{r}#2571,ASC,LAST]],5[INTEGER]]
      *   \_TopN[[Order[salary{f}#2565,ASC,LAST]],5[INTEGER]]
      *     \_MvExpand[first_name{f}#2561,first_name{r}#2571,null]
      *       \_EsRelation[test][_meta_field{f}#2566, emp_no{f}#2560, first_name{f}#..]
-     * }
-     * 
+ * }
*/ public void testPushDownLimitThroughMultipleSort_AfterMvExpand2() { LogicalPlan plan = optimizedPlan(""" @@ -2164,16 +2103,14 @@ public void testPushDownLimitThroughMultipleSort_AfterMvExpand2() { * TODO: Push down the filter correctly https://github.com/elastic/elasticsearch/issues/115311 * * Expected - *
-     * {@code
+     * 
{@code
      * Limit[5[INTEGER]]
      * \_Filter[ISNOTNULL(first_name{r}#23)]
      *   \_Aggregate[STANDARD,[first_name{r}#23],[MAX(salary{f}#18,true[BOOLEAN]) AS max_s, first_name{r}#23]]
      *     \_MvExpand[first_name{f}#14,first_name{r}#23]
      *       \_TopN[[Order[emp_no{f}#13,ASC,LAST]],50[INTEGER]]
      *         \_EsRelation[test][_meta_field{f}#19, emp_no{f}#13, first_name{f}#14, ..]
-     * }
-     * 
+ * }
*/ public void testDontPushDownLimitPastAggregate_AndMvExpand() { LogicalPlan plan = optimizedPlan(""" @@ -2234,8 +2171,7 @@ public void testPushDown_TheRightLimit_PastMvExpand() { * * Expected * - *
-     * {@code
+     * 
{@code
      * Limit[5[INTEGER],false]
      * \_Filter[ISNOTNULL(first_name{f}#15)]
      *   \_Aggregate[[first_name{f}#15],[MAX(salary{f}#19,true[BOOLEAN]) AS max_s#12, first_name{f}#15]]
@@ -2244,8 +2180,7 @@ public void testPushDown_TheRightLimit_PastMvExpand() {
      *         |_Limit[50[INTEGER],false]
      *         | \_EsRelation[test][_meta_field{f}#20, emp_no{f}#14, first_name{f}#15, ..]
      *         \_EsRelation[languages_lookup][LOOKUP][language_code{f}#25]
-     * }
-     * 
+ * }
*/ public void testPushDown_TheRightLimit_PastLookupJoin() { LogicalPlan plan = optimizedPlan(""" @@ -2269,15 +2204,13 @@ public void testPushDown_TheRightLimit_PastLookupJoin() { /** * Expected - *
-     * {@code
+     * 
{@code
      * EsqlProject[[first_name{f}#11, emp_no{f}#10, salary{f}#12, b{r}#4]]
      *  \_TopN[[Order[salary{f}#12,ASC,LAST]],5[INTEGER]]
      *    \_Eval[[100[INTEGER] AS b]]
      *      \_MvExpand[first_name{f}#11]
      *        \_EsRelation[employees][emp_no{f}#10, first_name{f}#11, salary{f}#12]
-     * }
-     * 
+ * }
*/ public void testPushDownLimit_PastEvalAndMvExpand() { LogicalPlan plan = optimizedPlan(""" @@ -2300,15 +2233,13 @@ public void testPushDownLimit_PastEvalAndMvExpand() { /** * Expected - *
-     * {@code
+     * 
{@code
      * EsqlProject[[emp_no{f}#5885, first_name{r}#5896, salary{f}#5890]]
      * \_TopN[[Order[salary{f}#5890,ASC,LAST], Order[first_name{r}#5896,ASC,LAST]],1000[INTEGER]]
      *   \_Filter[gender{f}#5887 == [46][KEYWORD] AND WILDCARDLIKE(first_name{r}#5896)]
      *     \_MvExpand[first_name{f}#5886,first_name{r}#5896,null]
      *       \_EsRelation[test][_meta_field{f}#5891, emp_no{f}#5885, first_name{f}#..]
-     * }
-     * 
+ * }
*/ public void testRedundantSort_BeforeMvExpand_WithFilterOnExpandedField_ResultTruncationDefaultSize() { LogicalPlan plan = optimizedPlan(""" @@ -2333,15 +2264,13 @@ public void testRedundantSort_BeforeMvExpand_WithFilterOnExpandedField_ResultTru /** * Expected * - *
-     * {@code
+     * 
{@code
      * Limit[10[INTEGER],true]
      * \_MvExpand[first_name{f}#7,first_name{r}#17]
      *   \_TopN[[Order[emp_no{f}#6,DESC,FIRST]],10[INTEGER]]
      *     \_Filter[emp_no{f}#6 ≤ 10006[INTEGER]]
      *       \_EsRelation[test][_meta_field{f}#12, emp_no{f}#6, first_name{f}#7, ge..]
-     * }
-     * 
+ * }
*/ public void testFilterWithSortBeforeMvExpand() { LogicalPlan plan = optimizedPlan(""" @@ -2363,8 +2292,7 @@ public void testFilterWithSortBeforeMvExpand() { /** * Expected * - *
-     * {@code
+     * 
{@code
      * Project[[_meta_field{f}#14, emp_no{f}#8, first_name{f}#9, gender{f}#10, hire_date{f}#15, job{f}#16, job.raw{f}#17,
      *          languages{f}#11 AS language_code#6, last_name{f}#12, long_noidx{f}#18, salary{f}#13, language_name{f}#20]]
      * \_Limit[10[INTEGER],true]
@@ -2373,8 +2301,7 @@ public void testFilterWithSortBeforeMvExpand() {
      *     | \_Filter[emp_no{f}#8 ≤ 10006[INTEGER]]
      *     |   \_EsRelation[test][_meta_field{f}#14, emp_no{f}#8, first_name{f}#9, ge..]
      *     \_EsRelation[languages_lookup][LOOKUP][language_code{f}#19, language_name{f}#20]
-     * }
-     * 
+ * }
*/ public void testFilterWithSortBeforeLookupJoin() { LogicalPlan plan = optimizedPlan(""" @@ -2398,15 +2325,13 @@ public void testFilterWithSortBeforeLookupJoin() { /** * Expected * - *
-     * {@code
+     * 
{@code
      * TopN[[Order[first_name{f}#10,ASC,LAST]],500[INTEGER]]
      * \_MvExpand[last_name{f}#13,last_name{r}#20,null]
      *   \_Filter[emp_no{r}#19 > 10050[INTEGER]]
      *     \_MvExpand[emp_no{f}#9,emp_no{r}#19,null]
      *       \_EsRelation[test][_meta_field{f}#15, emp_no{f}#9, first_name{f}#10, g..]
-     * }
-     * 
+ * }
*/ public void testMultiMvExpand_SortDownBelow() { LogicalPlan plan = optimizedPlan(""" @@ -2429,8 +2354,7 @@ public void testMultiMvExpand_SortDownBelow() { /** * Expected * - *
-     * {@code
+     * 
{@code
      * Limit[10000[INTEGER],true]
      * \_MvExpand[c{r}#7,c{r}#16]
      *   \_EsqlProject[[c{r}#7, a{r}#3]]
@@ -2441,8 +2365,7 @@ public void testMultiMvExpand_SortDownBelow() {
      *             \_LocalRelation[[a{r}#3, b{r}#5, c{r}#7],[ConstantNullBlock[positions=1],
      *               IntVectorBlock[vector=ConstantIntVector[positions=1, value=123]],
      *               IntVectorBlock[vector=ConstantIntVector[positions=1, value=234]]]]
-     * }
-     * 
+ * }
*/ public void testLimitThenSortBeforeMvExpand() { LogicalPlan plan = optimizedPlan(""" @@ -2468,8 +2391,7 @@ public void testLimitThenSortBeforeMvExpand() { /** * Expects * - *
-     * {@code
+     * 
{@code
      * Project[[c{r}#7 AS language_code#14, a{r}#3, language_name{f}#19]]
      * \_Limit[10000[INTEGER],true]
      *   \_Join[LEFT,[c{r}#7],[c{r}#7],[language_code{f}#18]]
@@ -2482,8 +2404,7 @@ public void testLimitThenSortBeforeMvExpand() {
      *                                                                   IntVectorBlock[vector=ConstantIntVector[positions=1, value=234]]]]
      *     |     \_EsRelation[languages_lookup][LOOKUP][language_code{f}#16]
      *     \_EsRelation[languages_lookup][LOOKUP][language_code{f}#18, language_name{f}#19]
-     * }
-     * 
+ * }
*/ public void testLimitThenSortBeforeLookupJoin() { LogicalPlan plan = optimizedPlan(""" @@ -2510,13 +2431,11 @@ public void testLimitThenSortBeforeLookupJoin() { /** * Expected - *
-     * {@code
+     * 
{@code
      * TopN[[Order[first_name{r}#16,ASC,LAST]],10000[INTEGER]]
      * \_MvExpand[first_name{f}#7,first_name{r}#16]
      *   \_EsRelation[test][_meta_field{f}#12, emp_no{f}#6, first_name{f}#7, ge..]
-     * }
-     * 
+ * }
*/ public void testRemoveUnusedSortBeforeMvExpand_DefaultLimit10000() { LogicalPlan plan = optimizedPlan(""" @@ -2535,15 +2454,13 @@ public void testRemoveUnusedSortBeforeMvExpand_DefaultLimit10000() { /** * Expected - *
-     *  {@code
+     * 
{@code
      * EsqlProject[[emp_no{f}#3517, first_name{r}#3528, salary{f}#3522]]
      * \_TopN[[Order[salary{f}#3522,ASC,LAST], Order[first_name{r}#3528,ASC,LAST]],15[INTEGER]]
      *   \_Filter[gender{f}#3519 == [46][KEYWORD] AND WILDCARDLIKE(first_name{r}#3528)]
      *     \_MvExpand[first_name{f}#3518,first_name{r}#3528,null]
      *       \_EsRelation[test][_meta_field{f}#3523, emp_no{f}#3517, first_name{f}#..]
-     *  }
-     * 
+ * }
*/ public void testRedundantSort_BeforeMvExpand_WithFilterOnExpandedField() { LogicalPlan plan = optimizedPlan(""" @@ -2568,15 +2485,13 @@ public void testRedundantSort_BeforeMvExpand_WithFilterOnExpandedField() { /** * Expected - *
-     * {@code
+     * 
{@code
      * EsqlProject[[emp_no{f}#3421, first_name{r}#3432, salary{f}#3426]]
      * \_TopN[[Order[salary{f}#3426,ASC,LAST], Order[first_name{r}#3432,ASC,LAST]],15[INTEGER]]
      *   \_Filter[gender{f}#3423 == [46][KEYWORD] AND salary{f}#3426 > 60000[INTEGER]]
      *     \_MvExpand[first_name{f}#3422,first_name{r}#3432,null]
      *       \_EsRelation[test][_meta_field{f}#3427, emp_no{f}#3421, first_name{f}#..]
-     * }
-     * 
+ * }
*/ public void testRedundantSort_BeforeMvExpand_WithFilter_NOT_OnExpandedField() { LogicalPlan plan = optimizedPlan(""" @@ -2601,15 +2516,13 @@ public void testRedundantSort_BeforeMvExpand_WithFilter_NOT_OnExpandedField() { /** * Expected - *
-     * {@code
+     * 
{@code
      * EsqlProject[[emp_no{f}#2085, first_name{r}#2096 AS x, salary{f}#2090]]
      * \_TopN[[Order[salary{f}#2090,ASC,LAST], Order[first_name{r}#2096,ASC,LAST]],15[INTEGER]]
      *   \_Filter[gender{f}#2087 == [46][KEYWORD] AND WILDCARDLIKE(first_name{r}#2096)]
      *     \_MvExpand[first_name{f}#2086,first_name{r}#2096,null]
      *       \_EsRelation[test][_meta_field{f}#2091, emp_no{f}#2085, first_name{f}#..]
-     * }
-     * 
+ * }
*/ public void testRedundantSort_BeforeMvExpand_WithFilterOnExpandedFieldAlias() { LogicalPlan plan = optimizedPlan(""" @@ -2635,14 +2548,12 @@ public void testRedundantSort_BeforeMvExpand_WithFilterOnExpandedFieldAlias() { /** * Expected: - *
-     * {@code
+     * 
{@code
      * Limit[1000[INTEGER],true]
      * \_MvExpand[a{r}#3,a{r}#7]
      *   \_TopN[[Order[a{r}#3,ASC,LAST]],1000[INTEGER]]
      *     \_LocalRelation[[a{r}#3],[IntVectorBlock[vector=ConstantIntVector[positions=1, value=1]]]]
-     * }
-     * 
+ * }
*/ public void testSortMvExpand() { LogicalPlan plan = optimizedPlan(""" @@ -2659,15 +2570,13 @@ public void testSortMvExpand() { /** * Expected: - *
-     * {@code
+     * 
{@code
      * Limit[1000[INTEGER],true]
      * \_Join[LEFT,[language_code{r}#3],[language_code{r}#3],[language_code{f}#6]]
      *   |_TopN[[Order[language_code{r}#3,ASC,LAST]],1000[INTEGER]]
      *   | \_LocalRelation[[language_code{r}#3],[IntVectorBlock[vector=ConstantIntVector[positions=1, value=1]]]]
      *   \_EsRelation[languages_lookup][LOOKUP][language_code{f}#6, language_name{f}#7]
-     * }
-     * 
+ * }
*/ public void testSortLookupJoin() { LogicalPlan plan = optimizedPlan(""" @@ -2684,14 +2593,12 @@ public void testSortLookupJoin() { /** * Expected: - *
-     * {@code
+     * 
{@code
      * Limit[20[INTEGER],true]
      * \_MvExpand[emp_no{f}#5,emp_no{r}#16]
      *   \_TopN[[Order[emp_no{f}#5,ASC,LAST]],20[INTEGER]]
      *     \_EsRelation[test][_meta_field{f}#11, emp_no{f}#5, first_name{f}#6, ge..]
-     * }
-     * 
+ * }
*/ public void testSortMvExpandLimit() { LogicalPlan plan = optimizedPlan(""" @@ -2710,8 +2617,7 @@ public void testSortMvExpandLimit() { /** * Expected: * - *
-     * {@code
+     * 
{@code
      * Project[[_meta_field{f}#13, emp_no{f}#7 AS language_code#5, first_name{f}#8, gender{f}#9, hire_date{f}#14, job{f}#15,
      *          job.raw{f}#16, languages{f}#10, last_name{f}#11, long_noidx{f}#17, salary{f}#12, language_name{f}#19]]
      * \_Limit[20[INTEGER],true]
@@ -2719,8 +2625,7 @@ public void testSortMvExpandLimit() {
      *     |_TopN[[Order[emp_no{f}#7,ASC,LAST]],20[INTEGER]]
      *     | \_EsRelation[test][_meta_field{f}#13, emp_no{f}#7, first_name{f}#8, ge..]
      *     \_EsRelation[languages_lookup][LOOKUP][language_code{f}#18, language_name{f}#19]
-     * }
-     * 
+ * }
*/ public void testSortLookupJoinLimit() { LogicalPlan plan = optimizedPlan(""" @@ -2740,15 +2645,13 @@ public void testSortLookupJoinLimit() { /** * Expected: - *
-     * {@code
+     * 
{@code
      * Limit[1000[INTEGER],true]
      * \_MvExpand[b{r}#5,b{r}#9]
      *   \_Limit[1000[INTEGER],false]
      *     \_LocalRelation[[a{r}#3, b{r}#5],[IntVectorBlock[vector=ConstantIntVector[positions=1, value=1]],
      *       IntVectorBlock[vector=ConstantIntVector[positions=1, value=-15]]]]
-     * }
-     * 
+ * }
* * see https://github.com/elastic/elasticsearch/issues/102084 */ @@ -2767,16 +2670,14 @@ public void testWhereMvExpand() { /** * Expected: - *
-     * {@code
+     * 
{@code
      * Limit[1000[INTEGER],true]
      * \_Join[LEFT,[language_code{r}#5],[language_code{r}#5],[language_code{f}#8]]
      *   |_Limit[1000[INTEGER],false]
      *   | \_LocalRelation[[a{r}#3, language_code{r}#5],[IntVectorBlock[vector=ConstantIntVector[positions=1, value=1]], IntVectorBlock[ve
      * ctor=ConstantIntVector[positions=1, value=-15]]]]
      *   \_EsRelation[languages_lookup][LOOKUP][language_code{f}#8, language_name{f}#9]
-     * }
-     * 
+ * }
*/ public void testWhereLookupJoin() { LogicalPlan plan = optimizedPlan(""" @@ -2793,15 +2694,13 @@ public void testWhereLookupJoin() { /** * Expects - *
-     * {@code
+     * 
{@code
      * TopN[[Order[language_code{r}#7,ASC,LAST]],1[INTEGER]]
      * \_Limit[1[INTEGER],true]
      *   \_MvExpand[language_code{r}#3,language_code{r}#7]
      *     \_Limit[1[INTEGER],false]
      *       \_LocalRelation[[language_code{r}#3],[IntVectorBlock[vector=ConstantIntVector[positions=1, value=1]]]]
-     * }
-     * 
+ * }
* * Notice that the `TopN` at the very top has limit 1, not 3! */ @@ -2823,16 +2722,14 @@ public void testDescendantLimitMvExpand() { /** * Expects - *
-     * {@code
+     * 
{@code
      * TopN[[Order[language_code{r}#3,ASC,LAST]],1[INTEGER]]
      * \_Limit[1[INTEGER],true]
      *   \_Join[LEFT,[language_code{r}#3],[language_code{r}#3],[language_code{f}#6]]
      *     |_Limit[1[INTEGER],false]
      *     | \_LocalRelation[[language_code{r}#3],[IntVectorBlock[vector=ConstantIntVector[positions=1, value=1]]]]
      *     \_EsRelation[languages_lookup][LOOKUP][language_code{f}#6, language_name{f}#7]
-     * }
-     * 
+ * }
* * Notice that the `TopN` at the very top has limit 1, not 3! */ @@ -2853,14 +2750,12 @@ public void testDescendantLimitLookupJoin() { } /** - *
-     * {@code
+     * 
{@code
      * EsqlProject[[emp_no{f}#9, first_name{f}#10, languages{f}#12, language_code{r}#3, language_name{r}#22]]
      * \_Eval[[null[INTEGER] AS language_code#3, null[KEYWORD] AS language_name#22]]
      *   \_Limit[1000[INTEGER],false]
      *     \_EsRelation[test][_meta_field{f}#15, emp_no{f}#9, first_name{f}#10, g..]
-     * }
-     * 
+ * }
*/ public void testPruneJoinOnNullMatchingField() { var plan = optimizedPlan(""" @@ -2878,14 +2773,12 @@ public void testPruneJoinOnNullMatchingField() { } /** - *
-     * {@code
+     * 
{@code
      * Project[[emp_no{f}#15, first_name{f}#16, my_null{r}#3 AS language_code#9, language_name{r}#27]]
      * \_Eval[[null[INTEGER] AS my_null#3, null[KEYWORD] AS language_name#27]]
      *   \_Limit[1000[INTEGER],false]
      *     \_EsRelation[test][_meta_field{f}#21, emp_no{f}#15, first_name{f}#16, ..]
-     * }
-     * 
+ * }
*/ public void testPruneJoinOnNullAssignedMatchingField() { var plan = optimizedPlan(""" @@ -2910,13 +2803,11 @@ private static List orderNames(TopN topN) { /** * Expects - *
-     * {@code
+     * 
{@code
      * Eval[[2[INTEGER] AS x]]
      * \_Limit[1000[INTEGER],false]
      *   \_LocalRelation[[{e}#9],[ConstantNullBlock[positions=1]]]
-     * }
-     * 
+ * }
*/ public void testEvalAfterStats() { var plan = optimizedPlan(""" @@ -2932,14 +2823,12 @@ public void testEvalAfterStats() { /** * Expects - *
-     * {@code
+     * 
{@code
      * Eval[[2[INTEGER] AS x]]
      * \_Limit[1000[INTEGER],false]
      *   \_Aggregate[[foo{r}#3],[foo{r}#3 AS x]]
      *     \_LocalRelation[[foo{r}#3],[IntVectorBlock[vector=ConstantIntVector[positions=1, value=1]]]]
-     * }
-     * 
+ * }
*/ public void testEvalAfterGroupBy() { var plan = optimizedPlan(""" @@ -3422,16 +3311,14 @@ public void testEnrichNotNullFilter() { /** * Expects - *
-     * {@code
+     * 
{@code
      * EsqlProject[[a{r}#3, last_name{f}#9]]
      * \_Eval[[__a_SUM_123{r}#12 / __a_COUNT_150{r}#13 AS a]]
      *   \_Limit[10000[INTEGER]]
      *     \_Aggregate[[last_name{f}#9],[SUM(salary{f}#10) AS __a_SUM_123, COUNT(salary{f}#10) AS __a_COUNT_150, last_nam
      * e{f}#9]]
      *       \_EsRelation[test][_meta_field{f}#11, emp_no{f}#5, first_name{f}#6, !g..]
-     * }
-     * 
+ * }
*/ public void testSimpleAvgReplacement() { var plan = plan(""" @@ -3461,15 +3348,13 @@ public void testSimpleAvgReplacement() { /** * Expects - *
-     * {@code
+     * 
{@code
      * EsqlProject[[a{r}#3, c{r}#6, s{r}#9, last_name{f}#15]]
      * \_Eval[[s{r}#9 / c{r}#6 AS a]]
      *   \_Limit[10000[INTEGER]]
      *     \_Aggregate[[last_name{f}#15],[COUNT(salary{f}#16) AS c, SUM(salary{f}#16) AS s, last_name{f}#15]]
      *       \_EsRelation[test][_meta_field{f}#17, emp_no{f}#11, first_name{f}#12, ..]
-     * }
-     * 
+ * }
*/ public void testClashingAggAvgReplacement() { var plan = plan(""" @@ -3491,16 +3376,14 @@ public void testClashingAggAvgReplacement() { /** * Expects - *
-     * {@code
+     * 
{@code
      * EsqlProject[[a{r}#3, c{r}#6, s{r}#9, last_name{f}#15]]
      * \_Eval[[s{r}#9 / __a_COUNT@xxx{r}#18 AS a]]
      *   \_Limit[10000[INTEGER]]
      *     \_Aggregate[[last_name{f}#15],[COUNT(salary{f}#16) AS __a_COUNT@xxx, COUNT(languages{f}#14) AS c, SUM(salary{f}#16) AS
      *  s, last_name{f}#15]]
      *       \_EsRelation[test][_meta_field{f}#17, emp_no{f}#11, first_name{f}#12, ..]
-     * }
-     * 
+ * }
*/ public void testSemiClashingAvgReplacement() { var plan = plan(""" @@ -3531,13 +3414,11 @@ public void testSemiClashingAvgReplacement() { /** * Expected - *
-     * {@code
+     * 
{@code
      * Limit[10000[INTEGER]]
      * \_Aggregate[[last_name{f}#9],[PERCENTILE(salary{f}#10,50[INTEGER]) AS m, last_name{f}#9]]
      *   \_EsRelation[test][_meta_field{f}#11, emp_no{f}#5, first_name{f}#6, !g..]
-     * }
-     * 
+ * }
*/ public void testMedianReplacement() { var plan = plan(""" @@ -3646,13 +3527,11 @@ public void testPruneChainedEvalNoProjection() { /** * Expects - *
-     * {@code
+     * 
{@code
      * Limit[1000[INTEGER]]
      * \_Aggregate[[],[COUNT(salary{f}#1345) AS c]]
      *   \_EsRelation[test][_meta_field{f}#1346, emp_no{f}#1340, first_name{f}#..]
-     * }
-     * 
+ * }
*/ public void testPruneEvalDueToStats() { var plan = plan(""" @@ -3689,13 +3568,11 @@ public void testPruneUnusedAggSimple() { /** * Expects - *
-     * {@code
+     * 
{@code
      * Limit[1000[INTEGER]]
      * \_Aggregate[[],[COUNT(salary{f}#19) AS x]]
      *   \_EsRelation[test][_meta_field{f}#20, emp_no{f}#14, first_name{f}#15, ..]
-     * }
-     * 
+ * }
*/ public void testPruneUnusedAggMixedWithEval() { var plan = plan(""" @@ -3737,15 +3614,13 @@ public void testPruneUnusedAggsChainedAgg() { /** * Expects - *
-     * {@code
+     * 
{@code
      * Project[[c{r}#342]]
      * \_Limit[1000[INTEGER]]
      *   \_Filter[min{r}#348 > 10[INTEGER]]
      *     \_Aggregate[[],[COUNT(salary{f}#367) AS c, MIN(salary{f}#367) AS min]]
      *       \_EsRelation[test][_meta_field{f}#368, emp_no{f}#362, first_name{f}#36..]
-     * }
-     * 
+ * }
*/ public void testPruneMixedAggInsideUnusedEval() { var plan = plan(""" @@ -3772,14 +3647,12 @@ public void testPruneMixedAggInsideUnusedEval() { /** * Expects - *
-     * {@code
+     * 
{@code
      * Eval[[max{r}#6 + min{r}#9 + c{r}#3 AS x, min{r}#9 AS y, c{r}#3 AS z]]
      * \_Limit[1000[INTEGER]]
      *   \_Aggregate[[],[COUNT(salary{f}#26) AS c, MAX(salary{f}#26) AS max, MIN(salary{f}#26) AS min]]
      *     \_EsRelation[test][_meta_field{f}#27, emp_no{f}#21, first_name{f}#22, ..]
-     * }
-     * 
+ * }
*/ public void testNoPruningWhenDealingJustWithEvals() { var plan = plan(""" @@ -3797,14 +3670,12 @@ public void testNoPruningWhenDealingJustWithEvals() { /** * Expects - *
-     * {@code
+     * 
{@code
      * Project[[y{r}#6 AS z]]
      * \_Eval[[emp_no{f}#11 + 1[INTEGER] AS y]]
      *   \_Limit[1000[INTEGER]]
      *     \_EsRelation[test][_meta_field{f}#17, emp_no{f}#11, first_name{f}#12, ..]
-     * }
-     * 
+ * }
*/ public void testNoPruningWhenChainedEvals() { var plan = plan(""" @@ -3823,13 +3694,11 @@ public void testNoPruningWhenChainedEvals() { /** * Expects - *
-     * {@code
+     * 
{@code
      * Project[[salary{f}#20 AS x, emp_no{f}#15 AS y]]
      * \_Limit[1000[INTEGER]]
      *   \_EsRelation[test][_meta_field{f}#21, emp_no{f}#15, first_name{f}#16, ..]
-     * }
-     * 
+ * }
*/ public void testPruningDuplicateEvals() { var plan = plan(""" @@ -3854,13 +3723,11 @@ public void testPruningDuplicateEvals() { /** * Expects - *
-     * {@code
+     * 
{@code
      * Limit[1000[INTEGER]]
      * \_Aggregate[[],[COUNT(salary{f}#24) AS cx, COUNT(emp_no{f}#19) AS cy]]
      *   \_EsRelation[test][_meta_field{f}#25, emp_no{f}#19, first_name{f}#20, ..]
-     * }
-     * 
+ * }
*/ public void testPruneEvalAliasOnAggUngrouped() { var plan = plan(""" @@ -3882,13 +3749,11 @@ public void testPruneEvalAliasOnAggUngrouped() { /** * Expects - *
-     * {@code
+     * 
{@code
      * Limit[1000[INTEGER]]
      * \_Aggregate[[x{r}#6],[COUNT(emp_no{f}#17) AS cy, salary{f}#22 AS x]]
      *   \_EsRelation[test][_meta_field{f}#23, emp_no{f}#17, first_name{f}#18, ..]
-     * }
-     * 
+ * }
*/ public void testPruneEvalAliasOnAggGroupedByAlias() { var plan = plan(""" @@ -3911,13 +3776,11 @@ public void testPruneEvalAliasOnAggGroupedByAlias() { /** * Expects - *
-     * {@code
+     * 
{@code
      * Limit[1000[INTEGER]]
      * \_Aggregate[[gender{f}#22],[COUNT(emp_no{f}#20) AS cy, MIN(salary{f}#25) AS cx, gender{f}#22]]
      *   \_EsRelation[test][_meta_field{f}#26, emp_no{f}#20, first_name{f}#21, ..]
-     * }
-     * 
+ * }
*/ public void testPruneEvalAliasOnAggGrouped() { var plan = plan(""" @@ -3941,13 +3804,11 @@ public void testPruneEvalAliasOnAggGrouped() { /** * Expects - *
-     * {@code
+     * 
{@code
      * Limit[1000[INTEGER]]
      * \_Aggregate[[gender{f}#21],[COUNT(emp_no{f}#19) AS cy, MIN(salary{f}#24) AS cx, gender{f}#21]]
      *   \_EsRelation[test][_meta_field{f}#25, emp_no{f}#19, first_name{f}#20, ..]
-     * }
-     * 
+ * }
*/ public void testPruneEvalAliasMixedWithRenameOnAggGrouped() { var plan = plan(""" @@ -3971,14 +3832,12 @@ public void testPruneEvalAliasMixedWithRenameOnAggGrouped() { /** * Expects - *
-     * {@code
+     * 
{@code
      * Limit[1000[INTEGER]]
      * \_Aggregate[[gender{f}#19],[COUNT(x{r}#3) AS cy, MIN(x{r}#3) AS cx, gender{f}#19]]
      *   \_Eval[[emp_no{f}#17 + 1[INTEGER] AS x]]
      *     \_EsRelation[test][_meta_field{f}#23, emp_no{f}#17, first_name{f}#18, ..]
-     * }
-     * 
+ * }
*/ public void testEvalAliasingAcrossCommands() { var plan = plan(""" @@ -4004,14 +3863,12 @@ public void testEvalAliasingAcrossCommands() { /** * Expects - *
-     * {@code
+     * 
{@code
      * Limit[1000[INTEGER]]
      * \_Aggregate[[gender{f}#19],[COUNT(x{r}#3) AS cy, MIN(x{r}#3) AS cx, gender{f}#19]]
      *   \_Eval[[emp_no{f}#17 + 1[INTEGER] AS x]]
      *     \_EsRelation[test][_meta_field{f}#23, emp_no{f}#17, first_name{f}#18, ..]
-     * }
-     * 
+ * }
*/ public void testEvalAliasingInsideSameCommand() { var plan = plan(""" @@ -4035,14 +3892,12 @@ public void testEvalAliasingInsideSameCommand() { /** * Expects - *
-     * {@code
+     * 
{@code
      * Limit[1000[INTEGER]]
      * \_Aggregate[[gender{f}#22],[COUNT(z{r}#9) AS cy, MIN(x{r}#3) AS cx, gender{f}#22]]
      *   \_Eval[[emp_no{f}#20 + 1[INTEGER] AS x, x{r}#3 + 1[INTEGER] AS z]]
      *     \_EsRelation[test][_meta_field{f}#26, emp_no{f}#20, first_name{f}#21, ..]
-     * }
-     * 
+ * }
*/ public void testEvalAliasingInsideSameCommandWithShadowing() { var plan = plan(""" @@ -4084,13 +3939,11 @@ public void testPruneRenameOnAgg() { /** * Expects - *
-     * {@code
+     * 
{@code
      * Limit[1000[INTEGER]]
      * \_Aggregate[[gender{f}#14],[COUNT(salary{f}#17) AS cy, MIN(emp_no{f}#12) AS cx, gender{f}#14]]
      *   \_EsRelation[test][_meta_field{f}#18, emp_no{f}#12, first_name{f}#13, ..]
-     * }
-     * 
+ * }
*/ public void testPruneRenameOnAggBy() { var plan = plan(""" @@ -4114,15 +3967,13 @@ public void testPruneRenameOnAggBy() { /** * Expects - *
-     * {@code
+     * 
{@code
      * Project[[c1{r}#2, c2{r}#4, cs{r}#6, cm{r}#8, cexp{r}#10]]
      * \_Eval[[c1{r}#2 AS c2, c1{r}#2 AS cs, c1{r}#2 AS cm, c1{r}#2 AS cexp]]
      *   \_Limit[1000[INTEGER]]
      *     \_Aggregate[[],[COUNT([2a][KEYWORD]) AS c1]]
      *       \_EsRelation[test][_meta_field{f}#17, emp_no{f}#11, first_name{f}#12, ..]
-     * }
-     * 
+ * }
*/ @AwaitsFix(bugUrl = "https://github.com/elastic/elasticsearch/issues/100634") public void testEliminateDuplicateAggsCountAll() { @@ -4149,15 +4000,13 @@ public void testEliminateDuplicateAggsCountAll() { /** * Expects - *
-     * {@code
+     * 
{@code
      * Project[[c1{r}#7, cx{r}#10, cs{r}#12, cy{r}#15]]
      * \_Eval[[c1{r}#7 AS cx, c1{r}#7 AS cs, c1{r}#7 AS cy]]
      *   \_Limit[1000[INTEGER]]
      *     \_Aggregate[[],[COUNT([2a][KEYWORD]) AS c1]]
      *       \_EsRelation[test][_meta_field{f}#22, emp_no{f}#16, first_name{f}#17, ..]
-     * }
-     * 
+ * }
*/ @AwaitsFix(bugUrl = "https://github.com/elastic/elasticsearch/issues/100634") public void testEliminateDuplicateAggsWithAliasedFields() { @@ -4186,14 +4035,12 @@ public void testEliminateDuplicateAggsWithAliasedFields() { /** * Expects - *
-     * {@code
+     * 
{@code
      * Project[[min{r}#1385, max{r}#1388, min{r}#1385 AS min2, max{r}#1388 AS max2, gender{f}#1398]]
      * \_Limit[1000[INTEGER]]
      *   \_Aggregate[[gender{f}#1398],[MIN(salary{f}#1401) AS min, MAX(salary{f}#1401) AS max, gender{f}#1398]]
      *     \_EsRelation[test][_meta_field{f}#1402, emp_no{f}#1396, first_name{f}#..]
-     * }
-     * 
+ * }
*/ public void testEliminateDuplicateAggsMixed() { var plan = plan(""" @@ -4220,13 +4067,11 @@ public void testEliminateDuplicateAggsMixed() { /** * Expects - *
-     * {@code
+     * 
{@code
      * EsqlProject[[a{r}#5, c{r}#8]]
      * \_Eval[[null[INTEGER] AS x]]
      *   \_EsRelation[test][_meta_field{f}#15, emp_no{f}#9, first_name{f}#10, g..]
-     * }
-     * 
+ * }
*/ @AwaitsFix(bugUrl = "https://github.com/elastic/elasticsearch/issues/100634") public void testEliminateDuplicateAggWithNull() { @@ -4240,14 +4085,12 @@ public void testEliminateDuplicateAggWithNull() { /** * Expects - *
-     * {@code
+     * 
{@code
      * Project[[max(x){r}#11, max(x){r}#11 AS max(y), max(x){r}#11 AS max(z)]]
      * \_Limit[1000[INTEGER]]
      *   \_Aggregate[[],[MAX(salary{f}#21) AS max(x)]]
      *     \_EsRelation[test][_meta_field{f}#22, emp_no{f}#16, first_name{f}#17, ..]
-     * }
-     * 
+ * }
*/ public void testEliminateDuplicateAggsNonCount() { var plan = plan(""" @@ -4275,13 +4118,11 @@ public void testEliminateDuplicateAggsNonCount() { /** * Expects - *
-     * {@code
+     * 
{@code
      * Limit[1000[INTEGER]]
      * \_Aggregate[[salary{f}#12],[salary{f}#12, salary{f}#12 AS x]]
      *   \_EsRelation[test][_meta_field{f}#13, emp_no{f}#7, first_name{f}#8, ge..]
-     * }
-     * 
+ * }
*/ public void testEliminateDuplicateRenamedGroupings() { var plan = plan(""" @@ -4300,14 +4141,12 @@ public void testEliminateDuplicateRenamedGroupings() { /** * Expected - *
-     * {@code
+     * 
{@code
      * Limit[2[INTEGER]]
      * \_Filter[a{r}#6 > 2[INTEGER]]
      *   \_MvExpand[a{r}#2,a{r}#6]
      *     \_Row[[[1, 2, 3][INTEGER] AS a]]
-     * }
-     * 
+ * }
*/ public void testMvExpandFoldable() { LogicalPlan plan = optimizedPlan(""" @@ -4328,13 +4167,11 @@ public void testMvExpandFoldable() { /** * Expected - *
-     * {@code
+     * 
{@code
      * Limit[1000[INTEGER]]
      * \_Aggregate[[a{r}#2],[COUNT([2a][KEYWORD]) AS bar]]
      *   \_Row[[1[INTEGER] AS a]]
-     * }
-     * 
+ * }
*/ public void testRenameStatsDropGroup() { LogicalPlan plan = optimizedPlan(""" @@ -4351,13 +4188,11 @@ public void testRenameStatsDropGroup() { /** * Expected - *
-     * {@code
+     * 
{@code
      * Limit[1000[INTEGER]]
      * \_Aggregate[[a{r}#3, b{r}#5],[COUNT([2a][KEYWORD]) AS baz, b{r}#5 AS bar]]
      *   \_Row[[1[INTEGER] AS a, 2[INTEGER] AS b]]
-     * }
-     * 
+ * }
*/ public void testMultipleRenameStatsDropGroup() { LogicalPlan plan = optimizedPlan(""" @@ -4374,13 +4209,11 @@ public void testMultipleRenameStatsDropGroup() { /** * Expected - *
-     * {@code
+     * 
{@code
      * Limit[1000[INTEGER]]
      * \_Aggregate[[emp_no{f}#14, gender{f}#16],[MAX(salary{f}#19) AS baz, gender{f}#16 AS bar]]
      *   \_EsRelation[test][_meta_field{f}#20, emp_no{f}#14, first_name{f}#15, ..]
-     * }
-     * 
+ * }
*/ public void testMultipleRenameStatsDropGroupMultirow() { LogicalPlan plan = optimizedPlan(""" @@ -4420,13 +4253,11 @@ private void aggFieldName(Expression exp, Class /** * Expects - *
-     * {@code
+     * 
{@code
      * Limit[1000[INTEGER]]
      * \_Aggregate[[],[SUM(emp_no{f}#4) AS sum(emp_no)]]
      *   \_EsRelation[test][_meta_field{f}#10, emp_no{f}#4, first_name{f}#5, ge..]
-     * }
-     * 
+ * }
*/ public void testIsNotNullConstraintForStatsWithoutGrouping() { var plan = optimizedPlan(""" @@ -4456,13 +4287,11 @@ public void testIsNotNullConstraintForStatsWithGrouping() { /** * Expected - *
-     * {@code
+     * 
{@code
      * Limit[1000[INTEGER]]
      * \_Aggregate[[salary{f}#1185],[SUM(salary{f}#1185) AS sum(salary), salary{f}#1185]]
      *   \_EsRelation[test][_meta_field{f}#1186, emp_no{f}#1180, first_name{f}#..]
-     * }
-     * 
+ * }
*/ public void testIsNotNullConstraintForStatsWithAndOnGrouping() { var plan = optimizedPlan(""" @@ -4479,13 +4308,11 @@ public void testIsNotNullConstraintForStatsWithAndOnGrouping() { /** * Expects - *
-     * {@code
+     * 
{@code
      * Limit[1000[INTEGER]]
      * \_Aggregate[[salary{f}#13],[SUM(salary{f}#13) AS sum(salary), salary{f}#13 AS x]]
      *   \_EsRelation[test][_meta_field{f}#14, emp_no{f}#8, first_name{f}#9, ge..]
-     * }
-     * 
+ * }
*/ public void testIsNotNullConstraintForStatsWithAndOnGroupingAlias() { var plan = optimizedPlan(""" @@ -4503,13 +4330,11 @@ public void testIsNotNullConstraintForStatsWithAndOnGroupingAlias() { /** * Expects - *
-     * {@code
+     * 
{@code
      * Limit[1000[INTEGER]]
      * \_Aggregate[[salary{f}#13],[SUM(emp_no{f}#8) AS sum(x), salary{f}#13]]
      *   \_EsRelation[test][_meta_field{f}#14, emp_no{f}#8, first_name{f}#9, ge..]
-     * }
-     * 
+ * }
*/ public void testIsNotNullConstraintSkippedForStatsWithAlias() { var plan = optimizedPlan(""" @@ -4529,13 +4354,11 @@ public void testIsNotNullConstraintSkippedForStatsWithAlias() { /** * Expects - *
-     * {@code
+     * 
{@code
      * Limit[1000[INTEGER]]
      * \_Aggregate[[],[SUM(emp_no{f}#8) AS a, MIN(salary{f}#13) AS b]]
      *   \_EsRelation[test][_meta_field{f}#14, emp_no{f}#8, first_name{f}#9, ge..]
-     * }
-     * 
+ * }
*/ public void testIsNotNullConstraintForStatsWithMultiAggWithoutGrouping() { var plan = optimizedPlan(""" @@ -4552,13 +4375,11 @@ public void testIsNotNullConstraintForStatsWithMultiAggWithoutGrouping() { /** * Expects - *
-     * {@code
+     * 
{@code
      * Limit[1000[INTEGER]]
      * \_Aggregate[[gender{f}#11],[SUM(emp_no{f}#9) AS a, MIN(salary{f}#14) AS b, gender{f}#11]]
      *   \_EsRelation[test][_meta_field{f}#15, emp_no{f}#9, first_name{f}#10, g..]
-     * }
-     * 
+ * }
*/ public void testIsNotNullConstraintForStatsWithMultiAggWithGrouping() { var plan = optimizedPlan(""" @@ -4575,13 +4396,11 @@ public void testIsNotNullConstraintForStatsWithMultiAggWithGrouping() { /** * Expects - *
-     * {@code
+     * 
{@code
      * Limit[1000[INTEGER]]
      * \_Aggregate[[emp_no{f}#9],[SUM(emp_no{f}#9) AS a, MIN(salary{f}#14) AS b, emp_no{f}#9]]
      *   \_EsRelation[test][_meta_field{f}#15, emp_no{f}#9, first_name{f}#10, g..]
-     * }
-     * 
+ * }
*/ public void testIsNotNullConstraintForStatsWithMultiAggWithAndOnGrouping() { var plan = optimizedPlan(""" @@ -4598,15 +4417,13 @@ public void testIsNotNullConstraintForStatsWithMultiAggWithAndOnGrouping() { /** * Expects - *
-     * {@code
+     * 
{@code
      * Limit[1000[INTEGER]]
      * \_Aggregate[[w{r}#14, g{r}#16],[COUNT(b{r}#24) AS c, w{r}#14, gender{f}#32 AS g]]
      *   \_Eval[[emp_no{f}#30 / 10[INTEGER] AS x, x{r}#4 + salary{f}#35 AS y, y{r}#8 / 4[INTEGER] AS z, z{r}#11 * 2[INTEGER] +
      *  3[INTEGER] AS w, salary{f}#35 + 4[INTEGER] / 2[INTEGER] AS a, a{r}#21 + 3[INTEGER] AS b]]
      *     \_EsRelation[test][_meta_field{f}#36, emp_no{f}#30, first_name{f}#31, ..]
-     * }
-     * 
+ * }
*/ public void testIsNotNullConstraintForAliasedExpressions() { var plan = optimizedPlan(""" @@ -4630,13 +4447,11 @@ public void testIsNotNullConstraintForAliasedExpressions() { /** * Expects - *
-     * {@code
+     * 
{@code
      * Limit[1000[INTEGER]]
      * \_Aggregate[[],[SPATIALCENTROID(location{f}#9) AS centroid]]
      *   \_EsRelation[airports][abbrev{f}#5, location{f}#9, name{f}#6, scalerank{f}..]
-     * }
-     * 
+ * }
*/ public void testSpatialTypesAndStatsUseDocValues() { var plan = planAirports(""" @@ -4659,13 +4474,11 @@ public void testSpatialTypesAndStatsUseDocValues() { /** * Expects - *
-     * {@code
+     * 
{@code
      * Limit[1000[INTEGER]]
      * \_Aggregate[[],[SPATIALCENTROID(location{f}#9) AS centroid]]
      *   \_EsRelation[airports][abbrev{f}#5, location{f}#9, name{f}#6, scalerank{f}..]
-     * }
-     * 
+ * }
*/ public void testSpatialTypesAndStatsUseDocValuesWithEval() { var plan = planAirports(""" @@ -4688,13 +4501,11 @@ public void testSpatialTypesAndStatsUseDocValuesWithEval() { /** * Expects: - *
-     * {@code
+     * 
{@code
      * Eval[[types.type{f}#5 AS new_types.type]]
      * \_Limit[1000[INTEGER]]
      *   \_EsRelation[test][_meta_field{f}#11, emp_no{f}#5, first_name{f}#6, ge..]
-     * }
-     * 
+ * }
* NOTE: The convert function to_type is removed, since the types match * This does not work for to_string(text) since that converts text to keyword */ @@ -4720,14 +4531,12 @@ public void testTrivialTypeConversionWrittenAway() { /** * Expects - *
-     * {@code
+     * 
{@code
      * Limit[1000[INTEGER]]
      * \_Aggregate[[emp_no%2{r}#6],[COUNT(salary{f}#12) AS c, emp_no%2{r}#6]]
      *   \_Eval[[emp_no{f}#7 % 2[INTEGER] AS emp_no%2]]
      *     \_EsRelation[test][_meta_field{f}#13, emp_no{f}#7, first_name{f}#8, ge..]
-     * }
-     * 
+ * }
*/ public void testNestedExpressionsInGroups() { var plan = optimizedPlan(""" @@ -4749,15 +4558,13 @@ public void testNestedExpressionsInGroups() { /** * Expects - *
-     * {@code
+     * 
{@code
      * Limit[1000[INTEGER],false]
      * \_Aggregate[[CATEGORIZE($$CONCAT(first_na>$CATEGORIZE(CONC>$0{r$}#1590) AS CATEGORIZE(CONCAT(first_name, "abc"))],[COUNT(sa
      * lary{f}#1584,true[BOOLEAN]) AS c, CATEGORIZE(CONCAT(first_name, "abc")){r}#1574]]
      *   \_Eval[[CONCAT(first_name{f}#1580,[61 62 63][KEYWORD]) AS $$CONCAT(first_na>$CATEGORIZE(CONC>$0]]
      *     \_EsRelation[test][_meta_field{f}#1585, emp_no{f}#1579, first_name{f}#..]
-     * }
-     * 
+ * }
*/ public void testNestedExpressionsInGroupsWithCategorize() { var plan = optimizedPlan(""" @@ -4786,14 +4593,12 @@ public void testNestedExpressionsInGroupsWithCategorize() { /** * Expects - *
-     * {@code
+     * 
{@code
      * Limit[1000[INTEGER]]
      * \_Aggregate[[emp_no{f}#6],[COUNT(__c_COUNT@1bd45f36{r}#16) AS c, emp_no{f}#6]]
      *   \_Eval[[salary{f}#11 + 1[INTEGER] AS __c_COUNT@1bd45f36]]
      *     \_EsRelation[test][_meta_field{f}#12, emp_no{f}#6, first_name{f}#7, ge..]
-     * }
-     * 
+ * }
*/ public void testNestedExpressionsInAggs() { var plan = optimizedPlan(""" @@ -4815,15 +4620,13 @@ public void testNestedExpressionsInAggs() { } /** - *
-     * {@code
+     * 
{@code
      * Limit[1000[INTEGER]]
      * \_Aggregate[[emp_no%2{r}#7],[COUNT(__c_COUNT@fb7855b0{r}#18) AS c, emp_no%2{r}#7]]
      *   \_Eval[[emp_no{f}#8 % 2[INTEGER] AS emp_no%2, 100[INTEGER] / languages{f}#11 + salary{f}#13 + 1[INTEGER] AS __c_COUNT
      * @fb7855b0]]
      *     \_EsRelation[test][_meta_field{f}#14, emp_no{f}#8, first_name{f}#9, ge..]
-     * }
-     * 
+ * }
*/ public void testNestedExpressionsInBothAggsAndGroups() { var plan = optimizedPlan(""" @@ -4865,14 +4668,12 @@ public void testNestedMultiExpressionsInGroupingAndAggs() { /** * Expects - *
-     * {@code
+     * 
{@code
      * Limit[1000[INTEGER]]
      * \_Aggregate[[g{r}#8],[COUNT($$emp_no_%_2_+_la>$COUNT$0{r}#20) AS c, g{r}#8]]
      *   \_Eval[[emp_no{f}#10 % 2[INTEGER] AS g, languages{f}#13 + emp_no{f}#10 % 2[INTEGER] AS $$emp_no_%_2_+_la>$COUNT$0]]
      *     \_EsRelation[test][_meta_field{f}#16, emp_no{f}#10, first_name{f}#11, ..]
-     * }
-     * 
+ * }
*/ public void testNestedExpressionsWithGroupingKeyInAggs() { var plan = optimizedPlan(""" @@ -4904,16 +4705,14 @@ public void testNestedExpressionsWithGroupingKeyInAggs() { /** * Expects - *
-     * {@code
+     * 
{@code
      * Limit[1000[INTEGER]]
      * \_Aggregate[[emp_no % 2{r}#12, languages + salary{r}#15],[MAX(languages + salary{r}#15) AS m, COUNT($$languages_+_sal>$COUN
      * T$0{r}#28) AS c, emp_no % 2{r}#12, languages + salary{r}#15]]
      *   \_Eval[[emp_no{f}#18 % 2[INTEGER] AS emp_no % 2, languages{f}#21 + salary{f}#23 AS languages + salary, languages{f}#2
      * 1 + salary{f}#23 + emp_no{f}#18 % 2[INTEGER] AS $$languages_+_sal>$COUNT$0]]
      *     \_EsRelation[test][_meta_field{f}#24, emp_no{f}#18, first_name{f}#19, ..]
-     * }
-     * 
+ * }
*/ @AwaitsFix(bugUrl = "disabled since canonical representation relies on hashing which is runtime defined") public void testNestedExpressionsWithMultiGrouping() { @@ -4954,8 +4753,7 @@ public void testNestedExpressionsWithMultiGrouping() { /** * Expects - *
-     * {@code
+     * 
{@code
      * Project[[e{r}#5, languages + emp_no{r}#8]]
      * \_Eval[[$$MAX$max(languages_+>$0{r}#20 + 1[INTEGER] AS e]]
      *   \_Limit[1000[INTEGER]]
@@ -4963,8 +4761,7 @@ public void testNestedExpressionsWithMultiGrouping() {
      * r}#8]]
      *       \_Eval[[languages{f}#13 + emp_no{f}#10 AS languages + emp_no]]
      *         \_EsRelation[test][_meta_field{f}#16, emp_no{f}#10, first_name{f}#11, ..]
-     * }
-     * 
+ * }
*/ public void testNestedExpressionsInStatsWithExpression() { var plan = optimizedPlan(""" @@ -5010,16 +4807,14 @@ public void testBucketFailsOnFieldArgument() { } /** - *
-     * {@code
+     * 
{@code
      * Project[[bucket(salary, 1000.) + 1{r}#3, bucket(salary, 1000.){r}#5]]
      *  \_Eval[[bucket(salary, 1000.){r}#5 + 1[INTEGER] AS bucket(salary, 1000.) + 1]]
      *    \_Limit[1000[INTEGER]]
      *      \_Aggregate[[bucket(salary, 1000.){r}#5],[bucket(salary, 1000.){r}#5]]
      *        \_Eval[[BUCKET(salary{f}#12,1000.0[DOUBLE]) AS bucket(salary, 1000.)]]
      *          \_EsRelation[test][_meta_field{f}#13, emp_no{f}#7, first_name{f}#8, ge..]
-     * }
-     * 
+ * }
*/ public void testBucketWithAggExpression() { var plan = plan(""" @@ -5096,8 +4891,7 @@ private String typesError(String query) { /** * Expects - *
-     * {@code
+     * 
{@code
      * Project[[x{r}#5]]
      * \_Eval[[____x_AVG@9efc3cf3_SUM@daf9f221{r}#18 / ____x_AVG@9efc3cf3_COUNT@53cd08ed{r}#19 AS __x_AVG@9efc3cf3, __x_AVG@
      * 9efc3cf3{r}#16 / 2[INTEGER] + __x_MAX@475d0e4d{r}#17 AS x]]
@@ -5105,8 +4899,7 @@ private String typesError(String query) {
      *     \_Aggregate[[],[SUM(salary{f}#11) AS ____x_AVG@9efc3cf3_SUM@daf9f221, COUNT(salary{f}#11) AS ____x_AVG@9efc3cf3_COUNT@53cd0
      * 8ed, MAX(salary{f}#11) AS __x_MAX@475d0e4d]]
      *       \_EsRelation[test][_meta_field{f}#12, emp_no{f}#6, first_name{f}#7, ge..]
-     * }
-     * 
+ * }
*/ public void testStatsExpOverAggs() { var plan = optimizedPlan(""" @@ -5137,8 +4930,7 @@ public void testStatsExpOverAggs() { /** * Expects - *
-     * {@code
+     * 
{@code
      * Project[[x{r}#5, y{r}#9, z{r}#12]]
      * \_Eval[[$$SUM$$$AVG$avg(salary_%_3)>$0$0{r}#29 / $$COUNT$$$AVG$avg(salary_%_3)>$0$1{r}#30 AS $$AVG$avg(salary_%_3)>$0,
      *   $$AVG$avg(salary_%_3)>$0{r}#23 + $$MAX$avg(salary_%_3)>$1{r}#24 AS x,
@@ -5153,8 +4945,7 @@ public void testStatsExpOverAggs() {
      *       salary{f}#18 % 3[INTEGER] AS $$salary_%_3$AVG$0,
      *       emp_no{f}#13 / 3[INTEGER] AS $$emp_no_/_3$MIN$1]]
      *         \_EsRelation[test][_meta_field{f}#19, emp_no{f}#13, first_name{f}#14, ..]
-     * }
-     * 
+ * }
*/ public void testStatsExpOverAggsMulti() { var plan = optimizedPlan(""" @@ -5197,8 +4988,7 @@ public void testStatsExpOverAggsMulti() { /** * Expects - *
-     * {@code
+     * 
{@code
      * Project[[x{r}#5, y{r}#9, z{r}#12]]
      * \_Eval[[$$SUM$$$AVG$CONCAT(TO_STRIN>$0$0{r}#29 / $$COUNT$$$AVG$CONCAT(TO_STRIN>$0$1{r}#30 AS $$AVG$CONCAT(TO_STRIN>$0,
      *        CONCAT(TOSTRING($$AVG$CONCAT(TO_STRIN>$0{r}#23),TOSTRING($$MAX$CONCAT(TO_STRIN>$1{r}#24)) AS x,
@@ -5214,8 +5004,7 @@ public void testStatsExpOverAggsMulti() {
      *       salary{f}#18 % 3[INTEGER] AS $$salary_%_3$AVG$0,
      *       emp_no{f}#13 / 3[INTEGER] AS $$emp_no_/_3$MIN$1]]
      *         \_EsRelation[test][_meta_field{f}#19, emp_no{f}#13, first_name{f}#14, ..]
-     * }
-     * 
+ * }
*/ public void testStatsExpOverAggsWithScalars() { var plan = optimizedPlan(""" @@ -5263,8 +5052,7 @@ public void testStatsExpOverAggsWithScalars() { /** * Expects - *
-     * {@code
+     * 
{@code
      * Project[[a{r}#5, b{r}#9, $$max(salary)_+_3>$COUNT$2{r}#46 AS d, $$count(salary)_->$MIN$3{r}#47 AS e, $$avg(salary)_+_m
      * >$MAX$1{r}#45 AS g]]
      * \_Eval[[$$$$avg(salary)_+_m>$AVG$0$SUM$0{r}#48 / $$max(salary)_+_3>$COUNT$2{r}#46 AS $$avg(salary)_+_m>$AVG$0, $$avg(
@@ -5275,8 +5063,7 @@ public void testStatsExpOverAggsWithScalars() {
      * , COUNT(salary{f}#39) AS $$max(salary)_+_3>$COUNT$2, MIN(salary{f}#39) AS $$count(salary)_->$MIN$3]]
      *       \_Eval[[languages{f}#37 % 2[INTEGER] AS w]]
      *         \_EsRelation[test][_meta_field{f}#40, emp_no{f}#34, first_name{f}#35, ..]
-     * }
-     * 
+ * }
*/ public void testStatsExpOverAggsWithScalarAndDuplicateAggs() { var plan = optimizedPlan(""" @@ -5338,15 +5125,13 @@ public void testStatsExpOverAggsWithScalarAndDuplicateAggs() { /** * Expects - *
-     * {@code
+     * 
{@code
      * Project[[a{r}#5, a{r}#5 AS b, w{r}#12]]
      * \_Limit[1000[INTEGER]]
      *   \_Aggregate[[w{r}#12],[SUM($$salary_/_2_+_la>$SUM$0{r}#26) AS a, w{r}#12]]
      *     \_Eval[[emp_no{f}#16 % 2[INTEGER] AS w, salary{f}#21 / 2[INTEGER] + languages{f}#19 AS $$salary_/_2_+_la>$SUM$0]]
      *       \_EsRelation[test][_meta_field{f}#22, emp_no{f}#16, first_name{f}#17, ..]
-     * }
-     * 
+ * }
*/ public void testStatsWithCanonicalAggregate() throws Exception { var plan = optimizedPlan(""" @@ -5378,8 +5163,7 @@ public void testStatsWithCanonicalAggregate() throws Exception { /** * Expects after running the {@link LogicalPlanOptimizer#substitutions()}: * - *
-     * {@code
+     * 
{@code
      * Limit[1000[INTEGER]]
      * \_EsqlProject[[s{r}#3, s_expr{r}#5, s_null{r}#7, w{r}#10]]
      *   \_Project[[s{r}#3, s_expr{r}#5, s_null{r}#7, w{r}#10]]
@@ -5388,8 +5172,7 @@ public void testStatsWithCanonicalAggregate() throws Exception {
      *       \_Aggregate[[w{r}#10],[COUNT(*[KEYWORD]) AS $$COUNT$s$0, w{r}#10]]
      *         \_Eval[[emp_no{f}#16 % 2[INTEGER] AS w]]
      *           \_EsRelation[test][_meta_field{f}#22, emp_no{f}#16, first_name{f}#17, ..]
-     * }
-     * 
+ * }
*/ public void testCountOfLiteral() { var plan = plan(""" @@ -5452,8 +5235,7 @@ public void testCountOfLiteral() { /** * Expects after running the {@link LogicalPlanOptimizer#substitutions()}: * - *
-     * {@code
+     * 
{@code
      * Limit[1000[INTEGER]]
      * \_EsqlProject[[s{r}#3, s_expr{r}#5, s_null{r}#7, w{r}#10]]
      *   \_Project[[s{r}#3, s_expr{r}#5, s_null{r}#7, w{r}#10]]
@@ -5462,8 +5244,7 @@ public void testCountOfLiteral() {
      *       \_Aggregate[[w{r}#10],[COUNT(*[KEYWORD]) AS $$COUNT$s$0, w{r}#10]]
      *         \_Eval[[emp_no{f}#15 % 2[INTEGER] AS w]]
      *           \_EsRelation[test][_meta_field{f}#21, emp_no{f}#15, first_name{f}#16, ..]
-     * }
-     * 
+ * }
*/ public void testSumOfLiteral() { var plan = plan(""" @@ -5554,15 +5335,13 @@ private record AggOfLiteralTestCase( *

* Expects after running the {@link LogicalPlanOptimizer#substitutions()}: * - *

-     * {@code
+     * 
{@code
      * Limit[1000[INTEGER]]
      * \_EsqlProject[[s{r}#3, s_expr{r}#5, s_null{r}#7]]
      *   \_Project[[s{r}#3, s_expr{r}#5, s_null{r}#7]]
      *     \_Eval[[MVAVG([1, 2][INTEGER]) AS s, MVAVG(314.0[DOUBLE] / 100[INTEGER]) AS s_expr, MVAVG(null[NULL]) AS s_null]]
      *       \_LocalRelation[[{e}#21],[ConstantNullBlock[positions=1]]]
-     * }
-     * 
+ * }
*/ public void testAggOfLiteral() { for (AggOfLiteralTestCase testCase : AGG_OF_CONST_CASES) { @@ -5602,16 +5381,14 @@ public void testAggOfLiteral() { *

* Expects after running the {@link LogicalPlanOptimizer#substitutions()}: * - *

-     * {@code
+     * 
{@code
      * Limit[1000[INTEGER]]
      * \_EsqlProject[[s{r}#3, s_expr{r}#5, s_null{r}#7, emp_no{f}#13]]
      *   \_Project[[s{r}#3, s_expr{r}#5, s_null{r}#7, emp_no{f}#13]]
      *     \_Eval[[MVAVG([1, 2][INTEGER]) AS s, MVAVG(314.0[DOUBLE] / 100[INTEGER]) AS s_expr, MVAVG(null[NULL]) AS s_null]]
      *       \_Aggregate[[emp_no{f}#13],[emp_no{f}#13]]
      *         \_EsRelation[test][_meta_field{f}#19, emp_no{f}#13, first_name{f}#14, ..]
-     * }
-     * 
+ * }
*/ public void testAggOfLiteralGrouped() { for (AggOfLiteralTestCase testCase : AGG_OF_CONST_CASES) { @@ -5761,8 +5538,7 @@ public void testPlanSanityCheck() throws Exception { /** * Before we alter the plan to make it invalid, we expect * - *
-     * {@code
+     * 
{@code
      * Project[[_meta_field{f}#12, emp_no{f}#6, first_name{f}#7, gender{f}#8, hire_date{f}#13, job{f}#14, job.raw{f}#15,
      *          languages{f}#9 AS language_code#4, last_name{f}#10, long_noidx{f}#16, salary{f}#11, language_name{f}#18]]
      * \_Limit[1000[INTEGER],true]
@@ -5770,8 +5546,7 @@ public void testPlanSanityCheck() throws Exception {
      *     |_Limit[1000[INTEGER],false]
      *     | \_EsRelation[test][_meta_field{f}#12, emp_no{f}#6, first_name{f}#7, ge..]
      *     \_EsRelation[languages_lookup][LOOKUP][language_code{f}#17, language_name{f}#18]
-     * }
-     * 
+ * }
*/ public void testPlanSanityCheckWithBinaryPlans() { assumeTrue("Requires LOOKUP JOIN", EsqlCapabilities.Cap.JOIN_LOOKUP_V12.isEnabled()); @@ -5817,16 +5592,14 @@ public void testNoWrongIsNotNullPruning() { *

* For DISSECT expects the following; the others are similar. * - *

-     * {@code
+     * 
{@code
      * Project[[first_name{f}#37, emp_no{r}#30, salary{r}#31]]
      * \_TopN[[Order[$$order_by$temp_name$0{r}#46,ASC,LAST], Order[$$order_by$temp_name$1{r}#47,DESC,FIRST]],3[INTEGER]]
      *   \_Dissect[first_name{f}#37,Parser[pattern=%{emp_no} %{salary}, appendSeparator=,
      *   parser=org.elasticsearch.dissect.DissectParser@87f460f],[emp_no{r}#30, salary{r}#31]]
      *     \_Eval[[emp_no{f}#36 + salary{f}#41 * 13[INTEGER] AS $$order_by$temp_name$0, NEG(salary{f}#41) AS $$order_by$temp_name$1]]
      *       \_EsRelation[test][_meta_field{f}#42, emp_no{f}#36, first_name{f}#37, ..]
-     * }
-     * 
+ * }
*/ public void testPushdownWithOverwrittenName() { List overwritingCommands = List.of( @@ -5999,23 +5772,19 @@ record PushdownShadowingGeneratingPlanTestCase( /** * Consider * - *
-     * {@code
+     * 
{@code
      * Eval[[TO_INTEGER(x{r}#2) AS y, y{r}#4 + 1[INTEGER] AS y]]
      * \_Project[[y{r}#3, x{r}#2]]
      * \_Row[[1[INTEGER] AS x, 2[INTEGER] AS y]]
-     * }
-     * 
+ * }
* * We can freely push down the Eval without renaming, but need to update the Project's references. * - *
-     * {@code
+     * 
{@code
      * Project[[x{r}#2, y{r}#6 AS y]]
      * \_Eval[[TO_INTEGER(x{r}#2) AS y, y{r}#4 + 1[INTEGER] AS y]]
      * \_Row[[1[INTEGER] AS x, 2[INTEGER] AS y]]
-     * }
-     * 
+ * }
* * And similarly for dissect, grok and enrich. */ @@ -6054,23 +5823,19 @@ public void testPushShadowingGeneratingPlanPastProject() { /** * Consider * - *
-     * {@code
+     * 
{@code
      * Eval[[TO_INTEGER(x{r}#2) AS y, y{r}#4 + 1[INTEGER] AS y]]
      * \_Project[[x{r}#2, y{r}#3, y{r}#3 AS z]]
      * \_Row[[1[INTEGER] AS x, 2[INTEGER] AS y]]
-     * }
-     * 
+ * }
* * To push down the Eval, we must not shadow the reference y{r}#3, so we rename. * - *
-     * {@code
+     * 
{@code
      * Project[[x{r}#2, y{r}#3 AS z, $$y$temp_name$10{r}#12 AS y]]
      * Eval[[TO_INTEGER(x{r}#2) AS $$y$temp_name$10, $$y$temp_name$10{r}#11 + 1[INTEGER] AS $$y$temp_name$10]]
      * \_Row[[1[INTEGER] AS x, 2[INTEGER] AS y]]
-     * }
-     * 
+ * }
* * And similarly for dissect, grok and enrich. */ @@ -6119,24 +5884,20 @@ public void testPushShadowingGeneratingPlanPastRenamingProject() { /** * Consider * - *
-     * {@code
+     * 
{@code
      * Eval[[TO_INTEGER(x{r}#2) AS y, y{r}#3 + 1[INTEGER] AS y]]
      * \_Project[[y{r}#1, y{r}#1 AS x]]
      * \_Row[[2[INTEGER] AS y]]
-     * }
-     * 
+ * }
* * To push down the Eval, we must not shadow the reference y{r}#1, so we rename. * Additionally, the rename "y AS x" needs to be propagated into the Eval. * - *
-     * {@code
+     * 
{@code
      * Project[[y{r}#1 AS x, $$y$temp_name$10{r}#12 AS y]]
      * Eval[[TO_INTEGER(y{r}#1) AS $$y$temp_name$10, $$y$temp_name$10{r}#11 + 1[INTEGER] AS $$y$temp_name$10]]
      * \_Row[[2[INTEGER] AS y]]
-     * }
-     * 
+ * }
* * And similarly for dissect, grok and enrich. */ @@ -6180,15 +5941,13 @@ public void testPushShadowingGeneratingPlanPastRenamingProjectWithResolution() { /** * Expects - *
-     * {@code
+     * 
{@code
      * Project[[min{r}#4, languages{f}#11]]
      * \_TopN[[Order[$$order_by$temp_name$0{r}#18,ASC,LAST]],1000[INTEGER]]
      *   \_Eval[[min{r}#4 + languages{f}#11 AS $$order_by$temp_name$0]]
      *     \_Aggregate[[languages{f}#11],[MIN(salary{f}#13) AS min, languages{f}#11]]
      *       \_EsRelation[test][_meta_field{f}#14, emp_no{f}#8, first_name{f}#9, ge..]
-     * }
-     * 
+ * }
*/ public void testReplaceSortByExpressionsWithStats() { var plan = optimizedPlan(""" @@ -6220,8 +5979,7 @@ public void testReplaceSortByExpressionsWithStats() { } /** - *
-     * {@code
+     * 
{@code
      * Limit[1000[INTEGER],true]
      * \_InlineJoin[LEFT,[emp_no % 2{r}#6],[emp_no % 2{r}#6],[emp_no % 2{r}#6]]
      *   |_Eval[[emp_no{f}#7 % 2[INTEGER] AS emp_no % 2#6]]
@@ -6230,8 +5988,7 @@ public void testReplaceSortByExpressionsWithStats() {
      *   \_Aggregate[[emp_no % 2{r}#6],[COUNT(salary{f}#12,true[BOOLEAN]) AS c#4, emp_no % 2{r}#6]]
      *     \_StubRelation[[_meta_field{f}#13, emp_no{f}#7, first_name{f}#8, gender{f}#9, hire_date{f}#14, job{f}#15, job.raw{f}#16, lang
      *          uages{f}#10, last_name{f}#11, long_noidx{f}#17, salary{f}#12, emp_no % 2{r}#6]]
-     * }
-     * 
+ * }
*/ public void testInlinestatsNestedExpressionsInGroups() { var query = """ @@ -6267,13 +6024,11 @@ private static boolean releaseBuildForInlinestats(String query) { } /** - *
-     * {@code
+     * 
{@code
      * Project[[emp_no{f}#12 AS x#8, emp_no{f}#12]]
      * \_TopN[[Order[emp_no{f}#12,ASC,LAST]],1[INTEGER]]
      *   \_EsRelation[test][_meta_field{f}#18, emp_no{f}#12, first_name{f}#13, ..]
-     * }
-     * 
+ * }
*/ public void testInlinestatsGetsPrunedEntirely() { var query = """ @@ -6321,8 +6076,7 @@ public void testDoubleInlinestatsGetsPrunedEntirely() { } /** - *
-     * {@code
+     * 
{@code
      * Project[[emp_no{f}#15 AS x#11, a{r}#7, emp_no{f}#15]]
      * \_Limit[1[INTEGER],true]
      *   \_InlineJoin[LEFT,[emp_no{f}#15],[emp_no{f}#15],[emp_no{r}#15]]
@@ -6331,8 +6085,7 @@ public void testDoubleInlinestatsGetsPrunedEntirely() {
      *     \_Aggregate[[emp_no{f}#15],[COUNTDISTINCT(languages{f}#18,true[BOOLEAN]) AS a#7, emp_no{f}#15]]
      *       \_StubRelation[[_meta_field{f}#21, emp_no{f}#15, first_name{f}#16, gender{f}#17, hire_date{f}#22, job{f}#23, job.raw{f}#24, l
      *          anguages{f}#18, last_name{f}#19, long_noidx{f}#25, salary{f}#20]]
-     * }
-     * 
+ * }
*/ public void testInlinestatsGetsPrunedPartially() { var query = """ @@ -6394,15 +6147,13 @@ public void testTrippleInlinestatsGetsPrunedPartially() { } /** - *
-     * {@code
+     * 
{@code
      * Project[[abbrev{f}#19, scalerank{f}#21 AS backup_scalerank#4, language_name{f}#28 AS scalerank#11]]
      * \_TopN[[Order[abbrev{f}#19,DESC,FIRST]],5[INTEGER]]
      *   \_Join[LEFT,[scalerank{f}#21],[scalerank{f}#21],[language_code{f}#27]]
      *     |_EsRelation[airports][abbrev{f}#19, city{f}#25, city_location{f}#26, coun..]
      *     \_EsRelation[languages_lookup][LOOKUP][language_code{f}#27, language_name{f}#28]
-     * }
-     * 
+ * }
*/ public void testInlinestatsWithLookupJoin() { var query = """ @@ -6440,8 +6191,7 @@ public void testInlinestatsWithLookupJoin() { } /** - *
-     * {@code
+     * 
{@code
      * EsqlProject[[avg{r}#4, emp_no{f}#9, first_name{f}#10]]
      * \_Limit[10[INTEGER],true]
      *   \_InlineJoin[LEFT,[emp_no{f}#9],[emp_no{f}#9],[emp_no{r}#9]]
@@ -6453,8 +6203,7 @@ public void testInlinestatsWithLookupJoin() {
      *              avg$1#21, emp_no{f}#9]]
      *           \_StubRelation[[_meta_field{f}#15, emp_no{f}#9, first_name{f}#10, gender{f}#11, hire_date{f}#16, job{f}#17, job.raw{f}#18,
      *              languages{f}#12, last_name{f}#13, long_noidx{f}#19, salary{f}#14]]
-     * }
-     * 
+ * }
*/ public void testInlinestatsWithAvg() { var query = """ @@ -6487,14 +6236,12 @@ public void testInlinestatsWithAvg() { } /** - *
-     * {@code
+     * 
{@code
      * EsqlProject[[emp_no{r}#5]]
      * \_Limit[1000[INTEGER],false]
      *   \_LocalRelation[[salary{r}#3, emp_no{r}#5, gender{r}#7],
      *      org.elasticsearch.xpack.esql.plan.logical.local.CopyingLocalSupplier@9d5b596d]
-     * }
-     * 
+ * }
*/ public void testInlinestatsWithRow() { var query = """ @@ -6525,14 +6272,12 @@ public void testInlinestatsWithRow() { /** * Expects * - *
-     * {@code
+     * 
{@code
      * Project[[salary{f}#19, languages{f}#17, emp_no{f}#14]]
      * \_TopN[[Order[$$order_by$0$0{r}#24,ASC,LAST], Order[emp_no{f}#14,DESC,FIRST]],1000[INTEGER]]
      *   \_Eval[[salary{f}#19 / 10000[INTEGER] + languages{f}#17 AS $$order_by$0$0]]
      *     \_EsRelation[test][_meta_field{f}#20, emp_no{f}#14, first_name{f}#15, ..]
-     * }
-     * 
+ * }
*/ public void testReplaceSortByExpressionsMultipleSorts() { var plan = optimizedPlan(""" @@ -6580,16 +6325,14 @@ public void testReplaceSortByExpressionsMultipleSorts() { /** * For DISSECT expects the following; the others are similar. * - *
-     * {@code
+     * 
{@code
      * Project[[first_name{f}#37, emp_no{r}#30, salary{r}#31]]
      * \_TopN[[Order[$$order_by$temp_name$0{r}#46,ASC,LAST], Order[$$order_by$temp_name$1{r}#47,DESC,FIRST]],3[INTEGER]]
      *   \_Dissect[first_name{f}#37,Parser[pattern=%{emp_no} %{salary}, appendSeparator=,
      *   parser=org.elasticsearch.dissect.DissectParser@87f460f],[emp_no{r}#30, salary{r}#31]]
      *     \_Eval[[emp_no{f}#36 + salary{f}#41 * 13[INTEGER] AS $$order_by$temp_name$0, NEG(salary{f}#41) AS $$order_by$temp_name$1]]
      *       \_EsRelation[test][_meta_field{f}#42, emp_no{f}#36, first_name{f}#37, ..]
-     * }
-     * 
+ * }
*/ public void testReplaceSortByExpressions() { List overwritingCommands = List.of( @@ -6960,8 +6703,7 @@ protected List filteredWarnings() { /** * Expects - *
-     * {@code
+     * 
{@code
      * Join[JoinConfig[type=LEFT OUTER, matchFields=[int{r}#4], conditions=[LOOKUP int_number_names ON int]]]
      * |_EsqlProject[[_meta_field{f}#12, emp_no{f}#6, first_name{f}#7, gender{f}#8, job{f}#13, job.raw{f}#14, languages{f}#9 AS int
      * , last_name{f}#10, long_noidx{f}#15, salary{f}#11]]
@@ -6969,8 +6711,7 @@ protected List filteredWarnings() {
      * |   \_EsRelation[test][_meta_field{f}#12, emp_no{f}#6, first_name{f}#7, ge..]
      * \_LocalRelation[[int{f}#16, name{f}#17],[IntVectorBlock[vector=IntArrayVector[positions=10, values=[0, 1, 2, 3, 4, 5, 6, 7, 8,
      * 9]]], BytesRefVectorBlock[vector=BytesRefArrayVector[positions=10]]]]
-     * }
-     * 
+ * }
*/ @AwaitsFix(bugUrl = "lookup functionality is not yet implemented") public void testLookupSimple() { @@ -7041,8 +6782,7 @@ public void testLookupSimple() { /** * Expects - *
-     * {@code
+     * 
{@code
      * Limit[1000[INTEGER]]
      * \_Aggregate[[name{r}#20],[MIN(emp_no{f}#9) AS MIN(emp_no), name{r}#20]]
      *   \_Join[JoinConfig[type=LEFT OUTER, matchFields=[int{r}#4], conditions=[LOOKUP int_number_names ON int]]]
@@ -7051,8 +6791,7 @@ public void testLookupSimple() {
      *     | \_EsRelation[test][_meta_field{f}#15, emp_no{f}#9, first_name{f}#10, g..]
      *     \_LocalRelation[[int{f}#19, name{f}#20],[IntVectorBlock[vector=IntArrayVector[positions=10, values=[0, 1, 2, 3, 4, 5, 6, 7, 8,
      * 9]]], BytesRefVectorBlock[vector=BytesRefArrayVector[positions=10]]]]
-     * }
-     * 
+ * }
*/ @AwaitsFix(bugUrl = "lookup functionality is not yet implemented") public void testLookupStats() { @@ -7137,8 +6876,7 @@ public void testLookupStats() { *

* Expects * - *

-     * {@code
+     * 
{@code
      * Project[[_meta_field{f}#13, emp_no{f}#7, first_name{f}#8, gender{f}#9, hire_date{f}#14, job{f}#15, job.raw{f}#16,
      *          languages{f}#10 AS language_code#4, last_name{f}#11, long_noidx{f}#17, salary{f}#12, language_name{f}#19]]
      * \_Limit[1000[INTEGER],true]
@@ -7147,8 +6885,7 @@ public void testLookupStats() {
      *     | \_Filter[languages{f}#10 > 1[INTEGER]]
      *     |   \_EsRelation[test][_meta_field{f}#13, emp_no{f}#7, first_name{f}#8, ge..]
      *     \_EsRelation[languages_lookup][LOOKUP][language_code{f}#18, language_name{f}#19]
-     * }
-     * 
+ * }
*/ public void testLookupJoinPushDownFilterOnJoinKeyWithRename() { assumeTrue("Requires LOOKUP JOIN", EsqlCapabilities.Cap.JOIN_LOOKUP_V12.isEnabled()); @@ -7183,8 +6920,7 @@ public void testLookupJoinPushDownFilterOnJoinKeyWithRename() { * Filter on on left side fields (outside the join key) should be pushed down * Expects * - *
-     * {@code
+     * 
{@code
      * Project[[_meta_field{f}#13, emp_no{f}#7, first_name{f}#8, gender{f}#9, hire_date{f}#14, job{f}#15, job.raw{f}#16,
      *          languages{f}#10 AS language_code#4, last_name{f}#11, long_noidx{f}#17, salary{f}#12, language_name{f}#19]]
      * \_Limit[1000[INTEGER],true]
@@ -7194,8 +6930,7 @@ public void testLookupJoinPushDownFilterOnJoinKeyWithRename() {
      *     |   \_EsRelation[test][_meta_field{f}#13, emp_no{f}#7, first_name{f}#8, ge..]
      *     \_EsRelation[languages_lookup][LOOKUP][language_code{f}#18, language_name{f}#19]
      *
-     * }
-     * 
+ * }
*/ public void testLookupJoinPushDownFilterOnLeftSideField() { assumeTrue("Requires LOOKUP JOIN", EsqlCapabilities.Cap.JOIN_LOOKUP_V12.isEnabled()); @@ -7232,8 +6967,7 @@ public void testLookupJoinPushDownFilterOnLeftSideField() { *

* Expects * - *

-     * {@code
+     * 
{@code
      * Project[[_meta_field{f}#13, emp_no{f}#7, first_name{f}#8, gender{f}#9, hire_date{f}#14, job{f}#15, job.raw{f}#16,
      *          languages{f}#10 AS language_code#4, last_name{f}#11, long_noidx{f}#17, salary{f}#12, language_name{f}#19]]
      * \_Limit[1000[INTEGER],false]
@@ -7241,8 +6975,7 @@ public void testLookupJoinPushDownFilterOnLeftSideField() {
      *     \_Join[LEFT,[languages{f}#10],[languages{f}#10],[language_code{f}#18]]
      *       |_EsRelation[test][_meta_field{f}#13, emp_no{f}#7, first_name{f}#8, ge..]
      *       \_EsRelation[languages_lookup][LOOKUP][language_code{f}#18, language_name{f}#19]
-     * }
-     * 
+ * }
*/ public void testLookupJoinPushDownDisabledForLookupField() { assumeTrue("Requires LOOKUP JOIN", EsqlCapabilities.Cap.JOIN_LOOKUP_V12.isEnabled()); From e70eb5ae38fe5c7021d09c691a0d1f570e4d7341 Mon Sep 17 00:00:00 2001 From: Mark Tozzi Date: Mon, 4 Aug 2025 17:52:47 -0400 Subject: [PATCH 3/3] oops --- .../xpack/esql/optimizer/LogicalPlanOptimizerTests.java | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/optimizer/LogicalPlanOptimizerTests.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/optimizer/LogicalPlanOptimizerTests.java index 50419d4ae11bc..dd48cfac29ea0 100644 --- a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/optimizer/LogicalPlanOptimizerTests.java +++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/optimizer/LogicalPlanOptimizerTests.java @@ -1225,13 +1225,11 @@ public void testCombineProjectionWithCategorizeGrouping() { /** * Expects - *
- * {@code + *
{@code
      * Limit[1000[INTEGER]]
      * \_Aggregate[[first_name{f}#16],[SUM(emp_no{f}#15) AS s, first_name{f}#16 AS f]]
      *   \_EsRelation[test][_meta_field{f}#21, emp_no{f}#15, first_name{f}#16, ..]
-     * }
-     * 
+ * }
*/ public void testCombineProjectionWithAggregationFirstAndAliasedGroupingUnused() { var plan = plan("""