Use Snowflake CLI variables in SQL context inside VS Code with Snowflake extesion - Stack Overflow

I've a project in Snowflake which is just a set of .sql files executed sequentially. For some para

I've a project in Snowflake which is just a set of .sql files executed sequentially. For some parameters, I did as follow:

1- I created a exported env variables called MY_DATABASE 2- I declared this variable in my snowflake.yml (this just has the env block actually)

Everything is working as expected in snow CLI and this is ok for my CICD environment eventually:

snow -q "select '<% ctx.env.MY_DATABASE $>'

But it doesn't in VSCode, where I see the only way to setup an env is skaffolding a native app project definition (which I have not)

So I created two files that works more or less this way:

init.cicd.sql

set my_database_sql_context = '<% ctx.env.MY_DATABASE %>';
set my_schema_sql_context = '<% ctx.env.SCHEMA %>';

USE DATABASE IDENTIFIER($my_database_sql_context);
USE SCHEMA IDENTIFIER($my_chema_sql_context);

-- Apparently one cannot concat, ie:
-- USE SCHEMA IDENTIFIER($my_database_sql_context).IDENTIFIER($my_schema_sql_context)

init.vscode.sql

set my_database_sql_context = 'THE_DEV_DATABASE';
set my_schema_sql_context = 'THE_DEV_SCHEMA';

But it definitively doesn't look as the best way to do it.

Is there a way for VS Code to be aware of environment setup within the project definition file, just like snow CLI tool does?

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744787189a4593697.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信