This repository was archived by the owner on May 17, 2024. It is now read-only.
This repository was archived by the owner on May 17, 2024. It is now read-only.
Data-diff --dbt doesn't work with profile targets that use env vars #386
Closed
Description
Describe the bug
Given a profiles.yml
that contains something like:
my_dwh:
target: "{{ env_var('DBT_SNOWFLAKE_TARGET', 'dev') }}"
outputs:
dev:
user: "{{ env_var('DBT_SNOWFLAKE_USER') }}"
password: "{{ env_var('DBT_SNOWFLAKE_PASSWORD') }}"
database: "dev_{{ env_var('DBT_SNOWFLAKE_DB') }}"
schema: none
warehouse: "{{ env_var('DBT_SNOWFLAKE_WAREHOUSE', 'dev_xsmall') }}"
role: "{{ env_var('DBT_SNOWFLAKE_ROLE', 'developer') }}"
then at
Line 305 in 29bfa73
"{{ env_var('DBT_SNOWFLAKE_TARGET', 'dev') }}"
gets used to index into the profile dict
Resulting in something like the below on the next call:
> data-diff --dbt --dbt-profiles-dir '.' --debug
Found 1 successful model runs from the last dbt command.
[21:29:23] ERROR - 'NoneType' object has no attribute 'get'
Traceback (most recent call last):
File "/usr/local/bin/data-diff", line 8, in <module>
sys.exit(main())
File "/usr/local/lib/python3.10/site-packages/click/core.py", line 1130, in __call__
return self.main(*args, **kwargs)
File "/usr/local/lib/python3.10/site-packages/click/core.py", line 1055, in main
rv = self.invoke(ctx)
File "/usr/local/lib/python3.10/site-packages/click/core.py", line 1404, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/usr/local/lib/python3.10/site-packages/click/core.py", line 760, in invoke
return __callback(*args, **kwargs)
File "/usr/local/lib/python3.10/site-packages/data_diff/__main__.py", line 262, in main
dbt_diff(
File "/usr/local/lib/python3.10/site-packages/data_diff/dbt.py", line 55, in dbt_diff
dbt_parser.set_connection()
File "/usr/local/lib/python3.10/site-packages/data_diff/dbt.py", line 306, in set_connection
conn_type = credentials.get("type").lower()
AttributeError: 'NoneType' object has no attribute 'get'
The way to get around this is to hardcode all values in profiles.yml
.
Additionally, even when specifying the db for a schema-separated project, you still have to specify the prod_schema
key in the dbt project config or else you get an error from
Lines 57 to 58 in 29bfa73
Describe the environment
> data-diff --version
v0.4.0
docker / Debian-bullseye / Python 3.10