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

Consider using proper SQL parser #117

Closed
nene opened this issue Jan 29, 2021 · 4 comments
Closed

Consider using proper SQL parser #117

nene opened this issue Jan 29, 2021 · 4 comments

Comments

@nene
Copy link
Collaborator

nene commented Jan 29, 2021

Currently the formatter is pretty dumb. It's looking for certain keywords and trying to make some formatting guesses based on these. A better approach would be to use an actual parser like https://github.com/taozhi8833998/node-sql-parser

@osv
Copy link
Contributor

osv commented Feb 5, 2021

pretty sure that parser ast tree does not contains info about comments in sql.. but I'm might be wrong.

@nene
Copy link
Collaborator Author

nene commented Feb 6, 2021

You're right. This specific parser completely discards all comments.

Should be possible to modify the parser though to also gather info about comments.

@romainr
Copy link

romainr commented Mar 20, 2021

It might have caveats: if the parser is validating, it might not work properly on invalid queries or grammar that it does not know (we had issues with that in Hue SQL Editor).

To note that https://github.com/taozhi8833998/node-sql-parser is GPL too.

I was surprised on how well sql-format handle big Hive queries, so the current approach has some good sides. Could be a pluggable option to select which parser to use.

@nene
Copy link
Collaborator Author

nene commented Jul 27, 2022

Closing this. That's a larger topic that's in our minds anyway. No real need for an issue to keep track of it.

@nene nene closed this as not planned Won't fix, can't repro, duplicate, stale Jul 27, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants