Skip to content
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

dbt testsql capability to test whether models have valid sql in both incremental and full-refresh modes. #2218

Closed
djayatillake opened this issue Mar 19, 2020 · 1 comment
Labels
enhancement New feature or request wontfix Not a bug or out of scope for dbt-core

Comments

@djayatillake
Copy link

Describe the feature

dbt testsql capability to test whether models have valid sql in both incremental and full-refresh modes.

Describe alternatives you've considered

right now as part of testing during development I start running the model in incremental mode and full-refresh mode on a small warehouse and then hit ctrl-C to stop the model running both times and rollback any transactions

Additional context

the method above isn't great as it's very manual and you can only test one model at a time. Also if a model runs too fast then it can easily commit before you can cancel the run!

I would imagine that it would work as follows:

dbt testsql -m model1 model2

and it will do a 10/20 second run (or other way of establishing the model hasn't thrown a db error) and rollback for each model in both incremental and full-refresh modes, because it automatically rolls back it doesn't matter if the model completes or not.

Who will this benefit?

This will benefit anyone who is trying to test new models or model changes.

@djayatillake djayatillake added enhancement New feature or request triage labels Mar 19, 2020
@drewbanin drewbanin added wontfix Not a bug or out of scope for dbt-core and removed triage wontfix Not a bug or out of scope for dbt-core labels Mar 19, 2020
@drewbanin
Copy link
Contributor

Hey @djayatillake - cool suggestion! I don't think we'd want to implement exactly this, but I do like where your head is at. One of the challenges here is that dbt can't generate all of the possible permutations of a model -- if you did something like:

select * from {{ ref(model) }}

{% if modules.datetime.datetime.now().isoweekday() == 4 %}
where 1 / 0
{% endif %}

this models would fail to build.... but only on Thursdays! As such, it's not really possible or desirable for dbt to try to make a claim like "this model's code passes regardless of the supplied configs (eg. if --full-refresh is present or not).

Instead, what do you think of something like #401? Now that Snowflake has explain capabilities, I think it would be awesome if we could do something like:

dbt run --explain -m model1 model2

This would run an explain plan on the specified models. If they contain syntax errors or invalid table references, then the explain plan should fail right away. Note that this would not help in cases like:

select 1 / 0

as it's a valid SQL statement that would encounter a runtime error.

I'm going to close this one out with a wontfix label as I don't imagine making the code change you've described exactly here, but I like the idea and I'm keep to discuss further in the comments below! Let me know what you think

@drewbanin drewbanin added the wontfix Not a bug or out of scope for dbt-core label Mar 19, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request wontfix Not a bug or out of scope for dbt-core
Projects
None yet
Development

No branches or pull requests

2 participants