最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

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

programmeradmin1浏览0评论

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?

发布评论

评论列表(0)

  1. 暂无评论