|
29 | 29 | import org.elasticsearch.xpack.esql.expression.function.scalar.math.RoundTo; |
30 | 30 | import org.elasticsearch.xpack.esql.optimizer.LocalPhysicalPlanOptimizerTests; |
31 | 31 | import org.elasticsearch.xpack.esql.optimizer.TestPlannerOptimizer; |
| 32 | +import org.elasticsearch.xpack.esql.plan.logical.EsRelation; |
32 | 33 | import org.elasticsearch.xpack.esql.plan.physical.AggregateExec; |
33 | 34 | import org.elasticsearch.xpack.esql.plan.physical.EsQueryExec; |
34 | 35 | import org.elasticsearch.xpack.esql.plan.physical.EvalExec; |
35 | 36 | import org.elasticsearch.xpack.esql.plan.physical.ExchangeExec; |
36 | 37 | import org.elasticsearch.xpack.esql.plan.physical.FieldExtractExec; |
| 38 | +import org.elasticsearch.xpack.esql.plan.physical.FragmentExec; |
37 | 39 | import org.elasticsearch.xpack.esql.plan.physical.LimitExec; |
38 | 40 | import org.elasticsearch.xpack.esql.plan.physical.LookupJoinExec; |
39 | 41 | import org.elasticsearch.xpack.esql.plan.physical.MergeExec; |
@@ -295,7 +297,24 @@ public void testDateTruncBucketTransformToQueryAndTagsWithOtherPushdownFunctions |
295 | 297 | } |
296 | 298 | } |
297 | 299 |
|
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 | + */ |
299 | 318 | public void testDateTruncBucketNotTransformToQueryAndTagsWithLookupJoin() { |
300 | 319 | for (String dateHistogram : dateHistograms) { |
301 | 320 | String query = LoggerMessageFormat.format(null, """ |
@@ -341,14 +360,9 @@ public void testDateTruncBucketNotTransformToQueryAndTagsWithLookupJoin() { |
341 | 360 | assertTrue(queryBuilder.tags().isEmpty()); |
342 | 361 | assertNull(esQueryExec.query()); |
343 | 362 | // 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]")); |
352 | 366 | } |
353 | 367 | } |
354 | 368 |
|
|
0 commit comments