雪花流数据保留

时间:2020-01-21 16:08:50

标签: snowflake-cloud-data-platform snowflake-task

我在Snowflake上的表上创建了一个Stream,并创建了一个将数据移动到表上的任务。即使任务完成后,流中的数据也不会清除。因此,该任务不会被跳过,并继续将数据从流中重新插入到表中,并且最终表将继续增长。可能是什么原因?昨天工作正常,但是从今天起,即使使用任务通过该流执行了DML,该流也不会清除。

create or replace stream test_stream on table test_table_raw APPEND_ONLY = TRUE;
create or replace task test_task_task warehouse = test_warehouse
schedule = '1 minute'
when system$stream_has_data('test_stream') 
as insert into test_table
SELECT 
level1.FILE_NAME,
level1.FILE_ROWNUMBER,
GET(lvl, '@id')::string as app_id
FROM (SELECT FILE_NAME,FILE_ROWNUMBER,src:"$" as lvl FROM test_table_raw)  level1,
lateral FLATTEN(LVL:"$")  level2
where level2.value like '%<test %';

alter task test_task resume;

select 
(select count(*) from test_table) table_count,
(select count(*) from test_stream) stream_count;

TABLE_COUNT STREAM_COUNT
500             1

1 个答案:

答案 0 :(得分:1)

似乎您没有在DML操作中使用该流。您要从构建流的表而不是流本身插入行。为了推进流,您需要将“ FROM test_table_raw”更改为“ FROM test_stream”。试试看,让我知道。

谢谢。