|
58 | 58 | - Tasks will not retry on each execution; each execution is serial. Each script SQL is executed one by one, with no parallel execution. This ensures that the sequence and dependencies of task execution are maintained.
|
59 | 59 | - Interval-based tasks follow a fixed interval spot in a tight way. This means that if the current task execution time exceeds the interval unit, the next task will execute immediately. Otherwise, the next task will wait until the next interval unit is triggered. For example, if a task is defined with a 1-second interval and one task execution takes 1.5 seconds, the next task will execute immediately. If one task execution takes 0.5 seconds, the next task will wait until the next 1-second interval tick starts.
|
60 | 60 |
|
| 61 | +### Important Notes on Cron Expressions |
| 62 | + |
| 63 | +- The cron expression used in the `SCHEDULE` parameter must contain **exactly 6 fields**. |
| 64 | +- The fields represent the following: |
| 65 | + 1. **Second** (0-59) |
| 66 | + 2. **Minute** (0-59) |
| 67 | + 3. **Hour** (0-23) |
| 68 | + 4. **Day of the Month** (1-31) |
| 69 | + 5. **Month** (1-12 or JAN-DEC) |
| 70 | + 6. **Day of the Week** (0-6, where 0 is Sunday, or SUN-SAT) |
| 71 | + |
| 72 | + #### Example Cron Expressions: |
| 73 | + |
| 74 | +- **Daily at 9:00:00 AM Pacific Time:** |
| 75 | + - `USING CRON '0 0 9 * * *' 'America/Los_Angeles'` |
| 76 | + |
| 77 | +- **Every minute:** |
| 78 | + - `USING CRON '0 * * * * *' 'UTC'` |
| 79 | + - This runs the task every minute at the start of the minute. |
| 80 | + |
| 81 | +- **Every hour at the 15th minute:** |
| 82 | + - `USING CRON '0 15 * * * *' 'UTC'` |
| 83 | + - This runs the task every hour at 15 minutes past the hour. |
| 84 | + |
| 85 | +- **Every Monday at 12:00:00 PM:** |
| 86 | + - `USING CRON '0 0 12 * * 1' 'UTC'` |
| 87 | + - This runs the task every Monday at noon. |
| 88 | + |
| 89 | +- **On the first day of every month at midnight:** |
| 90 | + - `USING CRON '0 0 0 1 * *' 'UTC'` |
| 91 | + - This runs the task at midnight on the first day of every month. |
| 92 | + |
| 93 | +- **Every weekday at 8:30:00 AM:** |
| 94 | + - `USING CRON '0 30 8 * * 1-5' 'UTC'` |
| 95 | + - This runs the task every weekday (Monday to Friday) at 8:30 AM. |
| 96 | + |
61 | 97 | ## Usage Examples
|
62 | 98 |
|
63 | 99 | ```sql
|
64 | 100 | CREATE TASK my_daily_task
|
65 | 101 | WAREHOUSE = 'compute_wh'
|
66 |
| - SCHEDULE = USING CRON '0 9 * * * *' 'America/Los_Angeles' |
| 102 | + SCHEDULE = USING CRON '0 0 9 * * *' 'America/Los_Angeles' |
67 | 103 | COMMENT = 'Daily summary task'
|
68 | 104 | AS
|
69 | 105 | INSERT INTO summary_table SELECT * FROM source_table;
|
@@ -105,7 +141,7 @@ In this example, a task named process_orders is created, and it is defined to ru
|
105 | 141 | ```sql
|
106 | 142 | CREATE TASK IF NOT EXISTS hourly_data_cleanup
|
107 | 143 | WAREHOUSE = 'maintenance'
|
108 |
| - SCHEDULE = '0 * * * *' |
| 144 | + SCHEDULE = '0 0 * * * *' |
109 | 145 | WHEN STREAM_STATUS('change_stream') = TRUE
|
110 | 146 | AS
|
111 | 147 | DELETE FROM archived_data
|
|
0 commit comments