ENV VAR需要但未提供-DBT CLI
我们在DBTCloud中具有一个环境变量,称为dbt_snowflake_env
,根据使用了哪个环境选择右数据库。
目前,我正在尝试使用VSCODE设置DBT CLI。我创建了一个看起来像这样的profiles.yml
文件:
default:
target: development
outputs:
development:
type: snowflake
account: skxxxx.eu-central-1
user: <name>
password: <pass>
role: sysadmin
warehouse: transformations_dw
database: " {{ env_var('DBT_SNOWFLAKE_ENV', 'analytics_dev') }} "
schema: transformations
threads: 4
在一些建议之后,我添加了env_var
行,但我意识到环境变量仍然不存在。我看到的问题是,如果我硬码analytics_dev
在该位置(这很有意义),则错误仍然存在。
我不希望任何要使用DBT的人如果想在生产中运行某些东西,就必须更改环境变量。
我在这里有什么选择?
We have an environment variable set in dbtCloud called DBT_SNOWFLAKE_ENV
that selects the right database depending on which environment is used.
At the moment, I'm trying to set up dbt CLI with VSCode. I created a profiles.yml
file that looks like this:
default:
target: development
outputs:
development:
type: snowflake
account: skxxxx.eu-central-1
user: <name>
password: <pass>
role: sysadmin
warehouse: transformations_dw
database: " {{ env_var('DBT_SNOWFLAKE_ENV', 'analytics_dev') }} "
schema: transformations
threads: 4
I added the env_var
line after some suggestions but I realise that the environment variable still doesn't exist yet. The problem I see is that if I hardcode analytics_dev
in that place (which makes sense), the error still persists.
I wouldn't want anybody who's going to use dbt to have to change the environment variable if they want to run something on production.
What are my options here?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您可以为DBT CLI上的变量设置源文件 - 例如,您将创建一个称为
set_env_var.sh
的bash脚本,然后在终端中source> source set_env_var.sh
。BASH脚本的一个示例是:
在您的
profiles.yml
中,您可以添加所需的所有变量。.希望这会有所帮助。
You can set up a source file for the variables on dbt cli - for example you would create a bash script called
set_env_var.sh
and thensource set_env_var.sh
in your terminal.An example of the bash script would be:
and in your
profiles.yml
you can add all the variables you want, for example..Hope this helps.
首先,您必须给出硬码数据库名称,而另一语法是错误的。其次,尝试为环境做一个动态变量,然后在要使用dbt时这样使用它,均值
** dbt快照 - profile -vars $ dbt_snowflake_env **
当您运行时,它很容易从Env拾取。
目前,我正在研究DBT,即使完整的配置文件也是动态的,根据Schema和DB的动态。
First of all younyou have to give hard code database name the other syntax is wrong. Secondly try to make a dynamic variable for environment and then use it like this when you want to use dbt, mean
**DBT snapshot --profile --vars $DBT_SNOWFLAKE_ENV **
As when you run it can easily pick up from env.
Currently i am working on dbt with everything dynamic even the full profile is dynamic according to schema and db.
在我的DBT模型中,我的变量在我的
vars
的一部分中声明为dbt_project.yml
file,因此,而不是访问变量,例如” {{envy_var ('my_variable')}}}“
我应该使用:
“ {{var('my_variable')}}”
>In my case in my DBT model my variable was declared as part of
vars
within mydbt_project.yml
file, so instead of accessing the variable like"{{ env_var('MY_VARIABLE') }}"
I should have used:
"{{ var('MY_VARIABLE') }}"