-
Notifications
You must be signed in to change notification settings - Fork 180
Support relevance query functions pushdown implementation in Calcite #3834
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
Support relevance query functions pushdown implementation in Calcite #3834
Conversation
Signed-off-by: Songkan Tang <[email protected]>
Signed-off-by: Songkan Tang <[email protected]>
| String query = | ||
| "source = %s| WHERE match_phrase_prefix(Title, 'in to', analyzer=english," | ||
| + " zero_terms_query='ALL') | sort -Title | head 1 | fields Title"; | ||
| + " zero_terms_query='ALL') | head 1 | fields Title"; |
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.
Modify this IT query because sort pushdown is not merged to Calcite yet.
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.
it merged, can you rebase the code?
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.
Rebased the code but the Sort pushdown has different behavior of handling missing_: first/last than V2. Calcite IT still has different assertion. So I leave my change here.
Waiting for @yuancu new PR merging.
Signed-off-by: Songkan Tang <[email protected]>
core/src/main/java/org/opensearch/sql/calcite/CalciteRexNodeVisitor.java
Outdated
Show resolved
Hide resolved
opensearch/src/main/java/org/opensearch/sql/opensearch/request/PredicateAnalyzer.java
Outdated
Show resolved
Hide resolved
opensearch/src/main/java/org/opensearch/sql/opensearch/request/PredicateAnalyzer.java
Outdated
Show resolved
Hide resolved
opensearch/src/main/java/org/opensearch/sql/opensearch/request/PredicateAnalyzer.java
Outdated
Show resolved
Hide resolved
...va/org/opensearch/sql/opensearch/storage/script/filter/lucene/relevance/MultiFieldQuery.java
Outdated
Show resolved
Hide resolved
...ava/org/opensearch/sql/opensearch/storage/script/filter/lucene/relevance/RelevanceQuery.java
Outdated
Show resolved
Hide resolved
Signed-off-by: Songkan Tang <[email protected]>
| if (node.getFuncName().equalsIgnoreCase("reduce")) { // analyze again with calculate type | ||
| lambdaContext = | ||
|
|
||
| if (SINGLE_FIELD_RELEVANCE_FUNCTION_SET.contains(node.getFuncName()) |
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.
I don't get why not replying on visitRelevanceFieldList to resolve all fields and then we don't need specific handing for relevance functions.
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.
As discussed, we can support UnresolvedArgument as alias(literal). Making such changes
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.
Addressed UnresolvedArgument change. The amount of changes is less than I expected.
core/src/main/java/org/opensearch/sql/expression/function/PPLBuiltinOperators.java
Outdated
Show resolved
Hide resolved
|
I don't think we should support relevance query functions directly. The concern is that it would allow users to use them anywhere a predicate expression is valid. However, the query engine does not support relevance evaluation, so it must always push down these functions to the DSL. If pushdown fails, the query will throw an exception. Instead, I propose supporting relevance-based queries only within the search command. |
Signed-off-by: Songkan Tang <[email protected]>
Signed-off-by: Songkan Tang <[email protected]>
|
@penghuo As discussed, since V2 relevance function cannot be removed quickly. We can mark these functions deprecated once we introduce new syntax of relevance query in search command directly. |
|
The backport to To backport manually, run these commands in your terminal: # Navigate to the root of your repository
cd $(git rev-parse --show-toplevel)
# Fetch latest updates from GitHub
git fetch
# Create a new working tree
git worktree add ../.worktrees/sql/backport-2.19-dev 2.19-dev
# Navigate to the new working tree
pushd ../.worktrees/sql/backport-2.19-dev
# Create a new branch
git switch --create backport/backport-3834-to-2.19-dev
# Cherry-pick the merged commit of this pull request and resolve the conflicts
git cherry-pick -x --mainline 1 74b4de067cefc821055076bd108249cef777c3f9
# Push it to GitHub
git push --set-upstream origin backport/backport-3834-to-2.19-dev
# Go back to the original working tree
popd
# Delete the working tree
git worktree remove ../.worktrees/sql/backport-2.19-devThen, create a pull request where the |
|
@songkant-aws please manually backport it to 2.19-dev |
…pensearch-project#3834) * Support relevance query functions pushdown implementation Signed-off-by: Songkan Tang <[email protected]> * Remove unused change Signed-off-by: Songkan Tang <[email protected]> * Remove ITs from NoPushDownIT list Signed-off-by: Songkan Tang <[email protected]> * Add more UTs and javadocs Signed-off-by: Songkan Tang <[email protected]> * Support analyzing UnresolvedArgument RexNode and refactor code Signed-off-by: Songkan Tang <[email protected]> * Fix spotless check Signed-off-by: Songkan Tang <[email protected]> --------- Signed-off-by: Songkan Tang <[email protected]>
…entation in Calcite (#3834) (#3848) * Support relevance query functions pushdown implementation in Calcite (#3834) * Support relevance query functions pushdown implementation Signed-off-by: Songkan Tang <[email protected]> * Remove unused change Signed-off-by: Songkan Tang <[email protected]> * Remove ITs from NoPushDownIT list Signed-off-by: Songkan Tang <[email protected]> * Add more UTs and javadocs Signed-off-by: Songkan Tang <[email protected]> * Support analyzing UnresolvedArgument RexNode and refactor code Signed-off-by: Songkan Tang <[email protected]> * Fix spotless check Signed-off-by: Songkan Tang <[email protected]> --------- Signed-off-by: Songkan Tang <[email protected]> * Fix compiling issue Signed-off-by: Songkan Tang <[email protected]> * Fix java syntax Signed-off-by: Songkan Tang <[email protected]> --------- Signed-off-by: Songkan Tang <[email protected]>
Description
Support relevance query functions pushdown implementation in Calcite
Related Issues
Resolves #3462
Check List
--signoff.By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.