-
Notifications
You must be signed in to change notification settings - Fork 225
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
Add "--explain-first" to run explain
on statements
#76
base: master
Are you sure you want to change the base?
Conversation
Sorry for the slow response here @akdor1154. I will be OOO until next Tuesday, but will look at this then. In the meantime I've left comments on #74 (and #75), and would love to get those published! |
894cd9a
to
1368743
Compare
1368743
to
b3f3953
Compare
@akdor1154 Could you revisit this PR and let us know if you could get the changes to the latest state so that we review it against the latest version and request additional enhancements for a future release. I can see Explain Plan being useful as part of the dry-run validations to append to a list of pre-checks. Thoughts? |
At our org, we like to run
explain
on DDL statements before running them. With the notable exception of GRANT, this is supported on almost all DDL statements we normally have deal with, and serves as a very capable pre-check step, e.g. for us to run in feature branch CI runs or as a pre-commit hook. (with EXPLAIN, snowflake not only checks sql syntax, but also column, table, and function references, type compatibility, and probably more)This pr adds an
--explain-first
flag to schemachange that will runexplain <statement>
before running any statements, which enables the above workflow. This also works with dry runs.One drawback is that not all statements support EXPLAIN - e.g. I have hit GRANT statements but there might be others. Currently this PR is an all-or-nothing approach. This is still useful for us but I could see future work enabling this on a per-statement basis. This is non-trivial though, might need to add a magic var, comment, or something else to the sql code. Would seek your design input before doing anything in this direction.
Sorry for the bombardment of PRs, this is the last one! :)
Will squash before merging, just will await feedback first in case there are other changes / you don't like this direction / etc.
Cheers
Jarrad