-
Notifications
You must be signed in to change notification settings - Fork 8.2k
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] Implements wrapping pretty-printer #190589
Merged
vadimkibana
merged 3 commits into
elastic:main
from
vadimkibana:esql-pretty-print-multi-line-2
Aug 20, 2024
Merged
[ES|QL] Implements wrapping pretty-printer #190589
vadimkibana
merged 3 commits into
elastic:main
from
vadimkibana:esql-pretty-print-multi-line-2
Aug 20, 2024
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 15, 2024
Pinging @elastic/kibana-esql (Team:ESQL) |
Pinging @elastic/kibana-data-discovery (Team:DataDiscovery) |
@elasticmachine merge upstream |
vadimkibana
changed the title
[ES|QL] Implements wrapping pretty printer
[ES|QL] Implements wrapping pretty-printer
Aug 19, 2024
💛 Build succeeded, but was flaky
Failed CI StepsMetrics [docs]Unknown metric groupsESLint disabled line counts
Total ESLint disabled count
History
To update your PR or re-run it, just comment with: |
drewdaemon
approved these changes
Aug 19, 2024
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.
Beautiful work
packages/kbn-esql-ast/src/pretty_print/__tests__/basic_pretty_printer.test.ts
Show resolved
Hide resolved
packages/kbn-esql-ast/src/pretty_print/__tests__/basic_pretty_printer.test.ts
Show resolved
Hide resolved
packages/kbn-esql-ast/src/pretty_print/__tests__/basic_pretty_printer.test.ts
Show resolved
Hide resolved
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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
Partially addresses #182257
BasicPrettyPrinter
, notable changes:`name👍`
(1 + 2)::string
instead of1 + 2::string
WrappingPrettyPrinter
.WrappingPrettyPrinter
formats the query likePrettier
, it tries to format AST nodes horizontally as lists, but based on various conditions breaks the lines and indents them.Cases handled by the
WrappingPrettyPrinter
Below are examples of some of the cases handled by the
WrappingPrettyPrinter
. (See test files for many more cases.)Short queries
Queries with less than 4 commands and if they do not require wrapping are formatted to a single line.
Source:
Result:
Argument wrapping
Command arguments are wrapped (at wrapping threshold, defaults to 80).
Source:
Result:
Argument breaking
Command argument combinations which result into a single argument occupying a whole line (due to that argument being long, or because the surrounding argument combination results into such a case), except the last argument, results into the argument list being broken by line.
Source:
Result:
Binary expression chain vertical flattening
Binary expressions of the same precedence are vertically flattened, if wrapping is required. Same as it is done by
Prettier
, where there is an indentation after the first line to allow for different precedence expressions.All expressions have the same precedence
Source:
Result:
Expressions with
additive
andmultiplicative
precedence mixedSource:
Result:
Checklist
Delete any items that are not applicable to this PR.
For maintainers