[ES|QL] Computed suggestions for expression#246421
Conversation
|
Pinging @elastic/kibana-esql (Team:ESQL) |
| }); | ||
|
|
||
| it('suggests WITH after the user writes a param as prompt', async () => { | ||
| await completionExpectSuggestions(`FROM a | COMPLETION ? /`, ['WITH { $0 }']); |
There was a problem hiding this comment.
That's just a test issue because the parser consider ?/ together
| * Finds the rightmost non-variadic operator in an expression tree. | ||
| * Useful for locating the most specific node near the cursor. | ||
| */ | ||
| export function getRightmostNonVariadicOperator(root: ESQLSingleAstItem): ESQLSingleAstItem { |
c486fa1 to
48fa409
Compare
48fa409 to
75921ed
Compare
| if (targetField && !targetField.incomplete) { | ||
| return CompletionPosition.AFTER_TARGET_ID; | ||
| // (function, literal, or existing column) - handle as primaryExpression | ||
| if (isFunctionExpression(expressionRoot) || isLiteral(prompt) || isExistingColumn) { |
There was a problem hiding this comment.
I've refactored Completion logic a bit more than the others . It's more similar to grammar logic and Rerank.
Mainly because I no longer wanted to use external checks like isExpressionComplete. That logic is already inside suggestForExpression, (calling it is not expensive for the cases that were previously handled by the functions we replaced)
5941552 to
ca460b5
Compare
|
Thanks Val and sorry for this. We will merge it immediately after! |
sddonne
left a comment
There was a problem hiding this comment.
Nice refactor! commands looks more simpler now :), found a bug, but it's not being added by this PR.
| } | ||
|
|
||
| /** Computes derived state from the expression context */ | ||
| function computeDerivedState(ctx: ExpressionContext) { |
There was a problem hiding this comment.
| function computeDerivedState(ctx: ExpressionContext) { | |
| function computeDerivedState(ctx: ExpressionContext): ExpressionComputedMetadata { |
There was a problem hiding this comment.
Not related with this PR, but found that rerank is not suggesting the inference_id's (problem is in main too).
getCommandContextis not adding the inference endpoints for RERANK.
Something like this would be needed:
case 'rerank':
return {
inferenceEndpoints:
(await callbacks?.getInferenceEndpoints?.('rerank'))?.inferenceEndpoints || [],
};- When the cursor is inside the empty quotes not suggestions are provided
FROM ebt-kibana-browser | RERANK "Your search query" ON context.branch WITH { "inference_id": "^CURSOR" }
This is becausewithinQuotesis generating an early return here.
Tell me if you want to take those in this PR, otherwise I can wait for this to be merged and create another PR if you want to avoid conflicts.
There was a problem hiding this comment.
Thanks.
Yes, I have to apply the same refactor that I did for Completion here to handle the case. I'll try to make changes here. It should be a mirrior of Completion
01db5e2 to
d7afbae
Compare
💚 Build Succeeded
Metrics [docs]Module Count
Page load bundle
History
cc @bartoval |


Summary
#244952
moved a little bit of unnecessary logic out of the commands
also fixed a couple of bugs