Skip to content

feat: Wrapping pretty-printer implementation for PromQL#47

Merged
vadimkibana merged 14 commits into
mainfrom
promql-pretty-printer-2
Mar 13, 2026
Merged

feat: Wrapping pretty-printer implementation for PromQL#47
vadimkibana merged 14 commits into
mainfrom
promql-pretty-printer-2

Conversation

@vadimkibana
Copy link
Copy Markdown
Collaborator

@vadimkibana vadimkibana commented Mar 5, 2026

Summary

Partially addresses: elastic/kibana#242923

This PR add pretty-printing for PromQL and integrates ES|QL and PromQL pretty printers so they work together to print an ES|QL query which might have PROMQ command with a nested PromQL subquery.

Visual Examples

PromQL wrapping pretty printer in action:

Kapture 2026-03-12 at 15 02 57

Before

(note: PromQL query is not formatted, it uses .text (visible ANTLR stream) property as returned by the parser):

Kapture 2026-03-12 at 14 46 43

After

Kapture 2026-03-12 at 14 44 06

In this PR

  • Implements PromQL wrapping pretty-printer in src/embedded_languages/promql/pretty_print/
  • Adds support to Visitor API in src/ast/visitor/ to traverse PromQL query expressions. Use the new "visitPromqlExpression" to format PromQL sub-queries in basic and wrapping ES|QL pretty-printers.
  • Sets up Storybook in .storybook/ for visual testing. Run it with yarn storybook.
  • Adds visual tests in src/stories/, some of them you can see in screen captures of above.

Details

Technical details, breaking changes or considerations you have made while working in this PR.

Checklist

  • Unit tests have been added or updated.
  • The proper documentation has been added or updated.
  • If this PR contains breaking changes, you have explained them using the BREAKING CHANGE: change syntax.
  • The PR title has the correct conventional commit label in the title, this is crucial for the correct versioning of this package. Check the following cheat shit.
    Title Label Release
    breaking: true (!) major
    feat minor
    fix patch
    refactor patch
    perf patch
    build patch
    docs patch
    chore patch
    revert patch

Base automatically changed from universal-pretty-printer to main March 6, 2026 12:11
@vadimkibana vadimkibana force-pushed the promql-pretty-printer-2 branch from a1b22e4 to dce44e8 Compare March 10, 2026 22:40
@vadimkibana vadimkibana changed the title feat: wrapping pretty printing for promql feat: wrapping pretty printing for PromQL Mar 10, 2026
@vadimkibana vadimkibana marked this pull request as ready for review March 12, 2026 14:04
@vadimkibana vadimkibana requested a review from a team as a code owner March 12, 2026 14:04
@vadimkibana vadimkibana changed the title feat: wrapping pretty printing for PromQL feat: Wrapping pretty-printer implementation for PromQL Mar 12, 2026
Copy link
Copy Markdown
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.

This is so nice Vadim! I really like the separation between the PromQL wrapping printer and its integration into the ES|QL wrapping printer. LGTM!

Comment thread package.json
"semantic-release:dry-run": "semantic-release --dry-run --debug",
"prepare": "husky"
"prepare": "husky",
"storybook": "storybook dev -p 6006",
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

❤️

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This is a typo right? You mean WithSilder

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Yeah, should be WithSlider :)

@vadimkibana vadimkibana merged commit 6631080 into main Mar 13, 2026
3 checks passed
@vadimkibana vadimkibana deleted the promql-pretty-printer-2 branch March 13, 2026 11:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants