Is there any linter for vsql scripts?
We would like to extend our CI/CD pipeline with running validation/linting of sql scripts during the authoring process. We found no good solution for this yet.
What I did so far
While DataGrip from JetBrains has support for the Vertica dialect, that is an IDE not a solution for CI/CD.
Contacted Vertica Support, they suggested to ask this question here.
I did a bit of googling, and found a curated list of linters, but no turn key solutions for vertica:
- SqlFluff seems to be a great option, but it does not have a Vertica dialect yet.
- sql-lint might be another option, but not mature yet, also aims to be generic, not considering dialects.
What we need
An open source solution would be better, but a subscription based/proprietary one would also be great.
I'm kinda surprised that there is no official Vertica solution for this.
Any suggestions? Thanks!
0
Answers
Hi vhermecz,
That's the goal of an open source project, if you need it and it doesn't exist you can contribute
On a personal note, I never saw a single benefit from a SQL linter.
I really don't want my code or indentation to be supervised by rules made by someone else.
Why do you want a linter?
An obvious helpful use case for linting is to automate catching syntax errors (formatting aside).
Typically, linting can configure formatting rules, so a team can decide which formatting rules to enforce (if any).
What type of validation do you need? If you want to check quickly whether a SQL is valid, then
EXPLAIN <sql>;
is a quick check that will usually tell you whether the SQL is valid, in which case it returns a plan, or invalid, in which case it returns an error that may indicate what's wrong, e.g.:Planned usage:
We had multiple cases where broken sql submitted to production caused ETL to fail, causing tiny outages.
Automatic linting (not formatting, just error checking) could have caught these earlier, before reaching prod.
Thx Bryan, the
EXPLAIN <sql>;
is a great trick, already applying that in some parts of our UI.I'm assuming it requires a server and thus feels a bit heavy weight for CI.
Also wondering if it could handle variables it the queries (probably nope).