Skip to main content

statements

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

Overview

Namestatements
TypeResource
Idaws.redshift_data.statements

Fields

The following fields are returned by SELECT queries:

NameDatatypeDescription
cluster_identifierstringThe cluster identifier.
created_atstring (date-time)The date and time (UTC) when the SQL statement was submitted to run.
databasestringThe name of the database.
db_userstringThe database user name.
durationinteger (int64)The amount of time in nanoseconds that the statement ran.
errorstringThe error message from the cluster if the SQL statement encountered an error while running.
execution_modestringThe 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_setbooleanA 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.
idstringThe 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_parametersarrayThe parameters for the SQL statement.
query_stringstringThe SQL statement text.
redshift_pidinteger (int64)The process identifier from Amazon Redshift.
redshift_query_idinteger (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_formatstringThe data format of the result of the SQL statement. (JSON, CSV)
result_rowsinteger (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_sizeinteger (int64)The size in bytes of the returned results. A -1 indicates the value is null.
secret_arnstringThe name or Amazon Resource Name (ARN) of the secret that enables access to the database.
session_idstringThe session identifier of the query.
statusstringThe 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_statementsarrayThe SQL statements from a multiple statement run.
updated_atstring (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_namestringThe 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:

NameAccessible byRequired ParamsOptional ParamsDescription
describe_statementselectregionDescribes 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_statementsexecregionList 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.

NameDatatypeDescription
regionstringAWS region (default: us-east-1)

SELECT examples

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 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 }}"
}'
;