-
Notifications
You must be signed in to change notification settings - Fork 175
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
[CT-1805] [Regression] Transaction behaviour change in dbt-snowflake >=1.2
results in an error when macros call run_query('begin;')
#388
Comments
run_query('begin;')
run_query('begin;')
run_query('begin;')
>=1.2
results in an error when macros call run_query('begin;')
If necessary, as a temporary workaround (which I don't recommend) - we can try replacing the default -- macros/run_query.sql
{% macro check_version() %}
{% set min_version = [1, 2, 0] %}
{% set cur_version = dbt_version.split(".") | map("int") | list %}
{{ return(cur_version >= min_version) }}
{% endmacro %}
{% macro run_query(sql) %}
{% set keywords = ["begin;", "BEGIN;", "commit;", "COMMIT;"] %}
{% if sql | trim in keywords and check_version() %}
{% if execute %}
{% do log('Replacing transaction keyword `' ~ sql ~ '` with `select 1;`.', True) %}
{% endif %}
{% set sql = "select 1;" %}
{% endif %}
{% call statement("run_query_statement", fetch_result=true, auto_begin=false) %}
{{ sql }}
{% endcall %}
{% do return(load_result("run_query_statement").table) %}
{% endmacro %} Basically we have a Testing: $ dbt --version && dbt run
Core:
- installed: 1.2.4
- latest: 1.3.2 - Update available!
Your version of dbt-core is out of date!
You can find instructions for upgrading here:
https://docs.getdbt.com/docs/installation
Plugins:
- snowflake: 1.2.0 - Update available!
At least one plugin is out of date or incompatible with dbt-core.
You can find instructions for upgrading here:
https://docs.getdbt.com/docs/installation
22:17:48 Running with dbt=1.2.4
22:17:49 Found 1 model, 0 tests, 0 snapshots, 0 analyses, 270 macros, 0 operations, 0 seed files, 0 sources, 0 exposures, 0 metrics
22:17:49
22:17:55 Concurrency: 8 threads (target='dev')
22:17:55
22:17:55 1 of 1 START table model dbt_jyeo.foo .......................................... [RUN]
22:18:01 Replacing transaction keyword `begin;` with `select 1;`.
22:18:03 Replacing transaction keyword `commit;` with `select 1;`.
22:18:04 1 of 1 OK created table model dbt_jyeo.foo ..................................... [SUCCESS 1 in 9.55s]
22:18:04
22:18:04 Finished running 1 table model in 0 hours 0 minutes and 15.47 seconds (15.47s).
22:18:04
22:18:04 Completed successfully
22:18:04
22:18:04 Done. PASS=1 WARN=0 ERROR=0 SKIP=0 TOTAL=1
$ dbt --version && dbt run
Core:
- installed: 1.3.2
- latest: 1.3.2 - Up to date!
Plugins:
- databricks: 1.3.2 - Up to date!
- bigquery: 1.3.0 - Up to date!
- snowflake: 1.3.0 - Up to date!
- redshift: 1.3.0 - Up to date!
- postgres: 1.3.1 - Update available!
- spark: 1.3.0 - Up to date!
At least one plugin is out of date or incompatible with dbt-core.
You can find instructions for upgrading here:
https://docs.getdbt.com/docs/installation
22:19:01 Running with dbt=1.3.2
22:19:02 Found 1 model, 0 tests, 0 snapshots, 0 analyses, 306 macros, 0 operations, 0 seed files, 0 sources, 0 exposures, 0 metrics
22:19:02
22:19:08 Concurrency: 8 threads (target='dev')
22:19:08
22:19:08 1 of 1 START sql table model dbt_jyeo.foo ...................................... [RUN]
22:19:11 Replacing transaction keyword `begin;` with `select 1;`.
22:19:12 Replacing transaction keyword `commit;` with `select 1;`.
22:19:13 1 of 1 OK created sql table model dbt_jyeo.foo ................................. [SUCCESS 1 in 5.60s]
22:19:13
22:19:13 Finished running 1 table model in 0 hours 0 minutes and 11.05 seconds (11.05s).
22:19:13
22:19:13 Completed successfully
22:19:13
22:19:13 Done. PASS=1 WARN=0 ERROR=0 SKIP=0 TOTAL=1 Also tested with
|
Thanks for the detailed writeup @jeremyyeo! Agree on both counts:
I think there are two paths we can take here:
(1) is scarier to me. (2) I was able to get working, and it gives us the opportunity to raise a warning as described above, by identifying that the user is probably not using |
Is this a regression in a recent version of dbt-snowflake?
Current Behavior
A summary of the issue is available here #304
With our 1.2 release - we "fixed" a previous regression that did not show the number of affected rows - this caused users who had macros that contained singular transaction keywords like the following to error:
dbt version 1 releases prior to
1.2
(i.e.1.0
,1.1
) had worked fine with the above calls (albeit with the wrong number of affected rows for incrementals) so we might want to do something about gracefully handling this "breaking" but net-improvement change.Expected/Previous Behavior
dbt version
>=1.0,<1.2
had no errors when macros had{% do run_query('commit;') %}
- we should continue to support this behaviour gracefully as long as we're in v1.Steps To Reproduce
Relevant log output
No response
Environment
Additional Context
No response
The text was updated successfully, but these errors were encountered: