I am trying to build some tasks to automate some of my processes. I have included the code for my tasks which execute successfully and have tested out manually, it achieves the correct end result. Also, please forgive my lack of SQL etiquette, just started working on DB's and really learning SQL about a month ago.
Here are the resume commands for the tasks. The first one works fine, the other three however do not.
alter task create_hubspot_mql_yesterday_table resume;
alter task create_pega_mql_yesterday_table resume;
alter task create_hubspot_pega_diff_yesterday_table resume;
alter task suspendwarehouse3 resume;
The error I am getting is this: Unable to update graph with root task XXXX since that root task is not suspended.
-- task 1: creates the hubspot mql yesterday report from hubspot data
create or replace task create_hubspot_mql_yesterday_table
warehouse = pc_fivetran_wh
schedule = 'USING CRON 0 6-20 * * MON-FRI America/Denver'
as create or replace table myfirstdatabase.hubspot.hubspot_mql_yesterday
as select * from pc_fivetran_db.hubspot.contact where PROPERTY_HS_LIFECYCLESTAGE_MARKETINGQUALIFIEDLEAD_DATE < current_date
and PROPERTY_HS_LIFECYCLESTAGE_MARKETINGQUALIFIEDLEAD_DATE > current_date - INTERVAL '1 d';
-- task 2: creates the pega mql yesterday report from pega lead data
create or replace task create_pega_mql_yesterday_table
warehouse = pc_fivetran_wh
after create_hubspot_mql_yesterday_table
as create or replace table myfirstdatabase.hubspot.pega_mql_yesterday
as select * from myfirstdatabase.public.pega_leads where BECAMEAMQLDATE <= current_date + INTERVAL '7 h'
and BECAMEAMQLDATE >= current_date - INTERVAL '1 d';
-- task 3: full outer join to determine differnce in id's between hubspot and pega tables
create or replace task create_hubspot_pega_diff_yesterday_table
warehouse = pc_fivetran_wh
after create_pega_mql_yesterday_table
as create or replace table myfirstdatabase.hubspot.hubspot_pega_mql_yesterday_delta
as select
myfirstdatabase.hubspot.hubspot_mql_yesterday.id as hubspot_contact_id,
myfirstdatabase.hubspot.pega_mql_yesterday.hubspotcontactid as pega_hubspot_contact_id
from myfirstdatabase.hubspot.hubspot_mql_yesterday
full outer join myfirstdatabase.hubspot.pega_mql_yesterday
on myfirstdatabase.hubspot.hubspot_mql_yesterday.id = myfirstdatabase.hubspot.pega_mql_yesterday.hubspotcontactid
where myfirstdatabase.hubspot.hubspot_mql_yesterday.id is null or myfirstdatabase.hubspot.pega_mql_yesterday.hubspotcontactid is null;
-- task 4: suspend the warehouse after the chain of tasks
create or replace task suspendwarehouse3
warehouse = pc_fivetran_wh
after create_hubspot_pega_diff_yesterday_table
as
alter warehouse compute_wh suspend;
When creating the tasks they execute successfully.
When I run the show tasks command:
show tasks in pc_fivetran_db.hubspot;
I appreciate any help or advice on how to fix this error.
Your child tasks named create_pega_mql_yesterday_table
and create_hubspot_pega_diff_yesterday_table
are running DDL statements.
Per the Snowflake Tasks documentation for the AFTER parameter, you'll likely need to suspend the root task before you can run these, or use an equivalent non-DDL statement:
Executing DDL commands on any task in a tree of tasks requires that the root task is suspended. If the root task is currently resumed, then the command returns a user error.