Skip to main content

stages

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

Overview

Namestages
TypeResource
Idsnowflake.stage.stages

Fields

The following fields are returned by SELECT queries:

successful

NameDatatypeDescription
namestringString that specifies the identifier (i.e. name) for the stage. (pattern: ^"([^"]|"")+"|[a-zA-Z_][a-zA-Z0-9_$]*$, example: TEST_NAME)
cloudstringCloud provider; always NULL for an internal stage.
commentstringSpecifies a comment for the stage.
created_onstring (date-time)Date and time when the stage was created.
credentialsobjectCredentials 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. (default: PERMANENT)
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_integrationstringStorage integration associated with the stage; always NULL for an internal stage. (pattern: ^"([^"]|"")+"|[a-zA-Z_][a-zA-Z0-9_$]*$, example: TEST_NAME)
urlstringURL for the external stage; blank for an internal stage.

Methods

The following methods are available for this resource:

NameAccessible byRequired ParamsOptional ParamsDescription
list_stagesselectdatabase_name, schema_name, endpointlikeLists stages under the database and schema, with show options as query parameters.
fetch_stageselectdatabase_name, schema_name, name, endpointFetch a stage using the describe command output.
create_stageinsertdatabase_name, schema_name, endpoint, data__namecreateModeCreate 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, schema_name, name, endpointifExistsDelete 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.

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.

NameDatatypeDescription
database_namestringIdentifier (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.
endpointstringOrganization and Account Name (default: orgid-acctid)
namestringIdentifier (i.e. name) for the resource.
schema_namestringIdentifier (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.
createModestringQuery 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.
ifExistsbooleanQuery 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.
likestringQuery parameter to filter the command output by resource name. Uses case-insensitive pattern matching, with support for SQL wildcard characters.

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 }}' -- required
AND schema_name = '{{ schema_name }}' -- required
AND endpoint = '{{ endpoint }}' -- required
AND like = '{{ like }}'
;

INSERT examples

Create 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.

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,
createMode
)
SELECT
'{{ name }}' /* required */,
'{{ kind }}',
'{{ url }}',
'{{ endpoint }}',
'{{ storage_integration }}',
'{{ comment }}',
'{{ credentials }}',
'{{ encryption }}',
'{{ directory_table }}',
'{{ database_name }}',
'{{ schema_name }}',
'{{ endpoint }}',
'{{ createMode }}'
;

DELETE examples

Delete 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.

DELETE FROM snowflake.stage.stages
WHERE database_name = '{{ database_name }}' --required
AND schema_name = '{{ schema_name }}' --required
AND name = '{{ name }}' --required
AND endpoint = '{{ endpoint }}' --required
AND ifExists = '{{ ifExists }}'
;