File tree Expand file tree Collapse file tree 2 files changed +4
-4
lines changed
x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/optimizer Expand file tree Collapse file tree 2 files changed +4
-4
lines changed Original file line number Diff line number Diff line change 1212import org .elasticsearch .xpack .esql .core .expression .Attribute ;
1313import org .elasticsearch .xpack .esql .core .expression .Expressions ;
1414import org .elasticsearch .xpack .esql .optimizer .rules .PlanConsistencyChecker ;
15- import org .elasticsearch .xpack .esql .plan .physical .AggregateExec ;
1615import org .elasticsearch .xpack .esql .plan .physical .FieldExtractExec ;
1716import org .elasticsearch .xpack .esql .plan .physical .PhysicalPlan ;
1817
Original file line number Diff line number Diff line change 1919import org .elasticsearch .xpack .esql .plan .logical .UnaryPlan ;
2020import org .elasticsearch .xpack .esql .plan .logical .join .Join ;
2121import org .elasticsearch .xpack .esql .plan .logical .join .JoinTypes ;
22- import org .elasticsearch .xpack .esql .plan .logical .local .LocalRelation ;
2322
2423public final class PushDownAndCombineLimits extends OptimizerRules .OptimizerRule <Limit > {
2524
@@ -63,8 +62,10 @@ public LogicalPlan rule(Limit limit) {
6362 }
6463 }
6564 } else if (limit .child () instanceof Join join ) {
66- if (join .config ().type () == JoinTypes .LEFT && join .right () instanceof LocalRelation ) {
67- // This is a hash join from something like a lookup.
65+ if (join .config ().type () == JoinTypes .LEFT ) {
66+ // NOTE! This is only correct because our LEFT JOINs preserve the number of rows from the left hand side.
67+ // This deviates from SQL semantics. In SQL, multiple matches on the right hand side lead to multiple rows in the output.
68+ // For us, multiple matches on the right hand side lead are collected into multi-values.
6869 return join .replaceChildren (limit .replaceChild (join .left ()), join .right ());
6970 }
7071 }
You can’t perform that action at this time.
0 commit comments