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

Better lib docs? #702

Open
max-sixty opened this issue Sep 8, 2024 · 6 comments
Open

Better lib docs? #702

max-sixty opened this issue Sep 8, 2024 · 6 comments
Labels
documentation Improvements or additions to documentation rust Pull requests that update Rust code

Comments

@max-sixty
Copy link

I wanted to check out calling sqruff from rust code. The rust docs are quite sparse and I don't see any examples. To the extent you're keen for folks to call the library too, would eb great to have more here! Thank you and congrats on the progress so far.

@benfdking benfdking added documentation Improvements or additions to documentation rust Pull requests that update Rust code labels Sep 9, 2024
@benfdking
Copy link
Collaborator

Hey @max-sixty, thanks for reaching out; you are right. Our lib docs are still very rough.

We're concerned about supporting this too early because we foresee some significant project changes:

  • refactoring the way config works
  • splitting up the project further
  • changing the API

We do have the API module crates/lib/src/api/simple.rs, which contains some entry points that I think we could outline a bit. Is there anything you are trying to use in the meantime that we could support?

@max-sixty
Copy link
Author

Totally understand if you want to push out supporting an API a bit.

Our use case is over at PRQL, we're trying to better support having expressions which aren't formatted (PRQL/prql#1284), and saw sqruff provides some abilities there; possibly more than our existing formatter.

We're not in a huge rush and some level of "broad stability" is important — i.e. it's fine if we need to add a param to continue using a function, but rewriting everything because a big change would be a pain — so feel free to take your time...

@gvozdvmozgu
Copy link
Collaborator

I just tried using sqruff instead of sqlformat: gvozdvmozgu/prql@ddd526e

@gvozdvmozgu
Copy link
Collaborator

I didn't review the diff very closely, but it might be a good place to get test data for testing rules

@max-sixty
Copy link
Author

Interesting @gvozdvmozgu ! Overall I think the diff looks pretty good. The SQL is denser for short lines, which I think is a bit nicer.

It occasionally is a bit odd — e.g. the hanging parenthesis here: gvozdvmozgu/prql@ddd526e#diff-dba890e435aa425a0d23bbf12de2829ce0890ebb5385d498de1bb8313bd17f83R6-R7 or the CTE here: gvozdvmozgu/prql@ddd526e#diff-148438c68d8050971a3f7dbedd92a05424b5e261322bac82a75d80a4823d481cR5-R8

...and the indent is arguably a bit large; e.g. here: gvozdvmozgu/prql@ddd526e#diff-b9b251f91096516a3cea9e35f51c87e47ca3904a5bd21f37b9be461eb4d8bbc1R7-R14

I personally would prefer a vertical list of columns when we get ~ >3; e.g. here: gvozdvmozgu/prql@ddd526e#diff-869ab0954a91a9a604d82e6eede05371e41a7cb22a327874d994a28dc0191a98R30-R32

...but these are all small issues. Having something reasonably stable is important to us, as well as the ability to avoid formatting s-strings (discussed in my comment above)

sqlparser-rs has just released the ability to turn formatting on & off, so I may try and use that to exclude formatting s-strings.

@gvozdvmozgu
Copy link
Collaborator

You can achieve vertical formatting by enabling certain rules that are turned off by default. I'll look into the rest later. By the way, we now have a playground: https://playground.quary.dev/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation rust Pull requests that update Rust code
Projects
None yet
Development

No branches or pull requests

3 participants