Skip to main content

stages

Creates, updates, deletes, gets or lists a stages resource.

Overview

Namestages
TypeResource
Idsnowflake.stage.stages

Fields

NameDatatypeDescription
namestringA Snowflake object identifier. If the identifier contains spaces or special characters, the entire string must be enclosed in double quotes. Identifiers enclosed in double quotes are also case-sensitive.
cloudstringCloud provider; always NULL for an internal stage.
commentstringSpecifies a comment for the stage.
created_onstringDate and time when the stage was created.
credentialsobjectSpecifies the credentials of the stage.
directory_tableobjectDirectory table parameters of the stage.
encryptionobjectEncryption parameters of the stage.
endpointstringThe S3-compatible API endpoint associated with the stage; always NULL for stages that are not S3-compatible.
has_credentialsbooleanIndicates that the external stage has access credentials; always false for an internal stage.
has_encryption_keybooleanIndicates that the external stage contains encrypted files; always false for an internal stage.
kindstringSpecifies whether the stage is permanent or temporary.
ownerstringRole that owns the stage.
owner_role_typestringThe type of role that owns the object, either ROLE or DATABASE_ROLE. If a Snowflake Native App owns the object, the value is APPLICATION. Snowflake returns NULL if you delete the object because a deleted object does not have an owner role.
regionstringRegion where the stage is located.
storage_integrationstringA Snowflake object identifier. If the identifier contains spaces or special characters, the entire string must be enclosed in double quotes. Identifiers enclosed in double quotes are also case-sensitive.
urlstringURL for the external stage; blank for an internal stage.

Methods

NameAccessible byRequired ParamsDescription
fetch_stageSELECTdatabase_name, name, schema_name, endpointFetch a stage using the describe command output.
list_stagesSELECTdatabase_name, schema_name, endpointLists stages under the database and schema, with show options as query parameters.
create_stageINSERTdatabase_name, schema_name, data__name, endpointCreate a stage, with standard create modifiers as query parameters. See the Stage component definition for what is required to be provided in the request body.
delete_stageDELETEdatabase_name, name, schema_name, endpointDelete a stage with the stage name. If ifExists is used, the operation will succeed even if the object does not exist. Otherwise, there will be a failure if the drop is unsuccessful.

SELECT examples

Lists stages under the database and schema, with show options as query parameters.

SELECT
name,
cloud,
comment,
created_on,
credentials,
directory_table,
encryption,
endpoint,
has_credentials,
has_encryption_key,
kind,
owner,
owner_role_type,
region,
storage_integration,
url
FROM snowflake.stage.stages
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 stages resource.

/*+ create */
INSERT INTO snowflake.stage.stages (
data__name,
data__kind,
data__url,
data__endpoint,
data__storage_integration,
data__comment,
data__credentials,
data__encryption,
data__directory_table,
database_name,
schema_name,
endpoint
)
SELECT
'{{ name }}',
'{{ kind }}',
'{{ url }}',
'{{ endpoint }}',
'{{ storage_integration }}',
'{{ comment }}',
'{{ credentials }}',
'{{ encryption }}',
'{{ directory_table }}',
'{{ database_name }}',
'{{ schema_name }}'
;

DELETE example

Deletes the specified stages resource.

/*+ delete */
DELETE FROM snowflake.stage.stages
WHERE database_name = '{{ database_name }}'
AND name = '{{ name }}'
AND schema_name = '{{ schema_name }}'
AND endpoint = '{{ endpoint }}';