Skip to content

Commit 989d6ce

Browse files
committed
simplify the lambdas. I think this is more correct
1 parent 201014a commit 989d6ce

File tree

1 file changed

+4
-18
lines changed

1 file changed

+4
-18
lines changed

x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/analysis/IgnoreNullMetrics.java

Lines changed: 4 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -54,24 +54,10 @@ public LogicalPlan apply(LogicalPlan logicalPlan) {
5454
}
5555

5656
Expression finalConditional = conditional;
57-
return logicalPlan.transformUp(p -> {
58-
// Find where to put the new Filter node; We want it right after the relation leaf node
59-
// We want to add the filter right after the TS command, which is a "leaf" node.
60-
// So we want to find the first node above the leaf node.
61-
//
62-
// Maybe instead of looking for leaf nodes, this should specifically look for an EsRelation with time series mode?
63-
// That could avoid the check earlier in the rule.
64-
for (Node child : p.children()) {
65-
if (child.children().isEmpty() == false) {
66-
return false;
67-
}
68-
}
69-
return true;
70-
}, p -> {
71-
assert p.children().size() == 1;
72-
return new Filter(p.source(), p.children().get(0), finalConditional);
73-
74-
});
57+
// Find where to put the new Filter node; We want it right after the relation leaf node
58+
// We want to add the filter right after the TS command, which is a "leaf" node.
59+
// So we want to find the first node above the leaf node.
60+
return logicalPlan.transformUp(p -> isMetricsQuery((LogicalPlan) p), p -> new Filter(p.source(), p, finalConditional));
7561
}
7662

7763
private Set<Attribute> collectMetrics(LogicalPlan logicalPlan) {

0 commit comments

Comments
 (0)