ESQL: Replace [ccq.mode] in favor of a policy prefix#105224
ESQL: Replace [ccq.mode] in favor of a policy prefix#105224elasticsearchmachine merged 3 commits intoelastic:mainfrom
Conversation
For consistency, replace [ccq.mode:<type>] with _<resolution>:policyName `ENRICH [ccq.mode=any] policyName` becomes `ENRICH _any:policyName`
|
Pinging @elastic/es-analytical-engine (Team:Analytics) |
luigidellaquila
left a comment
There was a problem hiding this comment.
Technically the PR looks good.
From a usability point of view I have some doubts, in particular for the syntax mode:policy_name clashing with CCQ syntax cluster_name:index_name.
This feature is specifically for CCQ, so users will easily mix the two things and try ENRICH cluster_name:policy_name, that would also make a lot of sense as an option to explicitly choose which cluster/enrich index you want to use.
If that's in the radar, then we have to take into consideration the fact that cluster names could clash with the keywords we are defining now for CCQ mode (_local, _coordinator, _any).
IMHO this aspect has to be clarified before merging
| ENRICH_POLICY_NAME | ||
| : (LETTER | DIGIT) ENRICH_POLICY_NAME_BODY* | ||
| // allow prefix for the policy to specify its resolution | ||
| : (ENRICH_POLICY_NAME_BODY+ COLON)? ENRICH_POLICY_NAME_BODY+ |
There was a problem hiding this comment.
I guess changing the allowed characters here is on purpose.
Before this change, the policy name only allowed letters or numbers as first char, now any character apart from those explicitly excluded in ENRICH_POLICY_NAME_BODY is allowed.
The good is that it allows all the valid policy names to be used (eg. a policy name can start with $ or .)
The bad is that it also allows invalid policy names, eg. ., .. or names starting with +, _, -
The impact is limited though, because the validation takes care of checking that the policy does not exist.
Most of the problem is for Kibana, that will need further validation outside of the grammar
Digging a bit in the code and performing some tests, If we will consider in the future to support |
|
Enrich policies follow the same rules as an index - see which leads to Essentially The proposed grammar changes overload the meaning of I propose to mark the feature as experimental - which we should do for CCQ as well since it has a different lifecycle than the rest of ESQL. |
b1ad25b to
9c28105
Compare
astefan
left a comment
There was a problem hiding this comment.
I've checked with Nhat to confirm it makes little sense to refer to a policy from a remote cluster - it's more likely that if such ability is created, it would be done inside the policy itself on each individual cluster.
That is ENRICH remote-cluster:some-policy is highly unlikely at the moment.
Assuming it will, in that scenario one way to disambiguate is to use double qualifiers:
ENRICH _any:remote-cluster:some-policy or come up at the time with another character.
I am ok with the change given the fairly certain aspect of cluster name aliases not being used in the future or being integrated differently.
I propose to mark the feature as experimental - which we should do for CCQ as well since it has a different lifecycle than the rest of ESQL.
👍
bpintea
left a comment
There was a problem hiding this comment.
Indeed, there's some room for initial confusion, but IMO the fact that there's no way to accidentally execute the query in an unexpected way contains it. Once you hit the first error (and dip in the documentation, which will generally have to happen before executing an ENRICH, whose policy setting up is a more involved process) the user should be set on the right path.
I don't find the syntax involving a prefixing _ particularly pretty (even after understanding its necessity).
I do find the existing ENRICH <config> <policy> ... syntax better overall (and inline with other similar languages), but not having a better alternative when:
- having to drop the
[]usage; - not wanting to introduce another keyword, which would break the command's flow.
So will 👍 and maybe we can still iterate, if marking it as experimental.
luigidellaquila
left a comment
There was a problem hiding this comment.
I propose to mark the feature as experimental - which we should do for CCQ as well since it has a different lifecycle than the rest of ESQL.
With this assumption LGTM, we'll have time to see if it's a real UX problem (and in case we'll have a little margin to fix it) or if we are just overestimating its impact
## Summary Sync with elastic/elasticsearch#104958 for support of builtin fn in STATS * validation ✅ * autocomplete ✅ * also fixed `STATS BY <field>` syntax  Sync with elastic/elasticsearch#104913 for new `log` function * validation ✅ - also warning for negative values * autocomplete ✅  Sync with elastic/elasticsearch#105064 for removal of `PROJECT` command * validation ✅ (both new and legacy syntax supported) * autocomplete ✅ (will only suggest new syntax)  Sync with elastic/elasticsearch#105221 for removal of mandatory brackets for `METADATA` command option * validation ✅ (added warning deprecation message when using brackets) * autocomplete ✅  Sync with elastic/elasticsearch#105224 for change of syntax for ENRICH ccq mode * validation ✅ * autocomplete ✅ (not directly promoted, the user has to type `_` to trigger it) * hover ✅ * code actions ✅   Do not merge until those 5 get merged. Additional things in this PR: * Added more tests for `callbacks` not passed scenario * covered more cases like those with `dissect` * Added more tests for signature params number (calling a function with an extra arg should return an error) * Cleaned up some more unused code * Improved messages on too many arguments for functions ### Checklist - [x] [Unit or functional tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html) were updated or added to match the most common scenarios
## Summary Sync with elastic/elasticsearch#104958 for support of builtin fn in STATS * validation ✅ * autocomplete ✅ * also fixed `STATS BY <field>` syntax  Sync with elastic/elasticsearch#104913 for new `log` function * validation ✅ - also warning for negative values * autocomplete ✅  Sync with elastic/elasticsearch#105064 for removal of `PROJECT` command * validation ✅ (both new and legacy syntax supported) * autocomplete ✅ (will only suggest new syntax)  Sync with elastic/elasticsearch#105221 for removal of mandatory brackets for `METADATA` command option * validation ✅ (added warning deprecation message when using brackets) * autocomplete ✅  Sync with elastic/elasticsearch#105224 for change of syntax for ENRICH ccq mode * validation ✅ * autocomplete ✅ (not directly promoted, the user has to type `_` to trigger it) * hover ✅ * code actions ✅   Do not merge until those 5 get merged. Additional things in this PR: * Added more tests for `callbacks` not passed scenario * covered more cases like those with `dissect` * Added more tests for signature params number (calling a function with an extra arg should return an error) * Cleaned up some more unused code * Improved messages on too many arguments for functions ### Checklist - [x] [Unit or functional tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html) were updated or added to match the most common scenarios
## Summary Sync with elastic/elasticsearch#104958 for support of builtin fn in STATS * validation ✅ * autocomplete ✅ * also fixed `STATS BY <field>` syntax  Sync with elastic/elasticsearch#104913 for new `log` function * validation ✅ - also warning for negative values * autocomplete ✅  Sync with elastic/elasticsearch#105064 for removal of `PROJECT` command * validation ✅ (both new and legacy syntax supported) * autocomplete ✅ (will only suggest new syntax)  Sync with elastic/elasticsearch#105221 for removal of mandatory brackets for `METADATA` command option * validation ✅ (added warning deprecation message when using brackets) * autocomplete ✅  Sync with elastic/elasticsearch#105224 for change of syntax for ENRICH ccq mode * validation ✅ * autocomplete ✅ (not directly promoted, the user has to type `_` to trigger it) * hover ✅ * code actions ✅   Do not merge until those 5 get merged. Additional things in this PR: * Added more tests for `callbacks` not passed scenario * covered more cases like those with `dissect` * Added more tests for signature params number (calling a function with an extra arg should return an error) * Cleaned up some more unused code * Improved messages on too many arguments for functions ### Checklist - [x] [Unit or functional tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html) were updated or added to match the most common scenarios
For consistency, replace [ccq.mode:] with _:policyName
ENRICH [ccq.mode=any] policyNamebecomesENRICH _any:policyName