Invalid schedule was specified. Please refer to the docs on what constitutes a valid schedule.

{tocify} $title={Table of Contents}


Problem Statement


Requirement is to create a Task which will run on weekends only at 7:30 am and 7:30 pm . 




Solution


Based on the above requirement, below is the definition of Task

          
            CREATE OR REPLACE TASK Object_Dataupsert_Task_Weekends
            WAREHOUSE=DEV
            schedule='USING CRON 30 7,19 * * SAT-SUN UTC'
            AS CALL Object_Dataupsert();


In the cron expression above, 30 is the minute whereas 7 and 19 are the hrs and SAT-SUN are the days.

Here 30 mins is applicable to both hrs, thus the time will resolve to 7:30 and 19:30.


Error - Invalid schedule was specified

All looks fine above,  but when I tried to execute the script  - there was an error


Invalid schedule was specified


Why it happened


"Invalid schedule was specified. Please refer to the docs on what constitutes a valid schedule."


The error is quite generic, it's just telling that something is not valid in the provided schedule, but what's wrong?

So tried to validate each subexpression(field) in the cron expression.

First doubt was on min field, is it ok to have single value in min field for two values in hrs field - yes, no issue syntactically 

Can we have 2 values in hrs field - yes, no issue syntactically as we can have multiple values in comma separated form

Last piece is Days, SAT-SUN is valid still the error was thrown for it


Why?

The observation after trial and error is that when hrs field has a value then the days in a range form doesn't work i.e. SAT-SUN or MON-FRI etc

But if there is value in only mins field then the days in range form works absolutely fine.



Note : I didn't find any reference for above in snowflake docs 

 

What to do


So here instead of providing the days in range form, provide the  days explicitly in comma separated form

           CREATE OR REPLACE TASK Object_Dataupsert_Task_Weekends
            WAREHOUSE=DEV
            schedule='USING CRON 30 7,19 * * SAT,SUN UTC'
            AS CALL Object_Dataupsert();

That's all, error was gone and task was created

If you have questions or suggestions, feel free to do in comments section below !!!


Do share if you find this helpful .......
 
                          Knowledge Sharing is Caring !!!!!!




Amazon_India Great Festival Sale | Getupto 70%OFF on Amazon Brands & More


Learn More about some more Snowflake errors








.

Post a Comment

If you have any suggestions or questions or want to share something then please drop a comment

Previous Post Next Post