-
Notifications
You must be signed in to change notification settings - Fork 8.5k
[ES|QL] SET header instruction parsing
#236460
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
4c56f6b to
21002d4
Compare
SET header instructionsSET header instruction parsing
|
Pinging @elastic/kibana-esql (Team:ESQL) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! I like this header property!
| const result = parseEsqlQuery(esqlQuery); | ||
| expect(result.errors.length).toEqual(1); | ||
| expect(result.errors[0].message.startsWith('SyntaxError:')).toBeTruthy(); | ||
| expect(result.errors.length > 0).toEqual(true); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we expect a precise errors number? What if there are unexpected error pop up due to a bug?
In case it's still preferable to track any number of errors it'd be nice to add a shot comment explaining why more than one error is expected. And additionally a small improvement to the assertion could be done
| expect(result.errors.length > 0).toEqual(true); | |
| expect(result.errors.length).toBeGreaterThan(0); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have moved it back to one error to get it approved: 37d53a8
The reason for not relying on one error is because it is the internals of the parser how many errors it returns, and it sometimes changes over time as the ES|QL language evolves.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@vadimkibana Thanks for addressing my comment 🙏
💚 Build Succeeded
Metrics [docs]Public APIs missing comments
Async chunks
Public APIs missing exports
Page load bundle
History
|
## Summary Closes elastic#233942 Implements parsing for `SET` pseudo-commands, which come before the main query. ``` SET key1 = 123; SET key2 = "asdf"; FROM index | LIMIT 123 ``` In `query` AST node introduces `header` section, which contain AST nodes before the main command. Although each `SET` instruction can now have a single key-value pair, it is implemented such that it will be able to store a list of those pairs. The reason is because in Elasticsearch team first implemented it to hold multiple key-value pairs, then changed to store only one, further they commented ([see thread](elastic/elasticsearch#134029)) that they may add support for a list of key-value pairs to `SET` back. ### 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
Partially addresses #233942
Implements parsing for
SETpseudo-commands, which come before the main query.In
queryAST node introducesheadersection, which contain AST nodes before the main command.Although each
SETinstruction can now have a single key-value pair, it is implemented such that it will be able to store a list of those pairs. The reason is because in Elasticsearch team first implemented it to hold multiple key-value pairs, then changed to store only one, further they commented (see thread) that they may add support for a list of key-value pairs toSETback.Checklist