雪花存储过程中的执行错误

时间:2021-06-15 17:21:33

标签: snowflake-cloud-data-platform

我编译了一个存储过程,但无法执行它 - 收到此错误:

<块引用>

存储过程SAMPLE_ETL_MONITORING_PROC中的执行错误:存储过程执行错误:在存储过程中无法访问当前用户的请求信息。在 Statement.execute,第 18 行位置 45

我对数据库有写访问权限,但不确定是否必须在脚本中包含任何命令/语句。任何人都可以建议需要做什么吗?

脚本如下:

CREATE OR REPLACE PROCEDURE sample_etl_monitoring_proc()
returns string not null
language javascript
as
$$
var insert_cmd = `
truncate table OOBE.monitoring.load_history_1

`
var sql_insert = snowflake.createStatement({sqlText: insert_cmd});
var insert_result = sql_insert.execute();

var stream_select_cmd = `
insert into OOBE.monitoring.load_history_1
select * from (
select * from OOBE.information_schema.load_history
union
select * from snowplow.information_schema.load_history);

`
var sql_select_stream = snowflake.createStatement({sqlText: stream_select_cmd});
var select_stream_result = sql_select_stream.execute();
return '?';
$$;

1 个答案:

答案 0 :(得分:1)

我重现了错误并通过添加显式调用者的正确声明使其工作:

CREATE OR REPLACE PROCEDURE sample_etl_monitoring_proc()
returns string not null
language javascript
execute as caller
as