-
Notifications
You must be signed in to change notification settings - Fork 25.6k
ES|QL completion command constant folding #138112
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
ES|QL completion command constant folding #138112
Conversation
…tion plan into a foldable expression.
|
Pinging @elastic/es-search-relevance (Team:Search Relevance) |
|
Hi @afoucret, I've created a changelog YAML for you. |
carlosdelest
left a comment
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.
This LGTM 👍
I was wondering if some rules could be taken out of the Analyzer - like transforming the command into an Eval - but I don't see a special benefit out of it, and I prefer to have all the related transformations in one place 👍
Folding is straightforward and incorporated into the InferencePlan.
ioanatia
left a comment
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 added some non blocking comments that you can address before merging
| // Test that a foldable Completion plan (with literal prompt) is transformed to Eval with CompletionFunction | ||
| LogicalPlan plan = analyze(""" | ||
| FROM books METADATA _score | ||
| | COMPLETION "Translate this text in French" WITH { "inference_id" : "completion-inference-id" } |
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.
can we add another test, where we have something like:
FROM books METADATA _score
| EVAL prompt = "Translate this text in", language = "French"
| COMPLETION concat(prompt, language) WITH ....
so we not only test for literals which are always foldable, but also foldable expressions that are not literals.
|
|
||
| /** | ||
| * COMPLETION function generates text completions from a prompt using an inference endpoint. | ||
| * This function is not registered in the function registry. |
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.
can we add more details here, that this is only used for optimizing the COMPLETION command when we deal with a foldable prompt with some example, that this should never be added to the function registry, since we don't have support for async functions etc.
Summary
This PR implements constant folding support for ESQL
COMPLETIONinference plans, allowing completion operations with constant prompts to be evaluated at optimization time rather than at query execution time.Closes #136863
Technical Details
is internally rewritten into