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] Prettiffying the query #191269

Merged
merged 12 commits into from
Sep 10, 2024

Conversation

stratoula
Copy link
Contributor

@stratoula stratoula commented Aug 26, 2024

Summary

The wrap by pipes CTA doesnt work correctly when pipes are being used inside functions or in a comment in an ES|QL query.

This PR fixes this bug by using the prettifying api. I was thinking to change the tooltip text to mention that it doesnt only wrap by pipes but also prettifies but I decided against it and kept the tooltip as it is for 2 reasons:

  • this is the most important thing that it does
  • prettifying means nothing for the majority of our users

meow

Checklist

@stratoula
Copy link
Contributor Author

@elasticmachine merge upstream

@stratoula stratoula added release_note:enhancement Feature:ES|QL ES|QL related features in Kibana Team:ESQL ES|QL related features in Kibana v8.16.0 backport:skip This commit does not require backporting labels Sep 9, 2024
@stratoula stratoula marked this pull request as ready for review September 9, 2024 12:51
@stratoula stratoula requested a review from a team as a code owner September 9, 2024 12:51
@elasticmachine
Copy link
Contributor

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

Copy link
Contributor

@vadimkibana vadimkibana left a comment

Choose a reason for hiding this comment

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

LGTM

Comment on lines 119 to 121
const trimmedCode = query.trim().replaceAll('\n |', '\n|');
const numberOfCommands = ast.length;
const pipesWithNewLine = trimmedCode?.split('\n|');
Copy link
Contributor

@vadimkibana vadimkibana Sep 10, 2024

Choose a reason for hiding this comment

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

Not sure, but it looks the replaceAll() might not be necessary:

Suggested change
const trimmedCode = query.trim().replaceAll('\n |', '\n|');
const numberOfCommands = ast.length;
const pipesWithNewLine = trimmedCode?.split('\n|');
const trimmedCode = query.trim();
const numberOfCommands = ast.length;
const pipesWithNewLine = trimmedCode?.split('\n |');

Maybe trim() as well:

Suggested change
const trimmedCode = query.trim().replaceAll('\n |', '\n|');
const numberOfCommands = ast.length;
const pipesWithNewLine = trimmedCode?.split('\n|');
const numberOfCommands = ast.length;
const pipesWithNewLine = query.split('\n |');

Copy link
Contributor Author

Choose a reason for hiding this comment

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

True, adjusted here a881caa

@stratoula
Copy link
Contributor Author

/ci

@stratoula stratoula enabled auto-merge (squash) September 10, 2024 08:08
@stratoula stratoula merged commit 7cc3eae into elastic:main Sep 10, 2024
19 of 20 checks passed
@kibana-ci
Copy link
Collaborator

💛 Build succeeded, but was flaky

Failed CI Steps

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 120 139 +19
@kbn/esql-utils 64 69 +5
total +24

Async chunks

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

id before after diff
esql 178.4KB 178.4KB -57.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 15 31 +16

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 +15.5KB
Unknown metric groups

API count

id before after diff
@kbn/esql-ast 152 177 +25
@kbn/esql-utils 68 73 +5
total +30

History

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

gergoabraham pushed a commit to gergoabraham/kibana that referenced this pull request Sep 13, 2024
## Summary

The wrap by pipes CTA doesnt work correctly when pipes are being used
inside functions or in a comment in an ES|QL query.

This PR fixes this bug by using the prettifying api. I was thinking to
change the tooltip text to mention that it doesnt only wrap by pipes but
also prettifies but I decided against it and kept the tooltip as it is
for 2 reasons:

- this is the most important thing that it does
- prettifying means nothing for the majority of our users


![meow](https://github.com/user-attachments/assets/c2189218-4367-4d4a-9f9e-2d6f88f731d2)

### Checklist

- [ ] [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

---------

Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
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:enhancement Team:ESQL ES|QL related features in Kibana v8.16.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants