Write a Snowflake query to create and schedule a task that runs every hour.
Asked in the Technical round 1 stage. Since the target database is PostgreSQL, implement the equivalent using PostgreSQL-compatible objects without requiring optional extensions. Register the task and define the routine that an external scheduler can invoke hourly.
schedule_name, cron_expression, command, and activeschedule_name| Column | Type | Description |
|---|---|---|
| schedule_namePK | VARCHAR(100) | Unique registered task name |
| cron_expression | VARCHAR(30) | Cron expression defining the schedule |
| command | TEXT | PostgreSQL command executed by the scheduler |
| active | BOOLEAN | Whether the schedule is enabled |
| timezone | VARCHAR(64) | Timezone used for schedule interpretation |
| owner | VARCHAR(100) | Team responsible for the schedule |
| last_registered_at | TIMESTAMPTZ | Timestamp when the definition was last registered |
| Column | Type | Description |
|---|---|---|
| run_idPK | BIGINT | Unique task execution identifier |
| task_name | VARCHAR(100) | Name of the registered task |
| started_at | TIMESTAMPTZ | Execution start timestamp |
| status | VARCHAR(20) | Execution status |
| details | TEXT | Execution details or error message |