notebooks
Creates, updates, deletes, gets or lists a notebooks
resource.
Overview
Name | notebooks |
Type | Resource |
Id | snowflake.notebook.notebooks |
Fields
The following fields are returned by SELECT
queries:
- list_notebooks
- fetch_notebook
A Snowflake notebook
Name | Datatype | Description |
---|---|---|
name | string | Name of the notebook (pattern: ^"([^"]|"")+"|[a-zA-Z_][a-zA-Z0-9_$]*$) |
url_id | string | Unique ID associated with the notebook object. |
database_name | string | Database in which the notebook is stored (pattern: ^"([^"]|"")+"|[a-zA-Z_][a-zA-Z0-9_$]*$) |
runtime_name | string | The runtime to run the Streamlit or Notebook on. If this is not set, the warehouse is assumed |
schema_name | string | Schema in which the notebook is stored (pattern: ^"([^"]|"")+"|[a-zA-Z_][a-zA-Z0-9_$]*$) |
budget | string | Name of the budget if the notebook is monitored by a budget (pattern: ^"([^"]|"")+"|[a-zA-Z_][a-zA-Z0-9_$]*$) |
comment | string | user comment associated to an object in the dictionary |
compute_pool | string | Compute pool name where the snowservice runs |
created_on | string (date-time) | Date and time when the notebook was created. |
default_packages | string | Default packages of the notebook |
default_version | string | The default version name of a file based entity. |
default_version_details | object | The version details of a file based entity |
external_access_integrations | array | List of external access integrations attached to this function |
external_access_secrets | string | Secrets to be used with this function for external access |
fromLocation | string | Location to copy the file from. This must be a Snowflake stage location. |
idle_auto_shutdown_time_seconds | integer (int64) | Sets the time in seconds for when to shutdown an idle Notebook. |
import_urls | array | List of urls |
last_version_details | object | The version details of a file based entity |
live_version_location_uri | string | The current version location |
main_file | string | Name + path of the file for the Notebook |
owner | string | Role that owns the notebook (pattern: ^"([^"]|"")+"|[a-zA-Z_][a-zA-Z0-9_$]*$) |
owner_role_type | string | The type of role that owns the notebook (pattern: ^"([^"]|"")+"|[a-zA-Z_][a-zA-Z0-9_$]*$) |
query_warehouse | string | Warehouse against which the queries issued by the Streamlit app are run against |
title | string | User facing title of the Streamlit app or an Organization Profile |
user_packages | string | User packages of the notebook |
version | string | User specified version alias |
A Snowflake notebook
Name | Datatype | Description |
---|---|---|
name | string | Name of the notebook (pattern: ^"([^"]|"")+"|[a-zA-Z_][a-zA-Z0-9_$]*$) |
url_id | string | Unique ID associated with the notebook object. |
database_name | string | Database in which the notebook is stored (pattern: ^"([^"]|"")+"|[a-zA-Z_][a-zA-Z0-9_$]*$) |
runtime_name | string | The runtime to run the Streamlit or Notebook on. If this is not set, the warehouse is assumed |
schema_name | string | Schema in which the notebook is stored (pattern: ^"([^"]|"")+"|[a-zA-Z_][a-zA-Z0-9_$]*$) |
budget | string | Name of the budget if the notebook is monitored by a budget (pattern: ^"([^"]|"")+"|[a-zA-Z_][a-zA-Z0-9_$]*$) |
comment | string | user comment associated to an object in the dictionary |
compute_pool | string | Compute pool name where the snowservice runs |
created_on | string (date-time) | Date and time when the notebook was created. |
default_packages | string | Default packages of the notebook |
default_version | string | The default version name of a file based entity. |
default_version_details | object | The version details of a file based entity |
external_access_integrations | array | List of external access integrations attached to this function |
external_access_secrets | string | Secrets to be used with this function for external access |
fromLocation | string | Location to copy the file from. This must be a Snowflake stage location. |
idle_auto_shutdown_time_seconds | integer (int64) | Sets the time in seconds for when to shutdown an idle Notebook. |
import_urls | array | List of urls |
last_version_details | object | The version details of a file based entity |
live_version_location_uri | string | The current version location |
main_file | string | Name + path of the file for the Notebook |
owner | string | Role that owns the notebook (pattern: ^"([^"]|"")+"|[a-zA-Z_][a-zA-Z0-9_$]*$) |
owner_role_type | string | The type of role that owns the notebook (pattern: ^"([^"]|"")+"|[a-zA-Z_][a-zA-Z0-9_$]*$) |
query_warehouse | string | Warehouse against which the queries issued by the Streamlit app are run against |
title | string | User facing title of the Streamlit app or an Organization Profile |
user_packages | string | User packages of the notebook |
version | string | User specified version alias |
Methods
The following methods are available for this resource:
Parameters
Parameters can be passed in the WHERE
clause of a query. Check the Methods section to see which parameters are required or optional for each operation.
Name | Datatype | Description |
---|---|---|
database_name | string | Identifier (i.e. name) for the database to which the resource belongs. You can use the /api/v2/databases GET request to get a list of available databases. |
endpoint | string | Organization and Account Name (default: orgid-acctid) |
name | string | Identifier (i.e. name) for the resource. |
schema_name | string | Identifier (i.e. name) for the schema to which the resource belongs. You can use the /api/v2/databases/{database}/schemas GET request to get a list of available schemas for the specified database. |
targetName | string | Name of the target resource. |
asyncExec | boolean | Asynchronous execution enable/disable. Default is disable. |
comment | string | Sets a comment for the notebook or version of the notebook |
createMode | string | Query parameter allowing support for different modes of resource creation. Possible values include: - errorIfExists : Throws an error if you try to create a resource that already exists. - orReplace : Automatically replaces the existing resource with the current one. - ifNotExists : Creates a new resource when an alter is requested for a non-existent resource. |
fromLast | boolean | Sets the LIVE version to the LAST version of the notebook |
fromName | string | Query parameter to enable fetching rows only following the first row whose object name matches the specified string. Case-sensitive and does not have to be the full name. |
ifExists | boolean | Query parameter that specifies how to handle the request for a resource that does not exist: - true : The endpoint does not throw an error if the resource does not exist. It returns a 200 success response, but does not take any action on the resource. - false : The endpoint throws an error if the resource doesn't exist. |
like | string | Query parameter to filter the command output by resource name. Uses case-insensitive pattern matching, with support for SQL wildcard characters. |
showLimit | integer | Query parameter to limit the maximum number of rows returned by a command. |
startsWith | string | Query parameter to filter the command output based on the string of characters that appear at the beginning of the object name. Uses case-sensitive pattern matching. |
targetDatabase | string | Database of the target resource. Defaults to the source's database |
targetSchema | string | Schema of the target resource. Defaults to the source's schema |
version | string | live version of the alias |
SELECT
examples
- list_notebooks
- fetch_notebook
List notebooks
SELECT
name,
url_id,
database_name,
runtime_name,
schema_name,
budget,
comment,
compute_pool,
created_on,
default_packages,
default_version,
default_version_details,
external_access_integrations,
external_access_secrets,
fromLocation,
idle_auto_shutdown_time_seconds,
import_urls,
last_version_details,
live_version_location_uri,
main_file,
owner,
owner_role_type,
query_warehouse,
title,
user_packages,
version
FROM snowflake.notebook.notebooks
WHERE database_name = '{{ database_name }}' -- required
AND schema_name = '{{ schema_name }}' -- required
AND endpoint = '{{ endpoint }}' -- required
AND like = '{{ like }}'
AND startsWith = '{{ startsWith }}'
AND showLimit = '{{ showLimit }}'
AND fromName = '{{ fromName }}';
Fetch a notebook
SELECT
name,
url_id,
database_name,
runtime_name,
schema_name,
budget,
comment,
compute_pool,
created_on,
default_packages,
default_version,
default_version_details,
external_access_integrations,
external_access_secrets,
fromLocation,
idle_auto_shutdown_time_seconds,
import_urls,
last_version_details,
live_version_location_uri,
main_file,
owner,
owner_role_type,
query_warehouse,
title,
user_packages,
version
FROM snowflake.notebook.notebooks
WHERE database_name = '{{ database_name }}' -- required
AND schema_name = '{{ schema_name }}' -- required
AND name = '{{ name }}' -- required
AND endpoint = '{{ endpoint }}' -- required;
INSERT
examples
- create_notebook
- Manifest
Create a notebook
INSERT INTO snowflake.notebook.notebooks (
data__name,
data__version,
data__fromLocation,
data__main_file,
data__comment,
data__default_version,
data__query_warehouse,
data__default_version_details,
data__last_version_details,
database_name,
schema_name,
endpoint,
createMode
)
SELECT
'{{ name }}' --required,
'{{ version }}',
'{{ fromLocation }}',
'{{ main_file }}',
'{{ comment }}',
'{{ default_version }}',
'{{ query_warehouse }}',
'{{ default_version_details }}',
'{{ last_version_details }}',
'{{ database_name }}',
'{{ schema_name }}',
'{{ endpoint }}',
'{{ createMode }}'
;
# Description fields are for documentation purposes
- name: notebooks
props:
- name: database_name
value: string
description: Required parameter for the notebooks resource.
- name: schema_name
value: string
description: Required parameter for the notebooks resource.
- name: endpoint
value: string
description: Required parameter for the notebooks resource.
- name: name
value: string
description: >
Name of the notebook
- name: version
value: string
description: >
User specified version alias
- name: fromLocation
value: string
description: >
Location to copy the file from. This must be a Snowflake stage location.
- name: main_file
value: string
description: >
Name + path of the file for the Notebook
- name: comment
value: string
description: >
user comment associated to an object in the dictionary
- name: default_version
value: string
description: >
The default version name of a file based entity.
- name: query_warehouse
value: string
description: >
Warehouse against which the queries issued by the Streamlit app are run against
- name: default_version_details
value: object
description: >
The version details of a file based entity
- name: last_version_details
value: object
description: >
The version details of a file based entity
- name: createMode
value: string
description: Query parameter allowing support for different modes of resource creation. Possible values include: - `errorIfExists`: Throws an error if you try to create a resource that already exists. - `orReplace`: Automatically replaces the existing resource with the current one. - `ifNotExists`: Creates a new resource when an alter is requested for a non-existent resource.
DELETE
examples
- delete_notebook
Delete a notebook
DELETE FROM snowflake.notebook.notebooks
WHERE database_name = '{{ database_name }}' --required
AND schema_name = '{{ schema_name }}' --required
AND name = '{{ name }}' --required
AND endpoint = '{{ endpoint }}' --required
AND ifExists = '{{ ifExists }}';
Lifecycle Methods
- execute_notebook
- rename_notebook
- add_live_version_notebook
- commit_notebook
Execute a Notebook
EXEC snowflake.notebook.notebooks.execute_notebook
@database_name='{{ database_name }}' --required,
@schema_name='{{ schema_name }}' --required,
@name='{{ name }}' --required,
@endpoint='{{ endpoint }}' --required,
@asyncExec={{ asyncExec }};
Changes the name of the notebook to new name. The new identifier must be unique for the schema.
EXEC snowflake.notebook.notebooks.rename_notebook
@database_name='{{ database_name }}' --required,
@schema_name='{{ schema_name }}' --required,
@name='{{ name }}' --required,
@targetName='{{ targetName }}' --required,
@endpoint='{{ endpoint }}' --required,
@ifExists={{ ifExists }},
@targetDatabase='{{ targetDatabase }}',
@targetSchema='{{ targetSchema }}';
Adds a LIVE version to the notebook
EXEC snowflake.notebook.notebooks.add_live_version_notebook
@database_name='{{ database_name }}' --required,
@schema_name='{{ schema_name }}' --required,
@name='{{ name }}' --required,
@endpoint='{{ endpoint }}' --required,
@fromLast={{ fromLast }},
@comment='{{ comment }}';
If a Git connection is set up for the notebook, commits the LIVE version of the notebook to the Git repository
EXEC snowflake.notebook.notebooks.commit_notebook
@database_name='{{ database_name }}' --required,
@schema_name='{{ schema_name }}' --required,
@name='{{ name }}' --required,
@endpoint='{{ endpoint }}' --required,
@version='{{ version }}',
@comment='{{ comment }}';