Skip to content

Conversation

@vadimkibana
Copy link
Contributor

@vadimkibana vadimkibana commented Sep 25, 2025

Summary

Partially addresses #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) that they may add support for a list of key-value pairs to SET back.

Checklist

@vadimkibana vadimkibana force-pushed the esql-set-instruction-2 branch from 4c56f6b to 21002d4 Compare October 1, 2025 08:14
@vadimkibana vadimkibana changed the title WIP: [ES|QL] SET header instructions [ES|QL] SET header instruction parsing Oct 1, 2025
@vadimkibana vadimkibana marked this pull request as ready for review October 1, 2025 08:18
@vadimkibana vadimkibana requested a review from a team as a code owner October 1, 2025 08:18
@vadimkibana vadimkibana added review release_note:skip Skip the PR/issue when compiling release notes backport:skip This PR does not require backporting Feature:ES|QL ES|QL related features in Kibana Team:ESQL ES|QL related features in Kibana t// v9.3.0 labels Oct 1, 2025
@elasticmachine
Copy link
Contributor

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

@vadimkibana vadimkibana added v9.2.0 and removed v9.3.0 labels Oct 1, 2025
Copy link
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.

LGTM! I like this header property!

@vadimkibana vadimkibana enabled auto-merge (squash) October 2, 2025 13:37
@vadimkibana vadimkibana requested review from a team as code owners October 6, 2025 10:09
@vadimkibana vadimkibana requested review from maximpn and rylnd October 6, 2025 10:10
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);
Copy link
Contributor

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

Suggested change
expect(result.errors.length > 0).toEqual(true);
expect(result.errors.length).toBeGreaterThan(0);

Copy link
Contributor Author

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.

Copy link
Contributor

@maximpn maximpn left a 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 🙏

@vadimkibana vadimkibana merged commit a9739dc into elastic:main Oct 6, 2025
12 checks passed
@elasticmachine
Copy link
Contributor

💚 Build Succeeded

Metrics [docs]

Public APIs missing comments

Total count of every public API that lacks a comment. Target amount is 0. Run node scripts/build_api_docs --plugin [yourplugin] --stats comments for more detailed information.

id before after diff
@kbn/esql-ast 562 563 +1

Async chunks

Total size of all lazy-loaded chunks that will be downloaded as the user navigates the app

id before after diff
securitySolution 11.1MB 11.1MB +929.0B

Public APIs missing exports

Total count of every type that is part of your API that should be exported but is not. This will cause broken links in the API documentation system. Target amount is 0. Run node scripts/build_api_docs --plugin [yourplugin] --stats exports for more detailed information.

id before after diff
@kbn/esql-ast 42 43 +1

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.9MB 3.9MB +965.0B
Unknown metric groups

API count

id before after diff
@kbn/esql-ast 737 738 +1

History

rylnd pushed a commit to rylnd/kibana that referenced this pull request Oct 17, 2025
## 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
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:skip Skip the PR/issue when compiling release notes review Team:ESQL ES|QL related features in Kibana t// v9.2.0 v9.3.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants