One of the things that we’re trying to create as Engineers is a robust system that keeps working through failure.
This week we’re going to expand these capabilities when looking at tasks : Even though a task fails , it’s chained task must still continue.
For this challenge , we’ve got a task that is very error prone (for some reason that we still haven’t figured out 😉 ) but even if it DOES fail, we still want a notification in our table that the task itself failed.
The code:
Setup
CREATE OR REPLACE TABLE task_table (stamp time, message varchar);
CREATE OR REPLACE TASK main_task
SCHEDULE = '1 minute'
USER_TASK_MANAGED_INITIAL_WAREHOUSE_SIZE = 'XSMALL'
AS
SELECT CASE
WHEN RANDOM() <0 THEN 1/0
ELSE 1
END;
CREATE OR REPLACE TASK child_task
AFTER main_task
AS
INSERT INTO task_table (stamp,message) VALUES(CURRENT_TIMESTAMP,'main_task succes!');
The challenge
We want you to write a task that is chained to main_task and always runs even if the main_task fails.
The task should simply insert the message ‘task ran’ into task_table with an accompanying timestamp
ChrisHastie says
A nice way to kick off the new year, knowing that we can always make something succeed in the end, even if a step or two fail along the way