Skip to main content

statement_execution

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

Overview

Namestatement_execution
TypeResource
Iddatabricks_workspace.sql.statement_execution

Fields

The following fields are returned by SELECT queries:

NameDatatypeDescription
byte_countintegerThe number of bytes in the result chunk. This field is not available when using `INLINE` disposition.
chunk_indexintegerThe position within the sequence of result set chunks.
data_arrayarrayThe `JSON_ARRAY` format is an array of arrays of values, where each non-null value is formatted as a string. Null values are encoded as JSON `null`.
external_linksarray
next_chunk_indexintegerWhen fetching, provides the `chunk_index` for the _next_ chunk. If absent, indicates there are no more chunks. The next chunk can be fetched with a :method:statementexecution/getstatementresultchunkn request.
next_chunk_internal_linkstringWhen fetching, provides a link to fetch the _next_ chunk. If absent, indicates there are no more chunks. This link is an absolute `path` to be joined with your `$DATABRICKS_HOST`, and should be treated as an opaque link. This is an alternative to using `next_chunk_index`.
row_countintegerThe number of rows within the result chunk.
row_offsetintegerThe starting row offset within the result set.

Methods

The following methods are available for this resource:

NameAccessible byRequired ParamsOptional ParamsDescription
get_result_chunkselectstatement_id, chunk_index, deployment_nameAfter the statement execution has SUCCEEDED, this request can be used to fetch any chunk by index.
getselectstatement_id, deployment_nameThis request can be used to poll for the statement's status. StatementResponse contains statement_id
cancelinsertstatement_id, deployment_nameRequests that an executing statement be canceled. Callers must poll for status to see the terminal
executeinsertdeployment_name, statement, warehouse_idExecute a SQL statement and optionally await its results for a specified time.

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
chunk_indexinteger:returns: :class:ResultData
deployment_namestringThe Databricks Workspace Deployment Name (default: dbc-abcd0123-a1bc)
statement_idstringThe statement ID is returned upon successfully submitting a SQL statement, and is a required reference for all subsequent calls.

SELECT examples

After the statement execution has SUCCEEDED, this request can be used to fetch any chunk by index.

SELECT
byte_count,
chunk_index,
data_array,
external_links,
next_chunk_index,
next_chunk_internal_link,
row_count,
row_offset
FROM databricks_workspace.sql.statement_execution
WHERE statement_id = '{{ statement_id }}' -- required
AND chunk_index = '{{ chunk_index }}' -- required
AND deployment_name = '{{ deployment_name }}' -- required
;

INSERT examples

Requests that an executing statement be canceled. Callers must poll for status to see the terminal

INSERT INTO databricks_workspace.sql.statement_execution (
statement_id,
deployment_name
)
SELECT
'{{ statement_id }}',
'{{ deployment_name }}'
;