Skip to content

[ES|QL] Deep check if CHANGE_POINT ON option has any contents#216093

Merged
vadimkibana merged 2 commits intoelastic:mainfrom
vadimkibana:esql-change-point-empty-on
Mar 27, 2025
Merged

[ES|QL] Deep check if CHANGE_POINT ON option has any contents#216093
vadimkibana merged 2 commits intoelastic:mainfrom
vadimkibana:esql-change-point-empty-on

Conversation

@vadimkibana
Copy link
Contributor

@vadimkibana vadimkibana commented Mar 26, 2025

Summary

When ON option in CHANGE_POINT has no value, it is invalid syntax according ANTLR grammar. However, ANTLR does not fail but succeeds and returns a column name, which is an empty string.

Hence, in the past we created an ON option with an empty column name, but marked as incomplete: true.

Screenshot 2025-03-26 at 18 13 32

All of the above, IMO, relies on the ANTLR's behavior of trying to parse even invalid input, and mark some nodes with exception. This behavior is somewhat a "black box", not something we should rely on, as ANTLR will be able to parse or not invalid input depending on the complexity of the grammar rule at hand, and the rules themselves change over time.

Hence, better and more consistent, to not mark nodes as incomplete but not generate the ON option altogether. This PR does a deep check, simple string check, to see if there is anything in the ON option at all, if not, it does not generate it.

Checklist

@vadimkibana vadimkibana requested a review from a team as a code owner March 26, 2025 17:30
@vadimkibana vadimkibana added bug Fixes for quality problems that affect the customer experience review release_note:skip Skip the PR/issue when compiling release notes Feature:ES|QL ES|QL related features in Kibana Team:ESQL ES|QL related features in Kibana t// backport:version Backport to applied version labels v9.1.0 v8.19.0 labels Mar 26, 2025
@elasticmachine
Copy link
Contributor

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

@vadimkibana vadimkibana enabled auto-merge (squash) March 26, 2025 17:46
@elasticmachine
Copy link
Contributor

💚 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 3.6MB 3.6MB +18.0B

@stratoula stratoula requested a review from darnautov March 27, 2025 06:27
@stratoula
Copy link
Contributor

@darnautov can you take this code review?

Copy link
Contributor

@darnautov darnautov left a comment

Choose a reason for hiding this comment

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

LGTM

command.args.push(value);

if (ctx._key) {
if (ctx._key && ctx._key.getText()) {
Copy link
Contributor

Choose a reason for hiding this comment

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

❓ do we need the same check with getText for ctx._targetType && ctx._targetPvalue?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No. If it was only ctx._targetType we would need the check but because it is ctx._targetType && ctx._targetPvalue we don't need it. ANTLR does not generate an empty identifier for pvalue, only for target.

@vadimkibana vadimkibana merged commit f7d8bc3 into elastic:main Mar 27, 2025
9 checks passed
@kibanamachine
Copy link
Contributor

Starting backport for target branches: 8.x

https://github.com/elastic/kibana/actions/runs/14103787549

kibanamachine pushed a commit to kibanamachine/kibana that referenced this pull request Mar 27, 2025
…astic#216093)

## Summary

When `ON` option in `CHANGE_POINT` has no value, it is invalid syntax
according ANTLR grammar. However, ANTLR does not fail but succeeds and
returns a column name, which is an empty string.

Hence, in the past we created an `ON` option with an empty column name,
but marked as `incomplete: true`, beucause ANTLR at least told us that.

<img width="295" alt="Screenshot 2025-03-26 at 18 13 32"
src="https://github.com/user-attachments/assets/b5fd4512-04a2-48b3-b874-1ea35a3c7e84"
/>

All of the above, IMO, relies on the ANTLR's behavior of trying to parse
even invalid input, and mark some nodes with exception. This behavior is
somewhat a "black box", not something we should rely on, as ANTLR will
be able to parse or not invalid input depending on the complexity of the
grammar rule at hand, and the rules themselves change over time.

Hence, better and more consistent, to not mark nodes as `incomplete` but
not generate the `ON` option altogether. This PR does a deep check,
simple string check, to see if there is anything in the `ON` option at
all, if not, it does not generate it.

### 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

(cherry picked from commit f7d8bc3)
@kibanamachine
Copy link
Contributor

💚 All backports created successfully

Status Branch Result
8.x

Note: Successful backport PRs will be merged automatically after passing CI.

Questions ?

Please refer to the Backport tool documentation

@kibanamachine kibanamachine added the backport missing Added to PRs automatically when the are determined to be missing a backport. label Mar 31, 2025
@kibanamachine
Copy link
Contributor

Looks like this PR has a backport PR but it still hasn't been merged. Please merge it ASAP to keep the branches relatively in sync.

kibanamachine added a commit that referenced this pull request Mar 31, 2025
…ts (#216093) (#216136)

# Backport

This will backport the following commits from `main` to `8.x`:
- [[ES|QL] Deep check if `CHANGE_POINT` `ON` option has any contents
(#216093)](#216093)

<!--- Backport version: 9.6.6 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sorenlouv/backport)

<!--BACKPORT [{"author":{"name":"Vadim
Kibana","email":"82822460+vadimkibana@users.noreply.github.com"},"sourceCommit":{"committedDate":"2025-03-27T09:59:48Z","message":"[ES|QL]
Deep check if `CHANGE_POINT` `ON` option has any contents
(#216093)\n\n## Summary\n\nWhen `ON` option in `CHANGE_POINT` has no
value, it is invalid syntax\naccording ANTLR grammar. However, ANTLR
does not fail but succeeds and\nreturns a column name, which is an empty
string.\n\nHence, in the past we created an `ON` option with an empty
column name,\nbut marked as `incomplete: true`, beucause ANTLR at least
told us that.\n\n<img width=\"295\" alt=\"Screenshot 2025-03-26 at 18 13
32\"\nsrc=\"https://github.com/user-attachments/assets/b5fd4512-04a2-48b3-b874-1ea35a3c7e84\"\n/>\n\nAll
of the above, IMO, relies on the ANTLR's behavior of trying to
parse\neven invalid input, and mark some nodes with exception. This
behavior is\nsomewhat a \"black box\", not something we should rely on,
as ANTLR will\nbe able to parse or not invalid input depending on the
complexity of the\ngrammar rule at hand, and the rules themselves change
over time.\n\nHence, better and more consistent, to not mark nodes as
`incomplete` but\nnot generate the `ON` option altogether. This PR does
a deep check,\nsimple string check, to see if there is anything in the
`ON` option at\nall, if not, it does not generate it.\n\n\n###
Checklist\n\n- [x] [Unit or
functional\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\nwere
updated or added to match the most common
scenarios","sha":"f7d8bc3c25663ebd5e473087790e3a53c4901548","branchLabelMapping":{"^v9.1.0$":"main","^v8.19.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["bug","review","release_note:skip","Feature:ES|QL","Team:ESQL","backport:version","v9.1.0","v8.19.0"],"title":"[ES|QL]
Deep check if `CHANGE_POINT` `ON` option has any
contents","number":216093,"url":"https://github.com/elastic/kibana/pull/216093","mergeCommit":{"message":"[ES|QL]
Deep check if `CHANGE_POINT` `ON` option has any contents
(#216093)\n\n## Summary\n\nWhen `ON` option in `CHANGE_POINT` has no
value, it is invalid syntax\naccording ANTLR grammar. However, ANTLR
does not fail but succeeds and\nreturns a column name, which is an empty
string.\n\nHence, in the past we created an `ON` option with an empty
column name,\nbut marked as `incomplete: true`, beucause ANTLR at least
told us that.\n\n<img width=\"295\" alt=\"Screenshot 2025-03-26 at 18 13
32\"\nsrc=\"https://github.com/user-attachments/assets/b5fd4512-04a2-48b3-b874-1ea35a3c7e84\"\n/>\n\nAll
of the above, IMO, relies on the ANTLR's behavior of trying to
parse\neven invalid input, and mark some nodes with exception. This
behavior is\nsomewhat a \"black box\", not something we should rely on,
as ANTLR will\nbe able to parse or not invalid input depending on the
complexity of the\ngrammar rule at hand, and the rules themselves change
over time.\n\nHence, better and more consistent, to not mark nodes as
`incomplete` but\nnot generate the `ON` option altogether. This PR does
a deep check,\nsimple string check, to see if there is anything in the
`ON` option at\nall, if not, it does not generate it.\n\n\n###
Checklist\n\n- [x] [Unit or
functional\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\nwere
updated or added to match the most common
scenarios","sha":"f7d8bc3c25663ebd5e473087790e3a53c4901548"}},"sourceBranch":"main","suggestedTargetBranches":["8.x"],"targetPullRequestStates":[{"branch":"main","label":"v9.1.0","branchLabelMappingKey":"^v9.1.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/216093","number":216093,"mergeCommit":{"message":"[ES|QL]
Deep check if `CHANGE_POINT` `ON` option has any contents
(#216093)\n\n## Summary\n\nWhen `ON` option in `CHANGE_POINT` has no
value, it is invalid syntax\naccording ANTLR grammar. However, ANTLR
does not fail but succeeds and\nreturns a column name, which is an empty
string.\n\nHence, in the past we created an `ON` option with an empty
column name,\nbut marked as `incomplete: true`, beucause ANTLR at least
told us that.\n\n<img width=\"295\" alt=\"Screenshot 2025-03-26 at 18 13
32\"\nsrc=\"https://github.com/user-attachments/assets/b5fd4512-04a2-48b3-b874-1ea35a3c7e84\"\n/>\n\nAll
of the above, IMO, relies on the ANTLR's behavior of trying to
parse\neven invalid input, and mark some nodes with exception. This
behavior is\nsomewhat a \"black box\", not something we should rely on,
as ANTLR will\nbe able to parse or not invalid input depending on the
complexity of the\ngrammar rule at hand, and the rules themselves change
over time.\n\nHence, better and more consistent, to not mark nodes as
`incomplete` but\nnot generate the `ON` option altogether. This PR does
a deep check,\nsimple string check, to see if there is anything in the
`ON` option at\nall, if not, it does not generate it.\n\n\n###
Checklist\n\n- [x] [Unit or
functional\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\nwere
updated or added to match the most common
scenarios","sha":"f7d8bc3c25663ebd5e473087790e3a53c4901548"}},{"branch":"8.x","label":"v8.19.0","branchLabelMappingKey":"^v8.19.0$","isSourceBranch":false,"state":"NOT_CREATED"}]}]
BACKPORT-->

Co-authored-by: Vadim Kibana <82822460+vadimkibana@users.noreply.github.com>
Co-authored-by: Stratoula Kalafateli <efstratia.kalafateli@elastic.co>
@kibanamachine kibanamachine removed the backport missing Added to PRs automatically when the are determined to be missing a backport. label Mar 31, 2025
cqliu1 pushed a commit to cqliu1/kibana that referenced this pull request Mar 31, 2025
…astic#216093)

## Summary

When `ON` option in `CHANGE_POINT` has no value, it is invalid syntax
according ANTLR grammar. However, ANTLR does not fail but succeeds and
returns a column name, which is an empty string.

Hence, in the past we created an `ON` option with an empty column name,
but marked as `incomplete: true`, beucause ANTLR at least told us that.

<img width="295" alt="Screenshot 2025-03-26 at 18 13 32"
src="https://github.com/user-attachments/assets/b5fd4512-04a2-48b3-b874-1ea35a3c7e84"
/>

All of the above, IMO, relies on the ANTLR's behavior of trying to parse
even invalid input, and mark some nodes with exception. This behavior is
somewhat a "black box", not something we should rely on, as ANTLR will
be able to parse or not invalid input depending on the complexity of the
grammar rule at hand, and the rules themselves change over time.

Hence, better and more consistent, to not mark nodes as `incomplete` but
not generate the `ON` option altogether. This PR does a deep check,
simple string check, to see if there is anything in the `ON` option at
all, if not, it does not generate it.


### 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport:version Backport to applied version labels bug Fixes for quality problems that affect the customer experience Feature:ES|QL ES|QL related features in Kibana release_note:skip Skip the PR/issue when compiling release notes review Team:ESQL ES|QL related features in Kibana t// v8.19.0 v9.1.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants