Reputation: 15
Trying to schedule task on 23rd of every month ,after the some particular tasks
CREATE OR REPLACE TASK p.pat_t
WAREHOUSE = W_Simple
SCHEDULE = 'USING CRON 0 0 23 * * America'
TIMESTAMP_INPUT_FORMAT = 'YYYY-MM-DD HH24'
after DE_ER
** Getting an error ERROR cannot have both a schedule and a predecessor.**
Upvotes: 0
Views: 411
Reputation: 10059
It's expected: A schedule cannot be specified for child tasks in a DAG.
https://docs.snowflake.com/en/sql-reference/sql/create-task.html#optional-parameters
DAG: A Directed Acyclic Graph (DAG) is a series of tasks composed of a single root task and additional tasks, organized by their dependencies.
https://docs.snowflake.com/en/user-guide/tasks-intro.html#label-task-dag
As the predecessor will have a scheduler, why do you need to give a scheduled time for the child task?
Additional info: If the predecessor task is run every day but you want to run your task on only a specific day, you can call an SP (or SQL block) from your task and check the day before running the actual SQL statements. For example:
CREATE OR REPLACE TASK p.pat_t
WAREHOUSE = W_Simple
TIMESTAMP_INPUT_FORMAT = 'YYYY-MM-DD HH24'
after DE_ER
AS
BEGIN
IF ( DAY(current_date()) = 23 ) THEN
-- INSERT ETC
-- SELECT ETC;
END IF;
END;
Rohit you need to add SQL statements instead of comments. Here is a sample:
CREATE OR REPLACE TASK DE_ER
WAREHOUSE = gokhan_wh
SCHEDULE = 'USING CRON 0 0 23 * * Europe/Amsterdam'
as
select current_Date();
CREATE OR REPLACE TASK pat_t
WAREHOUSE = gokhan_wh
TIMESTAMP_INPUT_FORMAT = 'YYYY-MM-DD HH24'
after DE_ER
AS
BEGIN
IF ( DAY(current_date()) = 23 ) THEN
SELECT CURRENT_DATE();
END IF;
END;
Upvotes: 1