views
Creates, updates, deletes, gets or lists a views
resource.
Overview
Name | views |
Type | Resource |
Id | snowflake.view.views |
Fields
Name | Datatype | Description |
---|---|---|
name | string | Name of the view |
columns | array | The columns of the view |
comment | string | user comment associated to an object in the dictionary |
created_on | string | Date and time when the view was created. |
database_name | string | Database in which the view is stored |
kind | string | Kind of the view, permanent (default) or temporary |
owner | string | Role that owns the view |
owner_role_type | string | The type of role that owns the view |
query | string | Query used to create the view |
recursive | boolean | Whether or not this view can refer to itself using recursive syntax withot requiring a CTE (common table expression) |
schema_name | string | Schema in which the view is stored |
secure | boolean | Whether or not this view is secure |
Methods
Name | Accessible by | Required Params | Optional Params | Description |
---|---|---|---|---|
fetch_view | SELECT | database_name, name, schema_name, endpoint | - | Fetch a view |
list_views | SELECT | database_name, schema_name, endpoint | like , startsWith , showLimit , fromName , deep | List views |
create_view | INSERT | database_name, schema_name, data__columns, data__name, data__query, endpoint | createMode , copyGrants | Create a view |
delete_view | DELETE | database_name, name, schema_name, endpoint | ifExists | Delete a view |
Optional Parameter Details
Name | Description | Type | Default |
---|---|---|---|
copyGrants | Query parameter to enable copy grants when creating the object. | boolean | false |
createMode | 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. | string | errorIfExists |
deep | Optionally includes dependency information of the view. | boolean | - |
fromName | 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. | string | - |
ifExists | 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. | boolean | false |
like | Query parameter to filter the command output by resource name. Uses case-insensitive pattern matching, with support for SQL wildcard characters. | string | - |
showLimit | Query parameter to limit the maximum number of rows returned by a command. | integer | - |
startsWith | 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. | string | - |
SELECT
examples
List views
SELECT
name,
columns,
comment,
created_on,
database_name,
kind,
owner,
owner_role_type,
query,
recursive,
schema_name,
secure
FROM snowflake.view.views
WHERE database_name = '{{ database_name }}'
AND schema_name = '{{ schema_name }}'
AND endpoint = '{{ endpoint }}';
INSERT
example
Use the following StackQL query and manifest file to create a new views
resource.
- Required Properties
- All Properties
- Manifest
/*+ create */
INSERT INTO snowflake.view.views (
data__name,
data__secure,
data__kind,
data__recursive,
data__columns,
data__comment,
data__query,
database_name,
schema_name,
endpoint
)
SELECT
'{{ name }}',
'{{ secure }}',
'{{ kind }}',
'{{ recursive }}',
'{{ columns }}',
'{{ comment }}',
'{{ query }}',
'{{ database_name }}',
'{{ schema_name }}',
'{{ endpoint }}'
;
/*+ create */
INSERT INTO snowflake.view.views (
data__name,
data__columns,
data__query,
database_name,
schema_name,
endpoint
)
SELECT
'{{ name }}',
'{{ columns }}',
'{{ query }}',
'{{ database_name }}',
'{{ schema_name }}',
'{{ endpoint }}'
;
- name: views
props:
- name: database_name
value: string
- name: schema_name
value: string
- name: data__columns
value: string
- name: data__name
value: string
- name: data__query
value: string
- name: endpoint
value: string
- name: name
value: string
- name: secure
value: boolean
- name: kind
value: string
- name: recursive
value: boolean
- name: columns
value: array
props:
- name: name
value: string
- name: comment
value: string
- name: comment
value: string
- name: query
value: string
DELETE
example
Deletes the specified views
resource.
/*+ delete */
DELETE FROM snowflake.view.views
WHERE database_name = '{{ database_name }}'
AND name = '{{ name }}'
AND schema_name = '{{ schema_name }}'
AND endpoint = '{{ endpoint }}';