statements
Creates, updates, deletes, gets or lists a statements resource.
Overview
| Name | statements |
| Type | Resource |
| Id | aws.redshift_data.statements |
Fields
The following fields are returned by SELECT queries:
- describe_statement
| Name | Datatype | Description |
|---|---|---|
cluster_identifier | string | The cluster identifier. |
created_at | string (date-time) | The date and time (UTC) when the SQL statement was submitted to run. |
database | string | The name of the database. |
db_user | string | The database user name. |
duration | integer (int64) | The amount of time in nanoseconds that the statement ran. |
error | string | The error message from the cluster if the SQL statement encountered an error while running. |
execution_mode | string | The execution mode of the batch request. TRANSACTION indicates all SQL statements are run as a single transaction. AUTO_COMMIT indicates each SQL statement is committed individually. (TRANSACTION, AUTO_COMMIT) |
has_result_set | boolean | A value that indicates whether the statement has a result set. The result set can be empty. The value is true for an empty result set. The value is true if any substatement returns a result set. |
id | string | The identifier of the SQL statement described. This value is a universally unique identifier (UUID) generated by Amazon Redshift Data API. (pattern: <code>[a-z0-9]{8}(-[a-z0-9]{4}){3}-[a-z0-9]{12}(:\d{0,2})?</code>) |
query_parameters | array | The parameters for the SQL statement. |
query_string | string | The SQL statement text. |
redshift_pid | integer (int64) | The process identifier from Amazon Redshift. |
redshift_query_id | integer (int64) | The identifier of the query generated by Amazon Redshift. These identifiers are also available in the query column of the STL_QUERY system view. |
result_format | string | The data format of the result of the SQL statement. (JSON, CSV) |
result_rows | integer (int64) | Either the number of rows returned from the SQL statement or the number of rows affected. If result size is greater than zero, the result rows can be the number of rows affected by SQL statements such as INSERT, UPDATE, DELETE, COPY, and others. A -1 indicates the value is null. |
result_size | integer (int64) | The size in bytes of the returned results. A -1 indicates the value is null. |
secret_arn | string | The name or Amazon Resource Name (ARN) of the secret that enables access to the database. |
session_id | string | The session identifier of the query. |
status | string | The status of the SQL statement being described. Status values are defined as follows: ABORTED - The query run was stopped by the user. ALL - A status value that includes all query statuses. This value can be used to filter results. FAILED - The query run failed. FINISHED - The query has finished running. PICKED - The query has been chosen to be run. STARTED - The query run has started. SUBMITTED - The query was submitted, but not yet processed. (SUBMITTED, PICKED, STARTED, FINISHED, ABORTED, FAILED, ALL) |
sub_statements | array | The SQL statements from a multiple statement run. |
updated_at | string (date-time) | The date and time (UTC) that the metadata for the SQL statement was last updated. An example is the time the status last changed. |
workgroup_name | string | The serverless workgroup name or Amazon Resource Name (ARN). (pattern: <code>([a-z0-9-]{3,63}|arn:(aws(-[a-z]+)*):redshift-serverless:([a-z]{2}(-gov|(-iso[a-z]?))?|eusc-[a-z]+)-[a-z]+-\d{1}:\d{12}:workgroup/[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})</code>) |
Methods
The following methods are available for this resource:
| Name | Accessible by | Required Params | Optional Params | Description |
|---|---|---|---|---|
describe_statement | select | region | Describes the details about a specific instance when a query was run by the Amazon Redshift Data API. The information includes when the query started, when it finished, the query status, the number of rows returned, and the SQL statement. For more information about the Amazon Redshift Data API and CLI usage examples, see Using the Amazon Redshift Data API in the Amazon Redshift Management Guide. | |
list_statements | exec | region | List of SQL statements. By default, only finished statements are shown. A token is returned to page through the statement list. When you use identity-enhanced role sessions to list statements, you must provide either the cluster-identifier or workgroup-name parameter. This ensures that the IdC user can only access the Amazon Redshift IdC applications they are assigned. For more information, see Trusted identity propagation overview. For more information about the Amazon Redshift Data API and CLI usage examples, see Using the Amazon Redshift Data API in the Amazon Redshift Management Guide. |
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 |
|---|---|---|
region | string | AWS region (default: us-east-1) |
SELECT examples
- describe_statement
Describes the details about a specific instance when a query was run by the Amazon Redshift Data API. The information includes when the query started, when it finished, the query status, the number of rows returned, and the SQL statement. For more information about the Amazon Redshift Data API and CLI usage examples, see Using the Amazon Redshift Data API in the Amazon Redshift Management Guide.
SELECT
cluster_identifier,
created_at,
database,
db_user,
duration,
error,
execution_mode,
has_result_set,
id,
query_parameters,
query_string,
redshift_pid,
redshift_query_id,
result_format,
result_rows,
result_size,
secret_arn,
session_id,
status,
sub_statements,
updated_at,
workgroup_name
FROM aws.redshift_data.statements
WHERE region = '{{ region }}' -- required
;
Lifecycle Methods
- list_statements
List of SQL statements. By default, only finished statements are shown. A token is returned to page through the statement list. When you use identity-enhanced role sessions to list statements, you must provide either the cluster-identifier or workgroup-name parameter. This ensures that the IdC user can only access the Amazon Redshift IdC applications they are assigned. For more information, see Trusted identity propagation overview. For more information about the Amazon Redshift Data API and CLI usage examples, see Using the Amazon Redshift Data API in the Amazon Redshift Management Guide.
EXEC aws.redshift_data.statements.list_statements
@region='{{ region }}' --required
@@json=
'{
"NextToken": "{{ NextToken }}",
"MaxResults": {{ MaxResults }},
"StatementName": "{{ StatementName }}",
"Status": "{{ Status }}",
"RoleLevel": {{ RoleLevel }},
"Database": "{{ Database }}",
"ClusterIdentifier": "{{ ClusterIdentifier }}",
"WorkgroupName": "{{ WorkgroupName }}"
}'
;