astral-sh / ruff

An extremely fast Python linter and code formatter, written in Rust.
https://docs.astral.sh/ruff
MIT License
31.91k stars 1.07k forks source link

Feature Request: Extend Ruff as a fast and simple SQL formatting and linting tool #9244

Open OneCyrus opened 9 months ago

OneCyrus commented 9 months ago

i think there's a huge overlapping userbase of python users who work in the data engineering space. the current lanscape of good tooling to format and lint sql files is not great and something like ruff for those scenarios could be huge.

basically ruff to replace sqlfmt and sqlfluff would be awesome.

https://sqlfluff.com/ https://sqlfmt.com/

zanieb commented 9 months ago

We're definitely interested in this, but it's a serious endeavor and we'll need to dedicate some time to the design :)

gregorywaynepower commented 9 months ago

@OneCyrus It looks like Sleek may be up your alley for the time being, at least as far as formatting goes. It was easier to set up than sqlfmt.

ashrub-holvi commented 5 months ago

and https://github.com/pre-commit/mirrors-prettier

  Archived

prettier made some changes that breaks plugins entirely

KangOl commented 2 months ago

There is now a Rust rewrite of sqlfluff named sqruff.

benfdking commented 1 month ago

Hey 👋, Ben here from Quary, I just saw this! Yep, we would be happy to integrate https://github.com/quarylabs/sqruff in a way that makes sense, feels like there could be a nice way of doing this!

takeda commented 2 weeks ago

If this is implemented would that make ruff format SQL within the strings, or this feature only asks to format SQL files separately?

Slightly unrelated, but what's the recommended way to write python code with raw SQL?

gregorywaynepower commented 2 weeks ago

If this is implemented would that make ruff format SQL within the strings, or this feature only asks to format SQL files separately?

What's the recommended way to write python code with raw SQL?

@benfdking I'd also be pretty intrigued on what y'all's intended outcome for this. (I really enjoy sqruff by the way, I can completely understand sqruff being a completely separate tool.)

jordandakota commented 2 weeks ago

I also enjoy sqruff due to its speed, but there's still quite a few things that feel not implemented. It would be good to get more hands on deck. I've been working on quite a few fixes as I get it integrated into my project I'll be submitting a pr for, but would still be great to have it built into ruff.