6 ms·
I'm of the same opinion. I always wonder why SQL formatters do this. Is it because it's easier to diff queries with versioning tools? Because to me it's defini
by bot347851834 3y ago
I'm of the same opinion.
I always wonder why SQL formatters do this. Is it because it's easier to diff queries with versioning tools? Because to me it's definitely not for legibility. The example shown here isn't even that bad compared to what I see regularly. We've got quiet a few queries longer than 100 sanely written lines running in BigQuery, sometimes I missclick the "format query" option and it always makes me wonder who the hell enjoys scrolling so much because suddenly the line count increases by an order or magnitude or more and the lines aren't much longer than 20 or so characters.
- natpalmer1776 3y agoI think formatters are generally written by people who value consistency above other criteria, as many of the general conventions used when handwriting queries tend to break down as the complexity of the query increases. With these formatters I imagine complex queries would render in a more 'consistent' manner.
- DougMerritt 3y agoYes, and that tends to be the case with formatters for programming languages in general.
- adamrezich 3y agoI agree that the example input is more readable than the output, but I also think it's a bad example of messy SQL. sometimes it's nice to use a tool like this to break down a complex, appended-to-by-multiple-authors-over-the-years query just so you can understand the logic (and sometimes find unexpected logic bugs that nobody noticed before). at least, that's been my experience.
- johnnyworker 3y agoI make SQL queries even bigger, and for me it's not so much about reading but being able to copy and paste bits of it easily (easy meaning any line is just one "token"), to modify it or use parts of it elsewhere.