在Snowflake中,根据上次查询的ID进行表格过滤。

huangapple go评论69阅读模式
英文:

Filtering in table from last query ID in Snowflake

问题

以下代码正常工作:

CREATE USER test PASSWORD='test';
DESC USER test;
SELECT * from TABLE(RESULT_SCAN(LAST_QUERY_ID()));

但是当我尝试只返回一个列时:

CREATE USER test PASSWORD='test';
DESC USER test;
SELECT value from TABLE(RESULT_SCAN(LAST_QUERY_ID()));

我收到了一个错误:

错误:无效的标识符 'VALUE'。

为什么会返回这个错误,因为'value'是结果扫描中的一个现有列?

英文:

The following code works fine:

CREATE USER test PASSWORD='test';
DESC USER test;
SELECT * from TABLE(RESULT_SCAN(LAST_QUERY_ID()));

However when I try to only return one column:

CREATE USER test PASSWORD='test';
DESC USER test;
SELECT value from TABLE(RESULT_SCAN(LAST_QUERY_ID()));

I get an error:

Error: invalid identifier 'VALUE'.

Why does it return this error, as value is an existing column on the result scan?

答案1

得分: 1

你需要使用引号标识符 "col name" 来访问它:

SELECT value from TABLE(RESULT_SCAN(LAST_QUERY_ID()));
=>
SELECT "value" from TABLE(RESULT_SCAN(LAST_QUERY_ID()));

相关链接: 标识符要求

英文:

You need to use quoted identifier "col name" to access it:

SELECT value from TABLE(RESULT_SCAN(LAST_QUERY_ID()));
=>
SELECT "value" from TABLE(RESULT_SCAN(LAST_QUERY_ID()));

Related: Identifier Requirements

huangapple
  • 本文由 发表于 2023年6月30日 00:34:36
  • 转载请务必保留本文链接:https://go.coder-hub.com/76582993.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定