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..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 @@ -232,10 +232,12 @@ public void testEmptyProjectionInStat() { /** * Expects * + *
{@code
* EsqlProject[[x{r}#6]]
* \_Eval[[1[INTEGER] AS x]]
* \_Limit[1000[INTEGER]]
* \_LocalRelation[[{e}#18],[ConstantNullBlock[positions=1]]]
+ * }
*/
public void testEmptyProjectInStatWithEval() {
var plan = plan("""
@@ -263,13 +265,14 @@ 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 +319,11 @@ 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 +342,12 @@ 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 +411,12 @@ 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 +434,11 @@ 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 +466,11 @@ 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 +492,12 @@ 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 +516,12 @@ 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 +535,11 @@ 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 +556,13 @@ 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 +590,14 @@ 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 +625,16 @@ 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 +670,11 @@ 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 +692,13 @@ 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 +727,15 @@ 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 +770,11 @@ 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 +794,15 @@ 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 +1138,11 @@ 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 +1164,11 @@ 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 +1196,11 @@ 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 +1225,11 @@ 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 +1253,12 @@ 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 +1811,11 @@ 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 +1832,13 @@ 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 +1857,14 @@ 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 +1883,13 @@ 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 +1909,14 @@ 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 +1937,7 @@ 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 +1950,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("""
@@ -1931,6 +1988,7 @@ 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 +2003,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("""
@@ -1983,10 +2042,12 @@ 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 +2068,13 @@ 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 +2101,14 @@ 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 +2136,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 +2169,7 @@ 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 +2178,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("""
@@ -2134,11 +2202,13 @@ 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 +2231,13 @@ 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 +2262,13 @@ 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 +2290,7 @@ 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 +2299,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("""
@@ -2247,11 +2323,13 @@ 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 +2352,7 @@ 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 +2363,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("""
@@ -2310,6 +2389,7 @@ 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 +2402,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("""
@@ -2348,9 +2429,11 @@ 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 +2452,13 @@ 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 +2483,13 @@ 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 +2514,13 @@ 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 +2546,12 @@ 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 +2568,13 @@ 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 +2591,12 @@ 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 +2615,7 @@ 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 +2623,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("""
@@ -2546,13 +2643,15 @@ 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 +2668,14 @@ 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 +2692,13 @@ 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 +2720,14 @@ 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 +2747,13 @@ 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 +2770,13 @@ 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 +2801,11 @@ private static List{@code
* Eval[[2[INTEGER] AS x]]
* \_Limit[1000[INTEGER],false]
* \_LocalRelation[[{e}#9],[ConstantNullBlock[positions=1]]]
+ * }
*/
public void testEvalAfterStats() {
var plan = optimizedPlan("""
@@ -2710,10 +2821,12 @@ 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 +3309,14 @@ 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 +3346,13 @@ 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 +3374,14 @@ 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 +3412,11 @@ 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 +3525,11 @@ 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 +3566,11 @@ 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 +3612,13 @@ 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 +3645,12 @@ 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 +3668,12 @@ 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 +3692,11 @@ 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 +3721,11 @@ 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 +3747,11 @@ 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 +3774,11 @@ 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 +3802,11 @@ 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 +3830,12 @@ 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 +3861,12 @@ 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 +3890,12 @@ 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 +3937,11 @@ 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 +3965,13 @@ 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 +3998,13 @@ 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 +4033,12 @@ 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 +4065,11 @@ 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 +4083,12 @@ 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 +4116,11 @@ 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 +4139,12 @@ 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 +4165,11 @@ 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 +4186,11 @@ 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 +4207,11 @@ 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 +4251,11 @@ private {@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 +4285,11 @@ 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 +4306,11 @@ 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 +4328,11 @@ 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 +4352,11 @@ 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 +4373,11 @@ 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 +4394,11 @@ 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 +4415,13 @@ 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 +4445,11 @@ 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 +4472,11 @@ 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 +4499,11 @@ 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 +4529,12 @@ 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 +4556,13 @@ 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 +4591,12 @@ 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 +4618,13 @@ 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 +4666,12 @@ 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 +4703,14 @@ 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 +4751,7 @@ 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 +4759,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("""
@@ -4599,13 +4804,15 @@ 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 +4889,7 @@ 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 +4897,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("""
@@ -4719,6 +4928,7 @@ 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 +4943,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("""
@@ -4775,6 +4986,7 @@ 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 +5002,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("""
@@ -4837,6 +5050,7 @@ 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 +5061,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("""
@@ -4908,11 +5123,13 @@ 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 +5161,7 @@ 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 +5170,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("""
@@ -5014,6 +5233,7 @@ 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 +5242,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("""
@@ -5109,14 +5330,16 @@ 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 +5376,17 @@ 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 +5536,7 @@ 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 +5544,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());
@@ -5361,15 +5587,17 @@ 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{@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 +5821,19 @@ 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 +5882,20 @@ 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 +5939,13 @@ 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 +5976,8 @@ 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 +5986,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 = """
@@ -5777,10 +6021,12 @@ 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 +6073,8 @@ 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 +6083,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 = """
@@ -5896,12 +6144,14 @@ 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 +6188,8 @@ 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 +6201,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 = """
@@ -5981,11 +6233,13 @@ 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 +6270,12 @@ 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 +6323,14 @@ 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{@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]]
@@ -6451,7 +6709,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() {
@@ -6522,7 +6780,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]]]
@@ -6531,7 +6789,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() {
@@ -6613,9 +6871,10 @@ 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 +6883,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());
@@ -6658,6 +6918,7 @@ 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 +6928,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());
@@ -6700,9 +6962,10 @@ 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 +6973,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());
@@ -6742,9 +7006,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 +7018,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 +7059,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 +7070,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 +7113,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 +7124,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 +7157,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 +7169,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 +7204,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 +7882,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 +7891,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 +7917,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 +7943,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 +7951,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 +7973,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 +7981,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 +8004,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 +8015,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 +8041,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 +8054,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 +8084,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 +8093,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 +8121,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 +8131,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 +8246,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 +8341,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 +8369,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());