You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am currently working on a project where it is crucial to separate code from config.
Therefore, I need to split out the variables section of the dbt_project.yml.
The idea is to pass the variables manually to any dbt invocation (since dbt does not allow reading a separate config file).
This works well via the --vars option from the command line. I can simply read a custom json string from file and pass it.
However, in dbt power user, I have not found a consistent way to set this up.
Things I tried:
Works when building or running the model via the toolbar buttons.
Does not work for the compilation preview or querying SQL. I suppose that is because those UI Elements do not invoke dbt from the cli but the python api via the dbt runner
Also, those settings do not respect environment variables or typical vs code workspace syntax like ${env:MYVARS}. Thus, they cannot be populated dynamically, but would need to be hardcoded in the workspace file.
This seems to be undocumented, but here is the relevant code in the plugin init.
Only works in compile + query (i.e. dbtRunner) but not for running + building.
Again, setting something like "dbt.runModelCommandAdditionalParams": ["--vars", "{env:DBT_VARS}"] in workspace settings is not respected.
Not supported by vanilla dbt.
Customizing the dbt runner
possible via workspace setting
not actually tried this, but from above I conclude that this would only work for compile previews and queries.
TLDR:
Did I overlook a central place the set dbt variables so they take effect throughout the plugin?
-> Having to set them in various places seems cumbersome, unportable, and prone to break.
Worth a PR?
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Hi all,
I am currently working on a project where it is crucial to separate code from config.
Therefore, I need to split out the variables section of the
dbt_project.yml
.The idea is to pass the variables manually to any dbt invocation (since dbt does not allow reading a separate config file).
This works well via the
--vars
option from the command line. I can simply read a custom json string from file and pass it.However, in dbt power user, I have not found a consistent way to set this up.
Things I tried:
setting the argument in the
.code-workspace
${env:MYVARS}
. Thus, they cannot be populated dynamically, but would need to be hardcoded in the workspace file.using DBT_VARS environment variable
"dbt.runModelCommandAdditionalParams": ["--vars", "{env:DBT_VARS}"]
in workspace settings is not respected.Customizing the dbt runner
TLDR:
Did I overlook a central place the set dbt variables so they take effect throughout the plugin?
-> Having to set them in various places seems cumbersome, unportable, and prone to break.
Worth a PR?
Cheers,
Paul
Beta Was this translation helpful? Give feedback.
All reactions