-
Notifications
You must be signed in to change notification settings - Fork 25.4k
Add support for Lookup Join on Multiple Fields #131559
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 32 commits
Commits
Show all changes
45 commits
Select commit
Hold shift + click to select a range
b1ee80e
Lookup Join on Multiple Columns POC WIP
julian-elastic 2c90817
Update docs/changelog/131559.yaml
julian-elastic 4db37fd
Looking join on multiple fields WIP
julian-elastic ef894f3
Merge branch 'main' into lookupJoin
julian-elastic e367e8c
Fix more UTs
julian-elastic 744479f
Bugfixes
julian-elastic c17c993
Bugfixes
julian-elastic d9462cc
Fix serialization error
julian-elastic a17fa88
Fix UT error
julian-elastic 3fd48e4
Add more test datasets
julian-elastic 64a07c7
Add UTs for join on 2,3,4 columns
julian-elastic ea171b1
Merge branch 'main' into lookupJoin
julian-elastic bae7007
Add handling for remote not supporting LOOKUP JOIN on multiple fields
julian-elastic 6bd2937
Merge branch 'main' into lookupJoin
julian-elastic 71adaa8
Change documentation
julian-elastic 43aa7e1
Fix docs
julian-elastic 7e0d8d7
Add more UTs
julian-elastic b6c615c
Merge branch 'main' into lookupJoin
julian-elastic 5d9f68f
Address code review feedback
julian-elastic fc1c63b
Merge branch 'main' into lookupJoin
julian-elastic c179cea
Add Generative tests for Lookup Join On Multiple Columns
julian-elastic be2ce94
Merge branch 'main' into lookupJoin
julian-elastic 59c16d9
Remove debugging code
julian-elastic dd52c02
Address a rare issue in Generative tests
julian-elastic 8b2594b
Address docs issues
julian-elastic 606c099
Merge branch 'main' into lookupJoin
julian-elastic e585342
Mode docs changes
julian-elastic 72c3ad7
Merge branch 'main' into lookupJoin
julian-elastic f742160
Address code review feedback
julian-elastic ed6946b
Enhance LookupFromIndexIT
julian-elastic 806933f
Fix failing UT
julian-elastic 62956af
Merge branch 'main' into lookupJoin
julian-elastic 326cb82
Address more code review comments
julian-elastic 1dbe524
Address more code review comments, part 2
julian-elastic 00b41ed
MatchConfig refactoring and add serialization test
julian-elastic a036aa6
bugfix
julian-elastic 28d0c7c
Merge branch 'main' into lookupJoin
julian-elastic ce73957
Add HeapAttackIT cases with join on multiple fields
julian-elastic cfdb440
Merge branch 'main' into lookupJoin
julian-elastic 96a6891
bugfix
julian-elastic d90799d
Update docs/changelog/131559.yaml
julian-elastic ec7f10a
Merge branch 'main' into lookupJoin
julian-elastic 1cf34bc
Address code review comments
julian-elastic 6acb8ef
Merge branch 'main' into lookupJoin
julian-elastic 1102c1b
fix issue with docs
julian-elastic File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
pr: 131559 | ||
summary: Add support for LOOKUP JOIN on multiple fields | ||
area: ES|QL | ||
type: enhancement | ||
issues: [ ] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
61 changes: 61 additions & 0 deletions
61
.../compute/src/main/java/org/elasticsearch/compute/operator/lookup/ExpressionQueryList.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
package org.elasticsearch.compute.operator.lookup; | ||
|
||
import org.apache.lucene.search.BooleanClause; | ||
import org.apache.lucene.search.BooleanQuery; | ||
import org.apache.lucene.search.Query; | ||
|
||
import java.util.List; | ||
|
||
/** | ||
* A {@link LookupEnrichQueryGenerator} that combines multiple {@link QueryList}s into a single query. | ||
* Each query in the resulting query will be a conjunction of all queries from the input lists at the same position. | ||
* In the future we can extend this to support more complex expressions, such as disjunctions or negations. | ||
*/ | ||
public class ExpressionQueryList implements LookupEnrichQueryGenerator { | ||
julian-elastic marked this conversation as resolved.
Show resolved
Hide resolved
|
||
private final List<QueryList> queryLists; | ||
|
||
public ExpressionQueryList(List<QueryList> queryLists) { | ||
if (queryLists.size() < 2) { | ||
throw new IllegalArgumentException("ExpressionQueryList must have at least two QueryLists"); | ||
} | ||
this.queryLists = queryLists; | ||
} | ||
|
||
@Override | ||
public Query getQuery(int position) { | ||
BooleanQuery.Builder builder = new BooleanQuery.Builder(); | ||
for (QueryList queryList : queryLists) { | ||
Query q = queryList.getQuery(position); | ||
if (q == null) { | ||
// if any of the matchFields are null, it means there is no match for this position | ||
// A AND NULL is always NULL, so we can skip this position | ||
return null; | ||
} | ||
builder.add(q, BooleanClause.Occur.FILTER); | ||
} | ||
return builder.build(); | ||
} | ||
|
||
@Override | ||
public int getPositionCount() { | ||
int positionCount = queryLists.get(0).getPositionCount(); | ||
for (QueryList queryList : queryLists) { | ||
if (queryList.getPositionCount() != positionCount) { | ||
throw new IllegalArgumentException( | ||
julian-elastic marked this conversation as resolved.
Show resolved
Hide resolved
|
||
"All QueryLists must have the same position count, expected: " | ||
+ positionCount | ||
+ ", but got: " | ||
+ queryList.getPositionCount() | ||
); | ||
} | ||
} | ||
return positionCount; | ||
} | ||
} |
30 changes: 30 additions & 0 deletions
30
...e/src/main/java/org/elasticsearch/compute/operator/lookup/LookupEnrichQueryGenerator.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
package org.elasticsearch.compute.operator.lookup; | ||
|
||
import org.apache.lucene.search.Query; | ||
import org.elasticsearch.core.Nullable; | ||
|
||
/** | ||
* An interface to generates queries for the lookup and enrich operators. | ||
* This interface is used to retrieve queries based on a position index. | ||
*/ | ||
public interface LookupEnrichQueryGenerator { | ||
|
||
/** | ||
* Returns the query at the given position. | ||
*/ | ||
@Nullable | ||
Query getQuery(int position); | ||
|
||
/** | ||
* Returns the number of queries in this generator | ||
*/ | ||
int getPositionCount(); | ||
|
||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
x-pack/plugin/esql/qa/testFixtures/src/main/resources/data/multi_column_joinable.csv
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
id_int,name_str,is_active_bool,ip_addr,extra1,extra2 | ||
1,Alice,true,192.168.1.1,foo,100 | ||
julian-elastic marked this conversation as resolved.
Show resolved
Hide resolved
|
||
2,Bob,false,192.168.1.2,bar,200 | ||
3,Charlie,true,192.168.1.3,baz,300 | ||
4,David,false,192.168.1.4,qux,400 | ||
5,Eve,true,192.168.1.5,quux,500 | ||
6,,true,192.168.1.6,corge,600 | ||
7,Grace,false,,grault,700 | ||
8,Hank,true,192.168.1.8,garply,800 | ||
9,Ivy,false,192.168.1.9,waldo,900 | ||
10,John,true,192.168.1.10,fred,1000 | ||
,Kate,false,192.168.1.11,plugh,1100 | ||
[12],Liam,true,192.168.1.12,xyzzy,1200 | ||
13,Mia,false,192.168.1.13,thud,1300 | ||
[14],Nina,true,192.168.1.14,foo2,1400 | ||
15,Oscar,false,192.168.1.15,bar2,1500 | ||
[17,18],Olivia,true,192.168.1.17,xyz,17000 | ||
[1,19,21],Sophia,true,192.168.1.21,zyx,21000 |
19 changes: 19 additions & 0 deletions
19
x-pack/plugin/esql/qa/testFixtures/src/main/resources/data/multi_column_joinable_lookup.csv
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
id_int,name_str,is_active_bool,ip_addr,other1,other2 | ||
1,Alice,true,192.168.1.1,alpha,1000 | ||
1,Alice,true,192.168.1.2,beta,2000 | ||
2,Bob,false,192.168.1.3,gamma,3000 | ||
3,Charlie,true,192.168.1.3,delta,4000 | ||
3,Charlie,false,192.168.1.3,epsilon,5000 | ||
4,David,false,192.168.1.4,zeta,6000 | ||
5,Eve,true,192.168.1.5,eta,7000 | ||
5,Eve,true,192.168.1.5,theta,8000 | ||
6,,true,192.168.1.6,iota,9000 | ||
7,Grace,false,,kappa,10000 | ||
8,Hank,true,192.168.1.8,lambda,11000 | ||
,Kate,false,192.168.1.11,mu,12000 | ||
julian-elastic marked this conversation as resolved.
Show resolved
Hide resolved
|
||
12,Liam,true,192.168.1.12,nu,13000 | ||
13,Mia,false,192.168.1.13,xi,14000 | ||
[14],Nina,true,192.168.1.14,omicron,15000 | ||
16,Paul,true,192.168.1.16,pi,16000 | ||
[17,18],Olivia,true,192.168.1.17,rho,17000 | ||
[1,19,20],Sophia,true,192.168.1.21,sigma,21000 |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We may want to declare this change as notable. I'm not sure what the bar is for that @leemthompo ?
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you and @tylerperk agree sounds like this passes the notable bar 😄 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@leemthompo How do I declare this change as notable? Can you point me to an example? Or you add it to some other release notes list after it is merged?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@alex-spies by notable you mean adding the
release highlight
label I guess?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@leemthompo I saw that we flag important release notes as notable, like here. Is this normally added via the
release highlight
label?Both seem to make sense, so I'll go and mark this as
release highlight
and see what the bot does :)Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TIL 😄