Skip to content

Commit 93fd3dc

Browse files
committed
Address feedback
1 parent 47d5c63 commit 93fd3dc

File tree

4 files changed

+6
-11
lines changed

4 files changed

+6
-11
lines changed

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -648,6 +648,7 @@ private Join resolveLookupJoin(LookupJoin join) {
648648
List<Attribute> leftKeys = resolveUsingColumns(cols, join.left().output(), "left");
649649
List<Attribute> rightKeys = resolveUsingColumns(cols, join.right().output(), "right");
650650
List<Attribute> output = new ArrayList<>(join.left().output());
651+
// the order is stable (since the AttributeSet preservers the insertion order)
651652
output.addAll(join.right().outputSet().subtract(new AttributeSet(rightKeys)));
652653

653654
// update the config - pick the left keys as those in the output

x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/plan/logical/join/LookupJoin.java

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,6 @@
2323

2424
/**
2525
* Lookup join - specialized LEFT (OUTER) JOIN between the main left side and a lookup index (index_mode = lookup) on the right.
26-
* In the future, as the join capabilities of the engine will evolve, a regular LEFT JOIN will be used instead, letting the planner decide
27-
* the strategy at runtime.
2826
*/
2927
public class LookupJoin extends Join implements SurrogateLogicalPlan {
3028

@@ -62,8 +60,6 @@ public Join replaceChildren(LogicalPlan left, LogicalPlan right) {
6260

6361
@Override
6462
protected NodeInfo<Join> info() {
65-
// Do not just add the JoinConfig as a whole - this would prevent correctly registering the
66-
// expressions and references.
6763
return NodeInfo.create(this, LookupJoin::new, left(), right(), config(), output);
6864
}
6965

x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/plan/physical/LookupJoinExec.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,12 +116,14 @@ public List<Attribute> output() {
116116

117117
@Override
118118
public AttributeSet inputSet() {
119-
// TODO: this is a hack until qualifiers land since the right side is always materialized
119+
// TODO: this is a hack since the right side is always materialized - instead this should
120+
// return the _doc so the extraction can happen lazily
120121
return left().outputSet();
121122
}
122123

123124
@Override
124125
protected AttributeSet computeReferences() {
126+
// TODO: same as above - once lazy materialization of both sides lands, this needs updating
125127
return Expressions.references(leftFields);
126128
}
127129

x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/analysis/AnalyzerTests.java

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1945,18 +1945,14 @@ public void testLookup() {
19451945
.item(startsWith("job{f}"))
19461946
.item(startsWith("job.raw{f}"))
19471947
/*
1948-
* Int is a reference here because we renamed it in project.
1949-
* If we hadn't it'd be a field and that'd be fine.
1948+
* Int key is returned as a full field (despite the rename)
19501949
*/
19511950
.item(containsString("int{f}"))
19521951
.item(startsWith("last_name{f}"))
19531952
.item(startsWith("long_noidx{f}"))
19541953
.item(startsWith("salary{f}"))
19551954
/*
1956-
* It's important that name is returned as a *reference* here
1957-
* instead of a field. If it were a field we'd use SearchStats
1958-
* on it and discover that it doesn't exist in the index. It doesn't!
1959-
* We don't expect it to. It exists only in the lookup table.
1955+
* As is the name column from the right side.
19601956
*/
19611957
.item(containsString("name{f}"))
19621958
);

0 commit comments

Comments
 (0)