@@ -1044,10 +1044,12 @@ public void testPushdownLimitsPastLeftJoin() {
10441044
10451045 var optimizedPlan = rule .apply (limit , logicalOptimizerCtx );
10461046
1047- assertEquals (
1048- new Limit (limit .source (), limit .limit (), join .replaceChildren (limit .replaceChild (join .left ()), join .right ()), true ),
1049- optimizedPlan
1050- );
1047+ var expectedPlan = join instanceof InlineJoin
1048+ ? new Limit (limit .source (), limit .limit (), join , false )
1049+ : new Limit (limit .source (), limit .limit (), join .replaceChildren (limit .replaceChild (join .left ()), join .right ()), true );
1050+
1051+
1052+ assertEquals (expectedPlan , optimizedPlan );
10511053
10521054 var optimizedTwice = rule .apply (optimizedPlan , logicalOptimizerCtx );
10531055 // We mustn't create the limit after the JOIN multiple times when the rule is applied multiple times, that'd lead to infinite loops.
@@ -5714,17 +5716,14 @@ public void testReplaceSortByExpressionsWithStats() {
57145716 as (aggregate .child (), EsRelation .class );
57155717 }
57165718
5717- /**
5718- * <pre>{@code
5719- * Limit[1000[INTEGER],true]
5719+ /*
5720+ * Limit[1000[INTEGER],false]
57205721 * \_InlineJoin[LEFT,[emp_no % 2{r}#6],[emp_no % 2{r}#6],[emp_no % 2{r}#6]]
57215722 * |_Eval[[emp_no{f}#7 % 2[INTEGER] AS emp_no % 2#6]]
5722- * | \_Limit[1000[INTEGER],false] <-- TODO: this needs to go
5723- * | \_EsRelation[test][_meta_field{f}#13, emp_no{f}#7, first_name{f}#8, ge..]
5723+ * | \_EsRelation[test][_meta_field{f}#13, emp_no{f}#7, first_name{f}#8, ge..]
57245724 * \_Aggregate[[emp_no % 2{r}#6],[COUNT(salary{f}#12,true[BOOLEAN]) AS c#4, emp_no % 2{r}#6]]
57255725 * \_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
57265726 * uages{f}#10, last_name{f}#11, long_noidx{f}#17, salary{f}#12, emp_no % 2{r}#6]]
5727- * }</pre>
57285727 */
57295728 public void testInlinestatsNestedExpressionsInGroups () {
57305729 var query = """
@@ -5739,7 +5738,7 @@ public void testInlinestatsNestedExpressionsInGroups() {
57395738 var inline = as (limit .child (), InlineJoin .class );
57405739 var eval = as (inline .left (), Eval .class );
57415740 assertThat (Expressions .names (eval .fields ()), is (List .of ("emp_no % 2" )));
5742- limit = asLimit (eval .child (), 1000 , false );
5741+ var relation = as (eval .child (), EsRelation . class );
57435742 var agg = as (inline .right (), Aggregate .class );
57445743 var groupings = agg .groupings ();
57455744 var ref = as (groupings .get (0 ), ReferenceAttribute .class );
@@ -5811,17 +5810,14 @@ public void testDoubleInlinestatsGetsPrunedEntirely() {
58115810 var relation = as (topN .child (), EsRelation .class );
58125811 }
58135812
5814- /**
5815- * <pre>{@code
5813+ /*
58165814 * Project[[emp_no{f}#15 AS x#11, a{r}#7, emp_no{f}#15]]
5817- * \_Limit[1[INTEGER],true ]
5815+ * \_Limit[1[INTEGER],false ]
58185816 * \_InlineJoin[LEFT,[emp_no{f}#15],[emp_no{f}#15],[emp_no{r}#15]]
5819- * |_Limit[1[INTEGER],false] <-- TODO: this needs to go
5820- * | \_EsRelation[test][_meta_field{f}#21, emp_no{f}#15, first_name{f}#16, ..]
5817+ * |_EsRelation[test][_meta_field{f}#21, emp_no{f}#15, first_name{f}#16, ..]
58215818 * \_Aggregate[[emp_no{f}#15],[COUNTDISTINCT(languages{f}#18,true[BOOLEAN]) AS a#7, emp_no{f}#15]]
58225819 * \_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
58235820 * anguages{f}#18, last_name{f}#19, long_noidx{f}#25, salary{f}#20]]
5824- * }</pre>
58255821 */
58265822 public void testInlinestatsGetsPrunedPartially () {
58275823 var query = """
@@ -5838,13 +5834,11 @@ public void testInlinestatsGetsPrunedPartially() {
58385834
58395835 var project = as (plan , Project .class );
58405836 assertThat (Expressions .names (project .projections ()), is (List .of ("x" , "a" , "emp_no" )));
5841- var upperLimit = asLimit (project .child (), 1 , true );
5837+ var upperLimit = asLimit (project .child (), 1 , false );
58425838 var inlineJoin = as (upperLimit .child (), InlineJoin .class );
58435839 assertThat (Expressions .names (inlineJoin .config ().matchFields ()), is (List .of ("emp_no" )));
58445840 // Left
5845- var limit = as (inlineJoin .left (), Limit .class ); // TODO: this needs to go
5846- assertThat (limit .limit ().fold (FoldContext .small ()), equalTo (1 ));
5847- var relation = as (limit .child (), EsRelation .class );
5841+ var relation = as (inlineJoin .left (), EsRelation .class );
58485842 // Right
58495843 var agg = as (inlineJoin .right (), Aggregate .class );
58505844 assertMap (Expressions .names (agg .output ()), is (List .of ("a" , "emp_no" )));
@@ -5869,13 +5863,11 @@ public void testTrippleInlinestatsGetsPrunedPartially() {
58695863
58705864 var project = as (plan , Project .class );
58715865 assertThat (Expressions .names (project .projections ()), is (List .of ("x" , "a" , "emp_no" )));
5872- var upperLimit = asLimit (project .child (), 1 , true );
5866+ var upperLimit = asLimit (project .child (), 1 , false );
58735867 var inlineJoin = as (upperLimit .child (), InlineJoin .class );
58745868 assertThat (Expressions .names (inlineJoin .config ().matchFields ()), is (List .of ("emp_no" )));
58755869 // Left
5876- var limit = as (inlineJoin .left (), Limit .class );
5877- assertThat (limit .limit ().fold (FoldContext .small ()), equalTo (1 ));
5878- var relation = as (limit .child (), EsRelation .class );
5870+ var relation = as (inlineJoin .left (), EsRelation .class );
58795871 // Right
58805872 var agg = as (inlineJoin .right (), Aggregate .class );
58815873 assertMap (Expressions .names (agg .output ()), is (List .of ("a" , "emp_no" )));
@@ -5926,20 +5918,17 @@ public void testInlinestatsWithLookupJoin() {
59265918 assertThat (right .concreteIndices (), is (Set .of ("languages_lookup" )));
59275919 }
59285920
5929- /**
5930- * <pre>{@code
5921+ /*
59315922 * EsqlProject[[avg{r}#4, emp_no{f}#9, first_name{f}#10]]
5932- * \_Limit[10[INTEGER],true ]
5923+ * \_Limit[10[INTEGER],false ]
59335924 * \_InlineJoin[LEFT,[emp_no{f}#9],[emp_no{f}#9],[emp_no{r}#9]]
5934- * |_Limit[10[INTEGER],false] <-- TODO: this needs to go
5935- * | \_EsRelation[test][_meta_field{f}#15, emp_no{f}#9, first_name{f}#10, g..]
5925+ * |_EsRelation[test][_meta_field{f}#15, emp_no{f}#9, first_name{f}#10, g..]
59365926 * \_Project[[avg{r}#4, emp_no{f}#9]]
59375927 * \_Eval[[$$SUM$avg$0{r$}#20 / $$COUNT$avg$1{r$}#21 AS avg#4]]
59385928 * \_Aggregate[[emp_no{f}#9],[SUM(salary{f}#14,true[BOOLEAN]) AS $$SUM$avg$0#20, COUNT(salary{f}#14,true[BOOLEAN]) AS $$COUNT$
59395929 * avg$1#21, emp_no{f}#9]]
59405930 * \_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,
59415931 * languages{f}#12, last_name{f}#13, long_noidx{f}#19, salary{f}#14]]
5942- * }</pre>
59435932 */
59445933 public void testInlinestatsWithAvg () {
59455934 var query = """
@@ -5955,12 +5944,11 @@ public void testInlinestatsWithAvg() {
59555944
59565945 var esqlProject = as (plan , EsqlProject .class );
59575946 assertThat (Expressions .names (esqlProject .projections ()), is (List .of ("avg" , "emp_no" , "first_name" )));
5958- var upperLimit = asLimit (esqlProject .child (), 10 , true );
5947+ var upperLimit = asLimit (esqlProject .child (), 10 , false );
59595948 var inlineJoin = as (upperLimit .child (), InlineJoin .class );
59605949 assertThat (Expressions .names (inlineJoin .config ().matchFields ()), is (List .of ("emp_no" )));
59615950 // Left
5962- var limit = asLimit (inlineJoin .left (), 10 , false ); // TODO: this needs to go
5963- var relation = as (limit .child (), EsRelation .class );
5951+ var relation = as (inlineJoin .left (), EsRelation .class );
59645952 // Right
59655953 var project = as (inlineJoin .right (), Project .class );
59665954 assertThat (Expressions .names (project .projections ()), contains ("avg" , "emp_no" ));
0 commit comments