skw
skw

Reputation: 3

Snowflake cron task bug? (Can't do for every x day of month)

I believe there's major flaw in the task scheduling using cron job - correct me if I am wrong or I am missing something:

Perfectly fine if scheduled on the day of month before desired day of future months (today is 5th and I can schedule task for 6th every mth or any day parameter between 5 to 12)

CREATE OR REPLACE TASK MYTASK
 WAREHOUSE= XXX
 SCHEDULE = 'USING CRON 1 17 6 * * Asia/Kuala_Lumpur'
AS CALL SP_ALL_OPS();


ALTER TASK MYTASK RESUME;


select * from table(information_schema.task_history(task_name=>'MYTASK')) WHERE STATE = 'SCHEDULED';

Not fine if scheduled on the day of month before desired day of future months (today is 5th and I CANT schedule for task for 1st every month). TO ADD ON: the task can only accept day between 5 to 12 (exactly 1 week). Numbers beyond this range can't be used at all (BIZARRE BEHAVIOR @@)

CREATE OR REPLACE TASK MYTASK
 WAREHOUSE= XXX
 SCHEDULE = 'USING CRON 1 17 1 * * Asia/Kuala_Lumpur'
AS CALL SP_ALL_OPS();


ALTER TASK MYTASK RESUME;


select * from table(information_schema.task_history(task_name=>'MYTASK')) WHERE STATE = 'SCHEDULED';

Did I do anything wrong? Let me know if there's solution for this. In such situation I can only schedule task every 1st of the month and to run the desired task on the first run? This doesn't make sense at all as typical linux machine cron job doesn't behave such way. Couldn't find a solution online - so if anyone can shed some lights on this it will be helpful.

EDIT: "Not fine" here because when I run the task above it doesn't show whether the task has been "scheduled". Good that it's pointed out the query can only 'returns task activity within the last 7 days or the next scheduled execution within the next 8 days'.

Upvotes: 0

Views: 254

Answers (1)

Gokhan Atil
Gokhan Atil

Reputation: 10059

It's not about scheduling the task. If you run the following command you should be able to see the task and its state will be "STARTED" which means it's scheduled.

SHOW TASKS LIKE 'MYTASK';

This is about the information_schema.task_history function:

https://docs.snowflake.com/en/sql-reference/functions/task_history.html#usage-notes

This function can return all executions run in the past 7 days or the next scheduled execution within the next 8 days.

Upvotes: 1

Related Questions