Skip to content
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

[ES|QL] Traversal high level APIs #189957

Merged
merged 13 commits into from
Aug 6, 2024

Conversation

vadimkibana
Copy link
Contributor

@vadimkibana vadimkibana commented Aug 6, 2024

Summary

Closes #182255

Implements high-level AST node finding APIs, which satisfy requirements in #182255

  • Introduces "visitAny" callback, which capture any AST node (not captured by a more specific callback).
  • Walker.find(ast, predicate) — finds the first AST node that satisfies a predicate condition.
  • Walker.findAll(ast, predicate) — finds all AST nodes that satisfies a predicate condition.
  • Walker.match(ast, template) — finds the first AST node that matches the provided node template.
  • Walker.matchAll(ast, template) — finds all AST nodes that match the provided node template.

For example, here is how you find all agg1 and agg2 function nodes:

const nodes = Walker.matchAll(ast, { type: 'function', name: ['agg1', 'agg2'] });

Checklist

Delete any items that are not applicable to this PR.

  • Documentation was added for features that require explanation or tutorials

For maintainers

@vadimkibana vadimkibana requested a review from a team as a code owner August 6, 2024 09:46
@vadimkibana vadimkibana added review release_note:skip Skip the PR/issue when compiling release notes Team:DataDiscovery Discover, search (e.g. data plugin and KQL), data views, saved searches. For ES|QL, use Team:ES|QL. Feature:ES|QL ES|QL related features in Kibana Team:ESQL ES|QL related features in Kibana v8.16.0 labels Aug 6, 2024
@elasticmachine
Copy link
Contributor

Pinging @elastic/kibana-data-discovery (Team:DataDiscovery)

@elasticmachine
Copy link
Contributor

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

@kibana-ci
Copy link
Collaborator

💛 Build succeeded, but was flaky

Failed CI Steps

Test Failures

  • [job] [logs] Jest Tests #10 / Create renders correctly with default values
  • [job] [logs] Jest Tests #10 / Create updates the value correctly

Metrics [docs]

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 13 15 +2

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.3MB 3.3MB +863.0B
Unknown metric groups

API count

id before after diff
@kbn/esql-ast 135 149 +14

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

@vadimkibana vadimkibana enabled auto-merge (squash) August 6, 2024 11:59
Copy link
Contributor

@drewdaemon drewdaemon left a comment

Choose a reason for hiding this comment

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

Beautifully done 👏

@vadimkibana vadimkibana merged commit 7332211 into elastic:main Aug 6, 2024
34 checks passed
@kibanamachine kibanamachine added the backport:skip This commit does not require backporting label Aug 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport:skip This commit 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:DataDiscovery Discover, search (e.g. data plugin and KQL), data views, saved searches. For ES|QL, use Team:ES|QL. Team:ESQL ES|QL related features in Kibana v8.16.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[ES|QL] AST traversal API
5 participants