CREATE SCHEDULE
CREATE SCHEDULE
allows a SQL or PQL statement to be executed on a schedule.
Syntax
CREATE SCHEDULE schedule_name
START date_time
{ CRON 'expression' | INTERVAL expr time_unit }
AS statement
Schedule name
A unique name for the schedule.
Start datetime
A date or date-time in one of two forms:
DATE 'YYYY-MM-DD'
TIMESTAMP 'YYYY-MM-DD HH:mm:ss'
Cron expression
A cron expression is of form:
┌───────────── minute (0 - 59)
│ ┌───────────── hour (0 - 23)
│ │ ┌───────────── day of the month (1 - 31)
│ │ │ ┌───────────── month (1 - 12)
│ │ │ │ ┌───────────── day of the week (0 - 6) (Sunday to Saturday;
│ │ │ │ │
│ │ │ │ │
│ │ │ │ │
* * * * *
Interval expression
An interval expression can also be used with time units MINUTE
, HOUR
, DAY
or MONTH
eg:
INTERVAL 6 HOURS
Statement
The statement run on the schedule can be one of the following types of statements
SELECT
statementPREDICT
statementINSERT INTO
statementCREATE TABLE AS
statement
Examples
The statement will be executed once per day at 11pm starting January first, 2022:
CREATE SCHEDULE titanic_schedule
START DATE '2022-01-01'
CRON '0 23 * * *'
AS
INSERT INTO titanic_predictions
PREDICT Survived
GIVEN SELECT * from titanic limit 10
To run the schedule every 6 hours you could a INTERVAL
expression which would be equivalent to CRON '* */6 * * *'
CREATE SCHEDULE titanic_schedule
START TIMESTAMP '2022-01-01'
INTERVAL 6 HOURS
AS
CREATE TABLE titanic_predictions AS
PREDICT Survived
GIVEN SELECT * from titanic limit 10