Documentation
Toggle Dark/Light/Auto modeToggle Dark/Light/Auto modeToggle Dark/Light/Auto modeBack to homepage

CREATE_WAREHOUSE_SCHEDULE

Stored procedure CREATE_WAREHOUSE_SCHEDULE is a Snowflake stored procedure written in Python that is used to construct a warehouse schedule period object. This procedure is defined in database OPSCENTER (database where Snowflake NativeApp is installed) schema ADMIN.

ACCOUNTADMIN privilege is required to run this stored procedure.

See also:
UPDATE_WAREHOUSE_SCHEDULE, DELETE_WAREHOUSE_SCHEDULE, ENABLE_WAREHOUSE_SCHEDULING, DISABLE_WAREHOUSE_SCHEDULING, RESET_WAREHOUSE_SCHEDULING, CREATE_DEFAULT_WAREHOUSE_SCHEDULES

Syntax

CREATE_WAREHOUSE_SCHEDULE(<warehouse_name>,
                          <size>,
			  <start_at>, 
			  <finish_at>, 
			  <is_weekday>,
			  <suspend_minutes>,
			  <autoscale_mode>,  
			  <autoscale_min>,
			  <autoscale_max>,
			  <auto_resume>, 
			  <comment>)

Arguments

<warehouse_name>
a string that represents warehouse name.
<size>
warehouse size string.

Supported values:

X-Small
Small
Medium
Large
X-Large
2X-Large
3X-Large
4X-Large
5X-Large
6X-Large
Medium Snowpark
Large Snowpark
X-Large Snowpark
2X-Large Snowpark
3X-Large Snowpark
4X-Large Snowpark
<start_at>
schedule period start time on a 15 minute boundary. For example: 10:00, 10:15, 10:30, 10:45 The start_at time for a period must be the same value as the finish_at time for the preceding period for the schedule.
<finish_at>
schedule period end time on a 15 minute boundary.
<is_weekday>
if set to TRUE, schedule period is workday (Monday-Friday), if FALSE - weekend (Saturday and Sunday)
<suspend_minutes>
after how many minutes of inactivity warehouse will be suspended.
<autoscale_mode>
Standard or Economy for Snowflake Enterprise Edition.
<autoscale_min>
specifies the minimum number of autoscaled clusters (only applies to multi-cluster warehouses). set it to 0 for Standard.
<autoscale_max>
maximum number of autoscaled clusters (only applies to multi-cluster warehouse). set it to 0 for Standard.
<auto_resume>
True to enable auto-resume to automatically resume a warehouse when a SQL statement is submitted to it.
<comment>
Comments text.

Returns

NULL
if warehouse schedule period was successfully created.
<error>
error message string in the case of failure to warehouse schedule period.

Example:

Here is a warehouse with two default periods and disabled schedule:

vicky#COMPUTE_WH@OPSCENTER.ADMIN>select 
                                  name, 
                                  start_at, 
                                  finish_at, 
                                  size, 
                                  resume, 
                                  weekday, 
                                  enabled 
                                from 
                                  catalog.warehouse_schedules 
                                where 
                                  name = 'BATCH';
+-------+----------+-----------+---------+--------+---------+---------+         
| NAME  | START_AT | FINISH_AT | SIZE    | RESUME | WEEKDAY | ENABLED |
|-------+----------+-----------+---------+--------+---------+---------|
| BATCH | 00:00:00 | 23:59:00  | X-Small | True   | True    | False   |
| BATCH | 00:00:00 | 23:59:00  | X-Small | True   | False   | False   |
+-------+----------+-----------+---------+--------+---------+---------+
2 Row(s) produced. 

Let’s create a new schedule period that starts at 15:00 and ends at midnight:

vicky#COMPUTE_WH@OPSCENTER.ADMIN>call ADMIN.CREATE_WAREHOUSE_SCHEDULE('BATCH', 'Small', '15:00', '23:59',
                                                                      TRUE, 5, 'Standard', 0, 0, TRUE, NULL);
+---------------------------+                                                   
| CREATE_WAREHOUSE_SCHEDULE |
|---------------------------|
| NULL                      |
+---------------------------+
1 Row(s) produced. 

Below you can see a new record in the WAREHOUSE_SCHEDULE view for the warehouse named BATCH:

vicky#COMPUTE_WH@OPSCENTER.ADMIN>select 
                                  name, 
                                  start_at, 
                                  finish_at, 
                                  size, 
                                  resume, 
                                  weekday, 
                                  enabled 
                                from 
                                  catalog.warehouse_schedules 
                                where 
                                  name = 'BATCH';
+-------+----------+-----------+---------+--------+---------+---------+         
| NAME  | START_AT | FINISH_AT | SIZE    | RESUME | WEEKDAY | ENABLED |
|-------+----------+-----------+---------+--------+---------+---------|
| BATCH | 00:00:00 | 15:00:00  | X-Small | True   | True    | False   |
| BATCH | 00:00:00 | 23:59:00  | X-Small | True   | False   | False   |
| BATCH | 15:00:00 | 23:59:00  | Small   | True   | True    | False   |
+-------+----------+-----------+---------+--------+---------+---------+
3 Row(s) produced.