雪花仪表板瓷砖中使用的SQL的限制

发布于 2025-02-11 21:32:41 字数 448 浏览 1 评论 0原文

我们正在尝试在雪花仪表板瓷砖中使用多语句,并且不太了解这种行为。

假设我会在瓷砖中创建这两个语句,

SET MyVar = ( SELECT TOP 1 TABLE_NAME FROM DEV_CONTROL.INFORMATION_SCHEMA.TABLES WHERE NOT TABLE_NAME = :Subscription );

SELECT $MyVar;

如果我突出显示第一行并运行它,我将获得一个成功的语句,这些声明不会返回任何内容。 如果我回到瓷砖上,我会看到“成功执行的声明”。

如果我返回我的SQL语句并突出显示两者,然后运行它,我会得到第一张表的名称。 回到仪表板,我现在看到了第二个语句的结果,即我的表名。

我发现这既令人困惑又不连贯...

瓷砖中显示的数据应该反映我输入的所有代码,而不仅仅是我碰巧的是我上次查看代码时运行的内容?

We are trying to use multi statements in Snowflake Dashboard tiles and do not quite understand the behaviour.

Let's say I create these 2 statements in my tile

SET MyVar = ( SELECT TOP 1 TABLE_NAME FROM DEV_CONTROL.INFORMATION_SCHEMA.TABLES WHERE NOT TABLE_NAME = :Subscription );

SELECT $MyVar;

If I highlight the first line and run it, I get a successful statement that does not return anything.
If I get back to my tile, I see "Statement executed successfully."

If I then go back to my SQL statements and highlights both, then run it, I get the name of the first table.
Going back to my dashboard, I now see the result of the second statement, my table name.

I find this both confusing and incoherent...

The data showed in the tile should reflect ALL the code I entered, not just what I happened to highlight and run the last time I looked at the code?...

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

埋情葬爱 2025-02-18 21:32:41

不幸的是,它没有得到很好的记录。正如您提到的那样,瓷砖仅显示上次执行查询的结果 - 至少这是我在测试中观察到的。

在这里使用雪花脚本可能会很有帮助:

DECLARE
    MyVar VARCHAR;
    Rcount NUMBER;
BEGIN
    SELECT TOP 1 TABLE_NAME INTO :MyVar FROM GOKHAN_DB.INFORMATION_SCHEMA.TABLES WHERE NOT TABLE_NAME LIKE 'TEST%' ORDER BY random(); 
    SELECT IFNULL(ROW_COUNT,0) INTO :Rcount FROM GOKHAN_DB.INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = :MyVar;
    RETURN :MyVar || ' ' || :Rcount;
END;

以上代码将作为块执行。

Unfortunately, it's not documented well. As you mentioned, the tiles show only the result of the last executed query - at least this is what I observed on my tests.

Using Snowflake Scripting can be helpful here:

DECLARE
    MyVar VARCHAR;
    Rcount NUMBER;
BEGIN
    SELECT TOP 1 TABLE_NAME INTO :MyVar FROM GOKHAN_DB.INFORMATION_SCHEMA.TABLES WHERE NOT TABLE_NAME LIKE 'TEST%' ORDER BY random(); 
    SELECT IFNULL(ROW_COUNT,0) INTO :Rcount FROM GOKHAN_DB.INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = :MyVar;
    RETURN :MyVar || ' ' || :Rcount;
END;

The above code will be executed as a block.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文