Re:Sqlfluff the SQL Linter for Humans
by forgetfulness on Wednesday October 06, 2021 @09:52AM
(#28773202)
Leading comma is configurable, but I wouldn't know if the linter allows for that layout. Can't say I've seen it before, is it specific to a particular development environment?
[ Parent
| on HN ]
Re:Sqlfluff the SQL Linter for Humans
by mrbungie on Wednesday October 06, 2021 @10:38AM
(#28773692)
I've seen it a lot in Data Science/Analytics environments, as it allows for faster query iterations than trailing commas.
Re:Sqlfluff the SQL Linter for Humans
by forgetfulness on Wednesday October 06, 2021 @11:07AM
(#28774042)
Yes you can find sources advocating for leading commas and it's commonly used. I have "Google BigQuery: The Definitive Guide" on my desktop, it was written by senior Google employees involved in the steering and use of the product inside, for what it's worth, and it advocates for leading comma and SHOUTING THE KEYWORDS.
I personally disobey both recommendations (I mean, the book is worth it for other reasons) but both those conventions are very commonly used.
I meant more the the "center" layout that the commenter above was describing, it'd seem quite laborious to maintain by hand in most environments, if not using a particular one that supports it out of the box.
jetbrain IDEs have it configured by default for most situations, so its generally just an auto-format away if you're actually writing sql and not embedding sql queries in some other code.
It’s an informal way some people write SQL if they’re developing a script.
I’ve done it this way before because it was quicker to edit, and and remove lines. But it’s not a format I’d particularly like to share with others because it looks weird.