Skip to content

Commit 8a484b8

Browse files
committed
stabilize tests
1 parent 43922e8 commit 8a484b8

File tree

3 files changed

+26
-25
lines changed

3 files changed

+26
-25
lines changed

x-pack/plugin/esql/qa/testFixtures/src/main/resources/lookup-join.csv-spec

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1656,16 +1656,16 @@ required_capability: join_lookup_v12
16561656

16571657
FROM employees
16581658
| RENAME languages AS language_code
1659-
| SORT language_code
1659+
| SORT emp_no, language_code
16601660
| LIMIT 4
16611661
| EVAL language_code = TO_INTEGER(NULL)
16621662
| LOOKUP JOIN languages_lookup ON language_code
16631663
| KEEP emp_no, language_code, language_name
16641664
;
16651665

16661666
emp_no:integer | language_code:integer | language_name:keyword
1667-
10009 |null |null
1668-
10013 |null |null
1669-
10019 |null |null
1670-
10005 |null |null
1667+
10001 |null |null
1668+
10002 |null |null
1669+
10003 |null |null
1670+
10004 |null |null
16711671
;

x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/optimizer/rules/logical/local/PruneJoinOnNullMatchingField.java

Lines changed: 20 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -38,31 +38,32 @@ public class PruneJoinOnNullMatchingField extends OptimizerRules.OptimizerRule<J
3838

3939
@Override
4040
protected LogicalPlan rule(Join join) {
41+
LogicalPlan plan = join;
4142
var joinType = join.config().type();
42-
if ((joinType == INNER || joinType == LEFT) == false) { // other types will have different replacement logic
43-
return join;
44-
}
45-
AttributeMap.Builder<Expression> attributeMapBuilder = AttributeMap.builder();
46-
loop: for (var child = join.left();; child = ((UnaryPlan) child).child()) { // cast is safe as both Project and Eval are UnaryPlans
47-
switch (child) {
48-
case Project project -> project.projections().forEach(projection -> {
49-
if (projection instanceof Alias alias) {
50-
attributeMapBuilder.put(alias.toAttribute(), alias.child());
43+
if (joinType == INNER || joinType == LEFT) { // other types will have different replacement logic
44+
AttributeMap.Builder<Expression> attributeMapBuilder = AttributeMap.builder();
45+
loop: for (var child = join.left();; child = ((UnaryPlan) child).child()) { // cast is safe as both plans are UnaryPlans
46+
switch (child) {
47+
case Project project -> project.projections().forEach(projection -> {
48+
if (projection instanceof Alias alias) {
49+
attributeMapBuilder.put(alias.toAttribute(), alias.child());
50+
}
51+
});
52+
case Eval eval -> eval.fields().forEach(alias -> attributeMapBuilder.put(alias.toAttribute(), alias.child()));
53+
default -> {
54+
break loop;
5155
}
52-
});
53-
case Eval eval -> eval.fields().forEach(alias -> attributeMapBuilder.put(alias.toAttribute(), alias.child()));
54-
default -> {
55-
break loop;
5656
}
5757
}
58-
}
59-
for (var attr : AttributeSet.of(join.config().matchFields())) {
60-
var resolved = attributeMapBuilder.build().resolve(attr);
61-
if (resolved != null && isGuaranteedNull(resolved)) {
62-
return replaceJoin(join);
58+
for (var attr : AttributeSet.of(join.config().matchFields())) {
59+
var resolved = attributeMapBuilder.build().resolve(attr);
60+
if (resolved != null && isGuaranteedNull(resolved)) {
61+
plan = replaceJoin(join);
62+
break;
63+
}
6364
}
6465
}
65-
return join;
66+
return plan;
6667
}
6768

6869
private static LogicalPlan replaceJoin(Join join) {

x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/optimizer/PhysicalPlanOptimizerTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7666,7 +7666,7 @@ private LocalExecutionPlanner.LocalExecutionPlan physicalOperationsFromPhysicalP
76667666
// The TopN needs an estimated row size for the planner to work
76677667
var plans = PlannerUtils.breakPlanBetweenCoordinatorAndDataNode(EstimatesRowSize.estimateRowSize(0, plan), config);
76687668
plan = useDataNodePlan ? plans.v2() : plans.v1();
7669-
plan = PlannerUtils.localPlan(List.of(), config, FoldContext.small(), plan);
7669+
plan = PlannerUtils.localPlan(config, FoldContext.small(), plan, TEST_SEARCH_STATS);
76707670
ExchangeSinkHandler exchangeSinkHandler = new ExchangeSinkHandler(null, 10, () -> 10);
76717671
LocalExecutionPlanner planner = new LocalExecutionPlanner(
76727672
"test",

0 commit comments

Comments
 (0)