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

[Feature] Add Support for SQL Formatting in Query Editor #11725

Merged
merged 2 commits into from
Feb 24, 2024

Conversation

ArnavBalyan
Copy link
Contributor

@ArnavBalyan ArnavBalyan commented Oct 2, 2023

formatsql2.mov
formatsql1.mov

@Jackie-Jiang
Copy link
Contributor

This looks great! @jayeshchoudhary Can you help take a look?

@Jackie-Jiang Jackie-Jiang added feature ui UI related issue labels Oct 2, 2023
@ankitsultana
Copy link
Contributor

@ArnavBalyan : Pinot supports some unorthodox queries such as lookUp joins, funnel count, etc.

Can you test with those as well?

@@ -78,7 +79,15 @@ const useStyles = makeStyles((theme) => ({
},
runNowBtn: {
marginLeft: 'auto',
paddingLeft: '74px',
paddingLeft: '10px',
Copy link
Contributor

Choose a reason for hiding this comment

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

(not introduced in this PR)

Can you check how this looks when the window width is less? At present the buttons and the timeout field start overlapping when we reduce the width. With another button this will become a bit worse.

We can perhaps change the display prop of the divs with some media queries (I have no frontend knowledge so others can chime in)

image

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure, this seems to be something affecting the entire UI, let me work on this in an upcoming change. Thanks!

Copy link
Contributor

Choose a reason for hiding this comment

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

let's at least fix this view in this PR

@@ -47,6 +47,7 @@ import PinotMethodUtils from '../utils/PinotMethodUtils';
import '../styles/styles.css';
import {Resizable} from "re-resizable";
import { useHistory, useLocation } from 'react-router';
import sqlFormatter from '@sqltools/formatter';
Copy link
Contributor

Choose a reason for hiding this comment

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

The last update to this package was around a year ago.

I had also found this one earlier which seems to be quite actively maintained: https://www.npmjs.com/package/sql-formatter

Should we explore sql-formatter instead?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hi @ankitsultana the sql-formatter is currently in maintenance mode, no new features are being added. Also it's incompatible with the babel configuration we are using. The above sqltools/formatter actively get's maintained and has very close parity to sql-formatter. It has new updates as well. Thanks!

@codecov-commenter
Copy link

codecov-commenter commented Oct 2, 2023

Codecov Report

Merging #11725 (600cd98) into master (ae16812) will decrease coverage by 0.02%.
Report is 11 commits behind head on master.
The diff coverage is n/a.

@@             Coverage Diff              @@
##             master   #11725      +/-   ##
============================================
- Coverage     63.11%   63.09%   -0.02%     
  Complexity     1117     1117              
============================================
  Files          2342     2342              
  Lines        125802   125890      +88     
  Branches      19336    19360      +24     
============================================
+ Hits          79395    79428      +33     
- Misses        40745    40806      +61     
+ Partials       5662     5656       -6     
Flag Coverage Δ
integration <0.01% <ø> (-0.01%) ⬇️
integration1 <0.01% <ø> (-0.01%) ⬇️
integration2 0.00% <ø> (ø)
java-11 63.06% <ø> (+<0.01%) ⬆️
java-17 62.94% <ø> (+0.01%) ⬆️
java-20 62.95% <ø> (+<0.01%) ⬆️
temurin 63.09% <ø> (-0.02%) ⬇️
unittests 63.08% <ø> (-0.02%) ⬇️
unittests1 67.25% <ø> (+0.03%) ⬆️
unittests2 14.43% <ø> (-0.06%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

see 61 files with indirect coverage changes

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@ArnavBalyan
Copy link
Contributor Author

ArnavBalyan commented Oct 3, 2023

@ArnavBalyan : Pinot supports some unorthodox queries such as lookUp joins, funnel count, etc.

Can you test with those as well?

Hi @ankitsultana it works with lookUp joins and funnel count and other SQL clauses as well. Thanks!

Copy link
Contributor

@jayeshchoudhary jayeshchoudhary left a comment

Choose a reason for hiding this comment

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

lgtm code wise

@xiangfu0
Copy link
Contributor

xiangfu0 commented Oct 3, 2023

Can you fix the CI pipeline?

@ArnavBalyan
Copy link
Contributor Author

Can you fix the CI pipeline?

Done thanks!

@jayeshchoudhary
Copy link
Contributor

@ArnavBalyan I see a lot of changes in package-lock.json, this project uses npm v5 or lockfile v1
Changing that to npm v6 should not cause issues but we have to test the working.

Copy link
Contributor

@walterddr walterddr 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 awesome! was there any documentation we can use to follow the usage of sql formatting tool introduced in this PR?

@ArnavBalyan
Copy link
Contributor Author

@ArnavBalyan I see a lot of changes in package-lock.json, this project uses npm v5 or lockfile v1 Changing that to npm v6 should not cause issues but we have to test the working.

Got it, on a high level I don't see any issues with the UI, also relying on the tests to make sure nothing breaks. Would you recommend any other way to make sure there are no issues with lockfile v2. Had allowed this change to coming in since upgrading to v2 would give us better performance and stability. Thanks!

@ArnavBalyan
Copy link
Contributor Author

this is awesome! was there any documentation we can use to follow the usage of sql formatting tool introduced in this PR?

Thanks! I will add some usage instructions to the documentation as well.

@tibrewalpratik17
Copy link
Contributor

Had allowed this change to coming in since upgrading to v2 would give us better performance and stability.

Is it possible to keep version upgrade and this feature PRs separate?
Will allow for easier rollbacks if needed; unless this feature is strictly dependent on this version upgrade.

@ankitsultana
Copy link
Contributor

@ArnavBalyan : any updates on this? Can you try to get this closed this month?

@ArnavBalyan
Copy link
Contributor Author

@ArnavBalyan : any updates on this? Can you try to get this closed this month?

Hey @ankitsultana let me close this in this week, apologies for the delay

@ArnavBalyan
Copy link
Contributor Author

ArnavBalyan commented Feb 24, 2024

Will allow for easier rollbacks if needed; unless this feature is strictly dependent on this version upgrade.

Hey @tibrewalpratik17 this feature is build and tested with lockfile v2. I would suggest we can merge this. In case of rollbacks we can just revert this change, wdyt? Thanks!

@ArnavBalyan
Copy link
Contributor Author

@ankitsultana if there are no other concerns, do you think we could merge this, and for the already existing width issue, I can take it up in a future change thanks!

@Jackie-Jiang Jackie-Jiang merged commit c8060c1 into apache:master Feb 24, 2024
21 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature ui UI related issue
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants