Repository navigation
[DCV-3598] Document required Schema field for @task.datacoves_dbt service connections - #62
Conversation
…tions
Users leaving Schema empty on a Datacoves service connection hit a dbt
profile validation error ("None is not of type 'string'") that names
their own dbt profile, leading them to wrongly suspect the repo's
profiles.yml is being used instead of the generated temporary profile.
Clarify that Schema is required for @task.datacoves_dbt, and that the
Airflow Snowflake provider's "optional" schema applies to the Airflow
connection only, not the generated dbt profile.
Makes the existing defaults (connection details, profile name, target name) and their overrides explicit and scannable instead of prose, per request to clarify what @task.datacoves_dbt does out of the box vs. what can be customized.
| The Airflow Snowflake provider docs list `schema` as optional. That applies to the Airflow connection, not to the dbt profile generated from it, which requires `schema`. | ||
| ::: | ||
|
|
||
| These can be overridden with the following params: |
There was a problem hiding this comment.
@fmercadop what does this mean? e.g. why not just override in the decorator itself?
There was a problem hiding this comment.
@noel I may be misreading your question, so let me check. I think you're asking about the Profile name row in the overrides table: why would we point people to a DATACOVES__DBT_PROFILE env var instead of overriding it in the decorator itself, as we do with target and overrides?
If that's the question: there's no profile-name param on @task.datacoves_dbt. That row (and the env={"DATACOVES__DBT_PROFILE": ...} example further down) was already in the docs on main. I only reordered the sentence into a table.
Would you like me to remove that row from the overrides table, so we only document target and overrides? If you were asking about something else, let me know which part and I'll clarify.
There was a problem hiding this comment.
I think we should also say to override things via the decorator. I am not sure if that works at run time, in that case they can use env = ..... but I dont know if dbt would pick that up.
I think R&D was trying to do something like that. maybe talk to Ian bec there was something he changes that may allow this. Basically I think they wanted to pass a parameter when they go to run the DAG which would replace the schema for example
There was a problem hiding this comment.
Thanks @noel. I talked to Ian, checked the decorator code, and tested it in My Airflow.
Overriding in the decorator: yes, that works. target and overrides are templated fields since 6.0. I tested these three ways to set the schema, and all of them work:
- Fixed value, same on every run:
@task.datacoves_dbt(
connection_id="main",
overrides={"schema": "my_schema"},
)
- Chosen when you run the DAG manually. Add a schema param to the DAG with a default value:
- When the DAG runs on its schedule, it uses the default.
- When you trigger it manually from the Airflow UI, Airflow asks for the schema, pre-filled with the default, and you can change it before starting the run.
@dag(params={"schema": "my_default_schema"})
def my_dbt_dag():
@task.datacoves_dbt(
connection_id="main",
overrides={"schema": "{{ params.schema }}"},
)
def run_dbt():
return "dbt build"
- Per environment, using an Airflow Variable, so the same DAG uses one schema in dev and another in prod:
@task.datacoves_dbt(
connection_id="main",
overrides={"schema": "{{ var.value.dbt_schema }}"},
)
The env= approach: you were right to doubt it. When connection_id is used, the generated profile's name is read from the worker's environment, which comes from the Profile name setting. The task's env is only passed to the shell that runs dbt, after the profile file has already been written. So env={"DATACOVES__DBT_PROFILE": ...} doesn't rename the generated profile.
Proposal for this PR:
- Document the three options above for
overrides(and thattargetis templated too). - Remove the profile-name row and the
env=line from the overrides example, and note that the profile name comes from the Profile name setting (and must matchprofile:indbt_project.yml).
Sound good?
There was a problem hiding this comment.
Hi @noel, I pushed the doc changes we discussed. Summary:
Overrides
- Removed the
DATACOVES__DBT_PROFILErow andenv=line, since passing it via env doesn't rename the generated profile. The page now says the profile name comes from the Profile name setting and must matchprofile:indbt_project.yml.
New "Setting values dynamically" section
- Explains that
targetandoverridessupport Airflow templating, usingschemaas the example. - Covers the 4 options I tested: fixed value,
params(chosen at trigger), Airflow Variable, and an env var resolved by dbt. - For the env var option, it notes that
{% raw %}andappend_env=Trueare required.
Schema is already mandatory in the service connection UI, so the extra note about it being required for @task.datacoves_dbt is redundant.
Adds a warning to the @task.datacoves_dbt decorator docs and an explicit note on the service connections page stating that the Schema field is required when a service connection is used with @task.datacoves_dbt. Leaving it empty causes a dbt profile validation error at runtime (Credentials in profile "...", target "..." invalid: None is not of type 'string'), and it's easy to miss since the Airflow Snowflake provider docs list schema as optional for the Airflow connection itself.