雪花流未清除

时间:2020-01-14 19:32:29

标签: snowflake-cloud-data-platform

我在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

2 个答案:

答案 0 :(得分:0)

交易是否正在提交;即您是否看到插入或使用该流的任务中的DML应该发生的事情? 您可以发布SQL。

当使用流的事务提交时,流偏移发生更改。确实没有“清除”,但流偏移量只是向前移动,因此您不会再看到相同的行。

Dinesh Kulkarni (下午,雪花)

答案 1 :(得分:0)

我不好!我在任务中使用基表,而不是使用流。

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* test_stream)  level1,
lateral FLATTEN(LVL:"$")  level2
where level2.value like '%<test %';