-
Notifications
You must be signed in to change notification settings - Fork 25.6k
ES|QL: Add initial grammar and planning for RRF (snapshot) #123396
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
Changes from 3 commits
33eb3fe
9b00645
406b3ea
f08abb7
f8c2654
c6cbfd0
587ef71
ee50a80
281da1d
0a45f00
e401c23
40168dc
4b3a8d7
d56d280
b6b1a84
d1de323
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -2938,6 +2938,22 @@ public void testRrfError() { | |||||||||||||||||||
| assertThat(e.getMessage(), containsString("Unknown column [_score]")); | ||||||||||||||||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we should provide a better error message for missing metadata attrs- something like "_score is needed for using RRF. Please add METADATA _score to your FROM command".
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I looked into this - looks simple enough at a first glance. We can just modify this to have a custom error message when Lines 113 to 121 in a5e0423
However we would return an error message like "Please add METADATA _score to your FROM command" even if you use I know this is a very narrow corner case, but it would be an unintended behaviour.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think it would be OK to error with "_score is needed for using RRF. Use FROM ... METADATA _score". We can assume that full text search needs FROM, as FTFs need an index attribute to operate on? We can refine this in a follow up, but it will be very confusing for users to receive "unknown column _score" - being a metadata attribute means users won't understand where's that coming from without referring to docs
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. agreed - added as a follow up in #123391 |
||||||||||||||||||||
| assertThat(e.getMessage(), containsString("Unknown column [_fork]")); | ||||||||||||||||||||
|
|
||||||||||||||||||||
| e = expectThrows(VerificationException.class, () -> analyze(""" | ||||||||||||||||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I wonder if the sequence between Do we allow multiple
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I have put a validation for or Another thing to note is that we currently have a restriction for FORK where it's possible to only have a single FORK command in a query, so the following is not something we can do atm:
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I did see one thing that was concerning when I tried to do: this would lead to an unexecutable query because when do the RRF planning this expands to: The first SORT does not have a LIMIT so it cannot be translated to a TOP N. |
||||||||||||||||||||
| from test metadata _score, _index, _id | ||||||||||||||||||||
| | eval _fork = 1 | ||||||||||||||||||||
| | rrf | ||||||||||||||||||||
| """)); | ||||||||||||||||||||
| assertThat(e.getMessage(), containsString("RRF can only be used after FORK, but found EVAL")); | ||||||||||||||||||||
|
|
||||||||||||||||||||
| e = expectThrows(VerificationException.class, () -> analyze(""" | ||||||||||||||||||||
| from test metadata _id, _index, _score | ||||||||||||||||||||
| | fork ( where first_name:"foo" ) | ||||||||||||||||||||
| ( where first_name:"bar" ) | ||||||||||||||||||||
| | rrf | ||||||||||||||||||||
| | rrf | ||||||||||||||||||||
| """)); | ||||||||||||||||||||
| assertThat(e.getMessage(), containsString("RRF can only be used after FORK, but found RRF")); | ||||||||||||||||||||
|
|
||||||||||||||||||||
| e = expectThrows(VerificationException.class, () -> analyze(""" | ||||||||||||||||||||
| from test | ||||||||||||||||||||
| | FORK ( WHERE emp_no == 1 ) | ||||||||||||||||||||
|
|
@@ -2953,6 +2969,14 @@ public void testRrfError() { | |||||||||||||||||||
| | RRF | ||||||||||||||||||||
| """)); | ||||||||||||||||||||
| assertThat(e.getMessage(), containsString("Unknown column [_index]")); | ||||||||||||||||||||
ioanatia marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||||||||||||
|
|
||||||||||||||||||||
| e = expectThrows(VerificationException.class, () -> analyze(""" | ||||||||||||||||||||
| from test metadata _score, _index | ||||||||||||||||||||
| | FORK ( WHERE emp_no == 1 ) | ||||||||||||||||||||
| ( WHERE emp_no > 1 ) | ||||||||||||||||||||
| | RRF | ||||||||||||||||||||
| """)); | ||||||||||||||||||||
| assertThat(e.getMessage(), containsString("Unknown column [_id]")); | ||||||||||||||||||||
| } | ||||||||||||||||||||
|
|
||||||||||||||||||||
| // TODO There's too much boilerplate involved here! We need a better way of creating FieldCapabilitiesResponses from a mapping or index. | ||||||||||||||||||||
|
|
||||||||||||||||||||
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.
Nice trick! ❤️