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

Interest in partial parsing and sql formatting? #1392

Open
zmaril opened this issue Aug 20, 2024 · 5 comments
Open

Interest in partial parsing and sql formatting? #1392

zmaril opened this issue Aug 20, 2024 · 5 comments

Comments

@zmaril
Copy link

zmaril commented Aug 20, 2024

Hello! I've been loving sqlparser-rs, I've been having a lot of fun using it with a tool I've been working on recently. As part of my work, I would like to do two things with sqlparser-rs that I don't think are supported right now. I'd like to be able to get a partial parse of a sql string back out, for use with code editors and text highlighting. Additionally, I would like to be able to format sql with my particular dialect as well eventually. Would you all be interested in me trying to contribute this back to the library somehow when I get around to it? Did I miss something somewhere hopefully? Thanks again for a great library.

@wpf375516041
Copy link

This is a great feature. SQL formatting, removing comments, and highlighting keywords are all very practical capabilities. If necessary, I can also contribute what I can.

@alamb
Copy link
Contributor

alamb commented Sep 10, 2024

I think adding hooks (like offsets / spans into the AST) would fit into sqlparser-rs 's design

I am not quite sure what you mean by "partial parse of a sql string" -- maybe you mean the parser would be able to produce an AST even for a partial SQL query?

Text highlighting I think would be possible if the ast had spans (location in the original parsed query) -- I am not sure highlighting itself fits into the crate

@wpf375516041
Copy link

image I think we only need to provide some built-in visitors like alibaba/druid to meet the needs, which will also help others learn and use sqlparser @alamb

@alamb
Copy link
Contributor

alamb commented Sep 11, 2024

There is a basic visitor already: https://docs.rs/sqlparser/latest/sqlparser/ast/trait.Visitor.html, perhaps that is enough

@wpf375516041
Copy link

Of course, this is a small case for SQL engine developers. I want to provide some SqlUtils to attract more developers. I will try to do something. If there is progress, I will synchronize with everyone.

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