Skip to content

[ES|QL] auto bucket and constant-only parameter improvements#180509

Merged
drewdaemon merged 11 commits intoelastic:mainfrom
drewdaemon:180061/auto-bucket-should-accept-date
Apr 16, 2024
Merged

[ES|QL] auto bucket and constant-only parameter improvements#180509
drewdaemon merged 11 commits intoelastic:mainfrom
drewdaemon:180061/auto-bucket-should-accept-date

Conversation

@drewdaemon
Copy link
Copy Markdown
Contributor

@drewdaemon drewdaemon commented Apr 10, 2024

Summary

Close #180061

Key fixes

  • auto_bucket
  • Constant-only parameters
    • We no longer suggest fields or variables for auto-bucket's 2nd, 3rd, and 4th parameters, all of which must be constants
    • Validator catches non-constants even if they are nested in layers of functions (e.g. auto_bucket(@timestamp, abs(length(bytes)), "", ""))

Outstanding issues

  • Validation catches fields in a constant-only parameter spot, but not if they are nested in a function
Screenshot 2024-04-10 at 11 31 38 AM

Validator sees the problem

Screenshot 2024-04-10 at 11 31 14 AM

Validator doesn't see the problem

Checklist

@drewdaemon drewdaemon changed the title [ES|QL] auto bucket should accept date [ES|QL] auto bucket and constant-only parameter improvements Apr 10, 2024
@drewdaemon drewdaemon force-pushed the 180061/auto-bucket-should-accept-date branch from 130eff6 to 51b1635 Compare April 10, 2024 19:55
@drewdaemon
Copy link
Copy Markdown
Contributor Author

/ci

@drewdaemon drewdaemon added release_note:fix Team:ESQL ES|QL related features in Kibana t// labels Apr 11, 2024
@drewdaemon drewdaemon marked this pull request as ready for review April 11, 2024 15:11
@drewdaemon drewdaemon requested a review from a team as a code owner April 11, 2024 15:11
@elasticmachine
Copy link
Copy Markdown
Contributor

Pinging @elastic/kibana-esql (Team:ESQL)

@drewdaemon
Copy link
Copy Markdown
Contributor Author

drewdaemon commented Apr 11, 2024

One open question: how do we want the highlighting and messaging to work in the case of a nested non-constant?

e.g. given auto_bucket(@timestamp, avg(length(bytes)), ...)

only bytes is currently highlighted and the message reads

Argument of [length] must be a constant, received [bytes]

Questions

  • What do we want to highlight? Just the field or the whole argument to auto_bucket?
  • What do we want the message to be? I could see the current message being confusing because length isn't actually where the constant-only constraint is coming from.

WDYT @stratoula ?

@stratoula
Copy link
Copy Markdown
Contributor

@drewdaemon thanx, I played with it and seems really nice

What do we want to highlight?

Yes the entire argument, otherwise is weird

The messaging

Yes it is confusing
image

I suggest something simple as this argument for bucket should be a constant and highlight the entire argument

name: string;
description: string;
args?: Array<{ name: string; type: string; value: string; literalOnly?: boolean }>;
args?: Array<{ name: string; type: string; value: string; constantOnly?: boolean }>;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why this renaming?

In ES|QL there's the concept of literal but not of constant (which is an Monaco concept).

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, I was hoping this change would align us closer with ES since they use "constant" in their error messages. Wasn't aware of the Monaco thing.

[esql] > Unexpected error from Elasticsearch: verification_exception - Found 1 problem
line 1:51: second argument of [bucket(bytes, bytes, 30, 20)] must be a constant, received [bytes]

WDYT?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes makes sense 👍

@drewdaemon
Copy link
Copy Markdown
Contributor Author

drewdaemon commented Apr 12, 2024

@stratoula I've condensed the error messages and highlighting so they make more sense.

Screenshot 2024-04-12 at 2 20 17 PM

To your other point

I suggest something simple as this argument for bucket should be a constant

I think this could be a nice improvement.

Right now, all the error messages follow a similar pattern (see packages/kbn-esql-validation-autocomplete/src/validation/errors.ts). Because of this, I think that if we want to revisit this messaging, we should do it holistically as a separate effort. WDYT?

Also, maybe @dej611 has some input on the thinking behind the way the error messages are currently formatted?

@dej611
Copy link
Copy Markdown
Contributor

dej611 commented Apr 15, 2024

I think this could be a nice improvement.

Right now, all the error messages follow a similar pattern (see packages/kbn-esql-validation-autocomplete/src/validation/errors.ts). Because of this, I think that if we want to revisit this messaging, we should do it holistically as a separate effort. WDYT?

In general if there's an existing ES error message for something I think we should adopt their message to avoid confusion for the user. I see the current message is diverging from the current ES one who puts the entire bucket signature within the []:

Argument of [bucket] must be a constant, received [abs(length(bytes))]

vs

Argument of [bucket(bytes,abs(length(bytes)), 20, 30)] must be a constant, received [abs(length(bytes))]

The messaging copy used for the non-ES messages are using the same baseline as the other ES ones.

As for the highlight problem, I have a dilemma there as in terms of visual feedback I think it's better, but the error message provided does not provide the right information to the user. Perhaps nested vs nested scenarios ought to have two distinct messages? I think this should also be discussed with the ES team as well to align.

As for now, I think it is ok to unblock on the full function highlight + error message.

@drewdaemon
Copy link
Copy Markdown
Contributor Author

@elasticmachine merge upstream

@kibana-ci
Copy link
Copy Markdown

💚 Build Succeeded

Metrics [docs]

Page load bundle

Size of the bundles that are downloaded on every page load. Target size is below 100kb

id before after diff
kbnUiSharedDeps-srcJs 2.9MB 2.9MB +1.4KB

History

To update your PR or re-run it, just comment with:
@elasticmachine merge upstream

@stratoula
Copy link
Copy Markdown
Contributor

stratoula commented Apr 16, 2024

@drewdaemon I don't think you can backport, in 8.13 it was auto_bucket. The bug is a client side validation one, it is annoying I agree but I think is ok as we are in tech preview in 8.13. Also there will be no other patch for 8.13 as I can see

If you added this for the FF I think if you merge it today, we are fine!

@stratoula stratoula added Feature:ES|QL ES|QL related features in Kibana and removed backport:prev-minor labels Apr 16, 2024
Copy link
Copy Markdown
Contributor

@stratoula stratoula left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am fine with the messaging and the highlight, it is much more clear than before. I can see the difference with ES that Marco mentioned, we could align but honestly I find our message more clear so I am fine on proceeding with this small difference. 👍

@drewdaemon
Copy link
Copy Markdown
Contributor Author

@stratoula the backport was to get it into 8.14. However, I'm glad you mentioned this because it looks like it hasn't been branched yet.

I'm not worried about ff because I consider this a set of bug fixes 👍

@drewdaemon drewdaemon merged commit 0b9847d into elastic:main Apr 16, 2024
@kibanamachine kibanamachine added the backport:skip This PR does not require backporting label Apr 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport:skip This PR does not require backporting Feature:ES|QL ES|QL related features in Kibana release_note:fix Team:ESQL ES|QL related features in Kibana t// v8.14.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[ES|QL] auto_bucket doesn't accept arg of type date

6 participants