|
69 | 69 | import org.elasticsearch.xpack.esql.plan.physical.ExchangeExec; |
70 | 70 | import org.elasticsearch.xpack.esql.plan.physical.FieldExtractExec; |
71 | 71 | import org.elasticsearch.xpack.esql.plan.physical.FilterExec; |
| 72 | +import org.elasticsearch.xpack.esql.plan.physical.GrokExec; |
72 | 73 | import org.elasticsearch.xpack.esql.plan.physical.LimitExec; |
73 | 74 | import org.elasticsearch.xpack.esql.plan.physical.LocalSourceExec; |
74 | 75 | import org.elasticsearch.xpack.esql.plan.physical.LookupJoinExec; |
| 76 | +import org.elasticsearch.xpack.esql.plan.physical.MvExpandExec; |
75 | 77 | import org.elasticsearch.xpack.esql.plan.physical.PhysicalPlan; |
76 | 78 | import org.elasticsearch.xpack.esql.plan.physical.ProjectExec; |
77 | 79 | import org.elasticsearch.xpack.esql.plan.physical.TimeSeriesAggregateExec; |
@@ -1421,6 +1423,93 @@ public void testMissingFieldsPurgesTheJoinLocally() { |
1421 | 1423 | var source = as(eval.child(), EsQueryExec.class); |
1422 | 1424 | } |
1423 | 1425 |
|
| 1426 | + /* |
| 1427 | + * LimitExec[1000[INTEGER]] |
| 1428 | + * \_AggregateExec[[language_code{r}#7],[COUNT(emp_no{r}#31,true[BOOLEAN]) AS c#17, language_code{r}#7],FINAL,[language_code{r}#7, $ |
| 1429 | + * $c$count{r}#32, $$c$seen{r}#33],12] |
| 1430 | + * \_ExchangeExec[[language_code{r}#7, $$c$count{r}#32, $$c$seen{r}#33],true] |
| 1431 | + * \_AggregateExec[[language_code{r}#7],[COUNT(emp_no{r}#31,true[BOOLEAN]) AS c#17, language_code{r}#7],INITIAL,[language_code{r}#7, |
| 1432 | + * $$c$count{r}#34, $$c$seen{r}#35],12] |
| 1433 | + * \_GrokExec[first_name{f}#19,Parser[pattern=%{WORD:foo}, grok=org.elasticsearch.grok.Grok@75389ac1],[foo{r}#12]] |
| 1434 | + * \_MvExpandExec[emp_no{f}#18,emp_no{r}#31] |
| 1435 | + * \_ProjectExec[[emp_no{f}#18, languages{r}#21 AS language_code#7, first_name{f}#19]] |
| 1436 | + * \_FieldExtractExec[emp_no{f}#18, first_name{f}#19]<[],[]> |
| 1437 | + * \_EvalExec[[null[INTEGER] AS languages#21]] |
| 1438 | + * \_EsQueryExec[test], indexMode[standard], query[][_doc{f}#36], limit[], sort[] estimatedRowSize[112] |
| 1439 | + */ |
| 1440 | + public void testMissingFieldsPurgesTheJoinLocallyThroughCommands() { |
| 1441 | + var stats = EsqlTestUtils.statsForMissingField("languages"); |
| 1442 | + |
| 1443 | + var plan = plannerOptimizer.plan(""" |
| 1444 | + from test |
| 1445 | + | keep emp_no, languages, first_name |
| 1446 | + | rename languages AS language_code |
| 1447 | + | mv_expand emp_no |
| 1448 | + | grok first_name "%{WORD:foo}" |
| 1449 | + | lookup join languages_lookup ON language_code |
| 1450 | + | stats c = count(emp_no) by language_code |
| 1451 | + """, stats); |
| 1452 | + |
| 1453 | + var limit = as(plan, LimitExec.class); |
| 1454 | + var agg = as(limit.child(), AggregateExec.class); |
| 1455 | + assertThat(Expressions.names(agg.output()), contains("c", "language_code")); |
| 1456 | + |
| 1457 | + var exchange = as(agg.child(), ExchangeExec.class); |
| 1458 | + agg = as(exchange.child(), AggregateExec.class); |
| 1459 | + var grok = as(agg.child(), GrokExec.class); |
| 1460 | + var mvexpand = as(grok.child(), MvExpandExec.class); |
| 1461 | + var project = as(mvexpand.child(), ProjectExec.class); |
| 1462 | + var extract = as(project.child(), FieldExtractExec.class); |
| 1463 | + var eval = as(extract.child(), EvalExec.class); |
| 1464 | + var source = as(eval.child(), EsQueryExec.class); |
| 1465 | + } |
| 1466 | + |
| 1467 | + /* |
| 1468 | + * LimitExec[1000[INTEGER]] |
| 1469 | + * \_AggregateExec[[language_code{r}#12],[COUNT(emp_no{r}#31,true[BOOLEAN]) AS c#17, language_code{r}#12],FINAL,[language_code{r}#12 |
| 1470 | + * , $$c$count{r}#32, $$c$seen{r}#33],12] |
| 1471 | + * \_ExchangeExec[[language_code{r}#12, $$c$count{r}#32, $$c$seen{r}#33],true] |
| 1472 | + * \_AggregateExec[[language_code{r}#12],[COUNT(emp_no{r}#31,true[BOOLEAN]) AS c#17, language_code{r}#12],INITIAL,[language_code{r}# |
| 1473 | + * 12, $$c$count{r}#34, $$c$seen{r}#35],12] |
| 1474 | + * \_LookupJoinExec[[language_code{r}#12],[language_code{f}#29],[]] |
| 1475 | + * |_GrokExec[first_name{f}#19,Parser[pattern=%{NUMBER:language_code:int}, grok=org.elasticsearch.grok.Grok@764e5109],[languag |
| 1476 | + * e_code{r}#12]] |
| 1477 | + * | \_MvExpandExec[emp_no{f}#18,emp_no{r}#31] |
| 1478 | + * | \_ProjectExec[[emp_no{f}#18, languages{r}#21 AS language_code#7, first_name{f}#19]] |
| 1479 | + * | \_FieldExtractExec[emp_no{f}#18, first_name{f}#19]<[],[]> |
| 1480 | + * | \_EvalExec[[null[INTEGER] AS languages#21]] |
| 1481 | + * | \_EsQueryExec[test], indexMode[standard], query[][_doc{f}#36], limit[], sort[] estimatedRowSize[66] |
| 1482 | + * \_EsQueryExec[languages_lookup], indexMode[lookup], query[][_doc{f}#37], limit[], sort[] estimatedRowSize[4] |
| 1483 | + */ |
| 1484 | + public void testMissingFieldsNotPurgingTheJoinLocally() { |
| 1485 | + var stats = EsqlTestUtils.statsForMissingField("languages"); |
| 1486 | + |
| 1487 | + var plan = plannerOptimizer.plan(""" |
| 1488 | + from test |
| 1489 | + | keep emp_no, languages, first_name |
| 1490 | + | rename languages AS language_code |
| 1491 | + | mv_expand emp_no |
| 1492 | + | grok first_name "%{NUMBER:language_code:int}" // this reassigns language_code |
| 1493 | + | lookup join languages_lookup ON language_code |
| 1494 | + | stats c = count(emp_no) by language_code |
| 1495 | + """, stats); |
| 1496 | + |
| 1497 | + var limit = as(plan, LimitExec.class); |
| 1498 | + var agg = as(limit.child(), AggregateExec.class); |
| 1499 | + assertThat(Expressions.names(agg.output()), contains("c", "language_code")); |
| 1500 | + |
| 1501 | + var exchange = as(agg.child(), ExchangeExec.class); |
| 1502 | + agg = as(exchange.child(), AggregateExec.class); |
| 1503 | + var join = as(agg.child(), LookupJoinExec.class); |
| 1504 | + var grok = as(join.left(), GrokExec.class); |
| 1505 | + var mvexpand = as(grok.child(), MvExpandExec.class); |
| 1506 | + var project = as(mvexpand.child(), ProjectExec.class); |
| 1507 | + var extract = as(project.child(), FieldExtractExec.class); |
| 1508 | + var eval = as(extract.child(), EvalExec.class); |
| 1509 | + var source = as(eval.child(), EsQueryExec.class); |
| 1510 | + var right = as(join.right(), EsQueryExec.class); |
| 1511 | + } |
| 1512 | + |
1424 | 1513 | /* |
1425 | 1514 | * LimitExec[1000[INTEGER]] |
1426 | 1515 | * \_LookupJoinExec[[language_code{r}#6],[language_code{f}#23],[language_name{f}#24]] |
|
0 commit comments