AFTER parameter not recognized as part of CREATE TASK

Viewed 57

I've created a task and verified that it exists using SHOW TASKS. I'm now trying to create a subtask using the AFTER parameter of CREATE TASK, but I'm getting the following error: invalid property 'AFTER' for 'TASK'. I can't find any documentation on why this is happening. I think my syntax is correct; it appears to match Snowflake's documentation. This is my code:

//Create the task and set the schedule
CREATE TASK NIGHTLY_1
  WAREHOUSE = ADMIN_WH
  SCHEDULE = 'USING CRON 0 02 * * * America/Chicago'
AS
CALL SP_LOAD_STAGING_TABLE('param1');

//Create the subtask 
CREATE TASK NIGHTLY_2
  WAREHOUSE = ADMIN_WH
  AFTER = NIGHTLY_1
AS
CALL SP_LOAD_STAGING_TABLE('param2');

The notes on the AFTER param state (my emphasis):

The root task in a tree of tasks must be suspended before any task in the tree is recreated (using the CREATE OR REPLACE TASK syntax) or a child task is added (using CREATE TASK … AFTER).

I've verified with SHOW TASKS that the parent task is suspended.

Any thoughts on what is causing the issue?

1 Answers

The equal sign should be removed AFTER = NIGHTLY_1:

//Create the subtask 
CREATE TASK NIGHTLY_2
  WAREHOUSE = ADMIN_WH
  AFTER NIGHTLY_1
AS
CALL SP_LOAD_STAGING_TABLE('param2');

CREATE TASK:

AFTER <string>

Specifies the predecessor task for the current task. When a run of the predecessor task finishes successfully, it triggers this task (after a brief lag).

The same rule applies to ALTER:

ALTER TASK [ IF EXISTS ] <name> REMOVE AFTER <string> | ADD AFTER <string>
Related