statements
Creates, updates, deletes, gets or lists a statements
resource.
Overview
Name | statements |
Type | Resource |
Id | snowflake.sqlapi.statements |
Fields
The following fields are returned by SELECT
queries:
- get_statement_status
The statement was executed successfully, and the response includes any data requested.
Name | Datatype | Description |
---|---|---|
code | string | (example: 000123) |
createdOn | integer (int64) | Timestamp that specifies when the statement execution started. The timestamp is expressed in milliseconds since the epoch. |
data | array | Result set data. |
message | string | (example: successfully executed) |
resultSetMetaData | object | |
sqlState | string | (example: 42601) |
statementHandle | string (uuid) | (example: 536fad38-b564-4dc5-9892-a4543504df6c) |
statementStatusUrl | string (uri) | |
stats | object | these stats might not be available for each request. |
Methods
The following methods are available for this resource:
Name | Accessible by | Required Params | Optional Params | Description |
---|---|---|---|---|
get_statement_status | select | endpoint | Checks the status of the execution of the statement with the specified statement handle. If the statement was executed successfully, the operation returns the requested partition of the result set. | |
submit_statement | insert | endpoint | Submits one or more statements for execution. You can specify that the statement should be executed asynchronously. | |
cancel_statement | delete | endpoint | Cancels the execution of the statement with the specified statement handle. |
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 |
---|---|---|
endpoint | string | Organization and Account Name (default: orgid-acctid) |
SELECT
examples
- get_statement_status
Checks the status of the execution of the statement with the specified statement handle. If the statement was executed successfully, the operation returns the requested partition of the result set.
SELECT
code,
createdOn,
data,
message,
resultSetMetaData,
sqlState,
statementHandle,
statementStatusUrl,
stats
FROM snowflake.sqlapi.statements
WHERE endpoint = '{{ endpoint }}' -- required;
INSERT
examples
- submit_statement
- Manifest
Submits one or more statements for execution. You can specify that the statement should be executed asynchronously.
INSERT INTO snowflake.sqlapi.statements (
data__statement,
data__timeout,
data__database,
data__schema,
data__warehouse,
data__role,
data__bindings,
data__parameters,
endpoint
)
SELECT
'{{ statement }}',
{{ timeout }},
'{{ database }}',
'{{ schema }}',
'{{ warehouse }}',
'{{ role }}',
'{{ bindings }}',
'{{ parameters }}',
'{{ endpoint }}'
RETURNING
code,
createdOn,
data,
message,
resultSetMetaData,
sqlState,
statementHandle,
statementStatusUrl,
stats
;
# Description fields are for documentation purposes
- name: statements
props:
- name: endpoint
value: string
description: Required parameter for the statements resource.
- name: statement
value: string
description: >
SQL statement or batch of SQL statements to execute. You can specify query, DML and DDL statements. The following statements are not supported: PUT, GET, USE, ALTER SESSION, BEGIN, COMMIT, ROLLBACK, statements that set session variables, and statements that create temporary tables and stages.
- name: timeout
value: integer
description: >
Timeout in seconds for statement execution. If the execution of a statement takes longer than the specified timeout, the execution is automatically canceled. To set the timeout to the maximum value (604800 seconds), set timeout to 0.
- name: database
value: string
description: >
Database in which the statement should be executed. The value in this field is case-sensitive.
- name: schema
value: string
description: >
Schema in which the statement should be executed. The value in this field is case-sensitive.
- name: warehouse
value: string
description: >
Warehouse to use when executing the statement. The value in this field is case-sensitive.
- name: role
value: string
description: >
Role to use when executing the statement. The value in this field is case-sensitive.
- name: bindings
value: object
description: >
Values of bind variables in the SQL statement. When executing the statement, Snowflake replaces placeholders ('?' and ':name') in the statement with these specified values.
- name: parameters
value: object
description: >
Session parameters that should be set before executing the statement.
DELETE
examples
- cancel_statement
Cancels the execution of the statement with the specified statement handle.
DELETE FROM snowflake.sqlapi.statements
WHERE endpoint = '{{ endpoint }}' --required;