[ES|QL] Precise validation and autocomplete for CASE#244280
[ES|QL] Precise validation and autocomplete for CASE#244280bartoval merged 7 commits intoelastic:mainfrom
Conversation
|
Pinging @elastic/kibana-esql (Team:ESQL) |
| type: 'any', | ||
| }, | ||
| ], | ||
| repeatingParams: [ |
There was a problem hiding this comment.
this might be the thing that we don't like
There was a problem hiding this comment.
I dont like it 😄 The signature is this
signatures: [
{
params: [
{
name: 'condition',
type: 'boolean',
},
{
name: 'value',
type: 'any',
},
],
minParams: 2,
returnType: 'unknown',
},
],
The repeating params seems as a repetition to me. Why don'y you just add a flag: signatureIsRepeating? (the name can change ofc)
About the trailingParam what does the any means here? Don't we want this to be a constant?
...hared/kbn-esql-ast/src/definitions/utils/autocomplete/expressions/operators/partial/utils.ts
Outdated
Show resolved
Hide resolved
src/platform/packages/shared/kbn-esql-validation-autocomplete/src/shared/helpers.ts
Outdated
Show resolved
Hide resolved
|
I find the demonstration video confusing. What exactly are we suggesting here? This is a confusing suggestion. The signatures are:
and this is repetitive So in my head at least, when you have condition then you can suggest an expression but when is a value we should suggest a constant to help the users to fill it in correctly and so on. |
why constant? Types are boolean or any for odd positions and are any for others (including default) |
|
The point is to help them create easily queries like: We can suggest everything else too but the point is to help them to easily write the most common cases which are usually things like the above. The task needs investigation and brainstorming. So I am expecting to have some ideas in order to discuss and take a decision together. I dont know which is the correct solution, I said that yesterday too, I just know that the case suggestions are a bit confusing |
ok, understood |
@stratoula extend suggestions building a map based on the previous context that we can customize time by time with column -> array of values otherwise keep standard behaviour. Here some exapmple export const FUNCTION_SUGGESTION_HINTS = {
case: {
// Position 0, 2, 4... (condition)
0: {
prioritizeFieldTypes: ['boolean'],
},
// Position 1, 3, 5... (value)
1: {
// Level 2: generic defaults
defaultLiterals: {
integer: ['0'],
double: ['0.0'],
boolean: ['true', 'false'],
ip: ['"0.0.0.0"'],
geo_point: ['TO_GEOPOINT("POINT (0,0)")']
...
},
// Level 3: domain-specific values (HIGHEST PRIORITY)
domainValues: { // here a column name previosly present in the previous condition
'agent': ['"Mozilla"', '"Chrome"', '"Safari"', '"Edge"', '"Firefox"'],
'response': ['"200"', '"301"', '"400"', '"404"', '"500"'],
},
},
},
};Do you like the direction? too complicated? Is what you are thinking ? (obviously it's just a draft) |
|
I will check it tmr morning Val and I will let you know! |
|
I like the idea of having something like this I want to show the pairs (condition, value): 1st arg ---> condition. Let' say that the user types I want to investigate if the above is possible with a clean and easy way. If it is not possible let's close this issue. (After some consideration I don't think it is tbh) |
|
Ok I like the first and third argument ideas ++ I dont like the 2nd argument though. No need to go crazy there I think. At least for case I think you just want the user to understand that this is the value applicable for the first solution. I dont thinkt the hardcoded values is the solution here tbh |
bfebe16 to
cca12c3
Compare
0a524ce to
1bccb7d
Compare
1bccb7d to
0c48605
Compare
|
"I'll reopen it and update the description. Let’s see if I opened the fortune cookies. |
stratoula
left a comment
There was a problem hiding this comment.
Looks very nice! Some comments to make it even more easier
|
|
||
| export const valuePlaceholderConstant: ISuggestionItem = withAutoSuggest({ | ||
| label: i18n.translate('kbn-esql-ast.esql.autocomplete.valuePlaceholderLabel', { | ||
| defaultMessage: 'Add a value and let autocomplete "value"', |
There was a problem hiding this comment.
| defaultMessage: 'Add a value and let autocomplete "value"', | |
| defaultMessage: 'Insert value placeholder', |
| asSnippet: true, | ||
| kind: 'Constant', | ||
| detail: i18n.translate('kbn-esql-ast.esql.autocomplete.valuePlaceholderDetail', { | ||
| defaultMessage: 'Insert a value placeholder', |
There was a problem hiding this comment.
| defaultMessage: 'Insert a value placeholder', | |
| defaultMessage: 'Describe the CASE condition', |
stratoula
left a comment
There was a problem hiding this comment.
I really love it! Thanx Val, looks great
💚 Build Succeeded
Metrics [docs]Public APIs missing comments
Page load bundle
cc @bartoval |



Summary
#177118
This enhances the existing logic, which already handles operators, commas, and field filtering based on their position within the
CASEfunction.case.mp4