Skip to content

Commit 76b4042

Browse files
Switch to passing local logical plan to lookup node
1 parent 63018a7 commit 76b4042

File tree

2 files changed

+25
-10
lines changed

2 files changed

+25
-10
lines changed

x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/enrich/LookupFromIndexOperatorTests.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,8 @@ protected Matcher<String> expectedToStringOfSimple() {
239239
sb.append("FilterExec\\[lint\\{f}#\\d+ < ")
240240
.append(LESS_THAN_VALUE)
241241
.append(
242-
"\\[INTEGER]]\\n\\\\_EsQueryExec\\[test], indexMode\\[lookup],\\s*(?:query\\[\\]|\\[\\])?,?\\s*limit\\[\\],?\\s*sort\\[(?:\\[\\])?\\]\\s*estimatedRowSize\\[null\\]\\s*queryBuilderAndTags \\[(?:\\[\\]\\])\\]"
242+
"\\[INTEGER]]\\n\\\\_EsQueryExec\\[test], indexMode\\[lookup],\\s*(?:query\\[\\]|\\[\\])?,?\\s*"
243+
+ "limit\\[\\],?\\s*sort\\[(?:\\[\\])?\\]\\s*estimatedRowSize\\[null\\]\\s*queryBuilderAndTags \\[(?:\\[\\]\\])\\]"
243244
);
244245
sb.append("|");
245246
// New FragmentExec pattern

x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/ReplaceRoundToWithQueryAndTagsTests.java

Lines changed: 23 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,13 @@
2929
import org.elasticsearch.xpack.esql.expression.function.scalar.math.RoundTo;
3030
import org.elasticsearch.xpack.esql.optimizer.LocalPhysicalPlanOptimizerTests;
3131
import org.elasticsearch.xpack.esql.optimizer.TestPlannerOptimizer;
32+
import org.elasticsearch.xpack.esql.plan.logical.EsRelation;
3233
import org.elasticsearch.xpack.esql.plan.physical.AggregateExec;
3334
import org.elasticsearch.xpack.esql.plan.physical.EsQueryExec;
3435
import org.elasticsearch.xpack.esql.plan.physical.EvalExec;
3536
import org.elasticsearch.xpack.esql.plan.physical.ExchangeExec;
3637
import org.elasticsearch.xpack.esql.plan.physical.FieldExtractExec;
38+
import org.elasticsearch.xpack.esql.plan.physical.FragmentExec;
3739
import org.elasticsearch.xpack.esql.plan.physical.LimitExec;
3840
import org.elasticsearch.xpack.esql.plan.physical.LookupJoinExec;
3941
import org.elasticsearch.xpack.esql.plan.physical.MergeExec;
@@ -295,7 +297,24 @@ public void testDateTruncBucketTransformToQueryAndTagsWithOtherPushdownFunctions
295297
}
296298
}
297299

298-
// ReplaceRoundToWithQueryAndTags does not support lookup joins yet
300+
/**
301+
* ReplaceRoundToWithQueryAndTags does not support lookup joins yet
302+
* LimitExec[1000[INTEGER],16]
303+
* \_AggregateExec[[x{r}#8],[COUNT(*[KEYWORD],true[BOOLEAN]) AS count(*)#9, x{r}#8],FINAL,[x{r}#8, $$count(*)$count{r}#34, $$count(*
304+
* )$seen{r}#35],16]
305+
* \_ExchangeExec[[x{r}#8, $$count(*)$count{r}#34, $$count(*)$seen{r}#35],true]
306+
* \_AggregateExec[[x{r}#8],[COUNT(*[KEYWORD],true[BOOLEAN]) AS count(*)#9, x{r}#8],INITIAL,[x{r}#8, $$count(*)$count{r}#36, $$count
307+
* (*)$seen{r}#37],16]
308+
* \_EvalExec[[ROUNDTO(date{f}#15,1697760000000[DATETIME],1697846400000[DATETIME],1697932800000[DATETIME],1698019200000[DATE
309+
* TIME]) AS x#8]]
310+
* \_FieldExtractExec[date{f}#15]
311+
* \_LookupJoinExec[[integer{f}#21],[language_code{f}#32],[]]
312+
* |_FieldExtractExec[integer{f}#21]
313+
* | \_EsQueryExec[test], indexMode[standard], [_doc{f}#38], limit[], sort[] estimatedRowSize[24]
314+
* queryBuilderAndTags [[QueryBuilderAndTags{queryBuilder=[null], tags=[]}]]
315+
* \_FragmentExec[filter=null, estimatedRowSize=0, reducer=[], fragment=[
316+
* EsRelation[languages_lookup][LOOKUP][language_code{f}#32]]]
317+
*/
299318
public void testDateTruncBucketNotTransformToQueryAndTagsWithLookupJoin() {
300319
for (String dateHistogram : dateHistograms) {
301320
String query = LoggerMessageFormat.format(null, """
@@ -341,14 +360,9 @@ public void testDateTruncBucketNotTransformToQueryAndTagsWithLookupJoin() {
341360
assertTrue(queryBuilder.tags().isEmpty());
342361
assertNull(esQueryExec.query());
343362
// rhs of lookup join
344-
esQueryExec = as(lookupJoinExec.right(), EsQueryExec.class);
345-
assertEquals("languages_lookup", esQueryExec.indexPattern());
346-
queryBuilderAndTags = esQueryExec.queryBuilderAndTags();
347-
assertEquals(1, queryBuilderAndTags.size());
348-
queryBuilder = queryBuilderAndTags.get(0);
349-
assertNull(queryBuilder.query());
350-
assertTrue(queryBuilder.tags().isEmpty());
351-
assertNull(esQueryExec.query());
363+
FragmentExec fragmentExec = as(lookupJoinExec.right(), FragmentExec.class);
364+
EsRelation esRelation = as(fragmentExec.fragment(), EsRelation.class);
365+
assertTrue(esRelation.toString().contains("EsRelation[languages_lookup][LOOKUP]"));
352366
}
353367
}
354368

0 commit comments

Comments
 (0)