提问人:YogeshR 提问时间:5/28/2023 更新时间:5/28/2023 访问量:181
雪花 |在发生故障时保留流数据
Snowflake | retain stream data in case of failure
问:
我们希望使用流将数据从一个源表插入到多个目标表。为此,我们在源表上创建了 steam。
为此,我们使用 Java 脚本过程。我们首先将流数据插入到临时表中,然后编写了一些查询以使用临时表在多个目标表中插入数据。
如果该过程在任何查询中失败,我们也会丢失流数据。如果程序失败,我们如何保护流数据?
下面是我的过程的示例代码
CREATE OR REPLACE PROCEDURE test_proc()
RETURNS string
LANGUAGE javascript
strict
EXECUTE AS owner
AS
$$
try {
snowflake.execute({
sqlText: "BEGIN NAME test_update;"
});
snowflake.execute({
sqlText: "CREATE OR REPLACE TEMPORARY TABLE temp_1 as SELECT * FROM STREAM_TEST_1;"
});
snowflake.execute({
sqlText: "DELETE FROM TAB_2 WHERE ID IN (Select ID from temp_1 where name = 'TEST');"
});
snowflake.execute({
sqlText: "DELETE FROM TAB_3 WHERE ID IN (Select ID from temp_1 where name = 'DUMMY');"
});
snowflake.execute({
sqlText: "INSERT INTO TAB_4 SELECT ID, NAME FROM temp_1 where name = 'ABC';"
});
snowflake.execute({
sqlText: "INSERT INTO TAB_5 SELECT ID, NAME FROM temp_1 where name = 'XYZ';"
});
return "success";
} catch (err) {
snowflake.execute({
sqlText: "ROLLBACK;"
});
}
$$;
答: 暂无答案
评论