

# DescribeStatement
<a name="API_DescribeStatement"></a>

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 AWS CLI usage examples, see [Using the Amazon Redshift Data API](https://docs.aws.amazon.com/redshift/latest/mgmt/data-api.html) in the *Amazon Redshift Management Guide*. 

## Request Syntax
<a name="API_DescribeStatement_RequestSyntax"></a>

```
{
   "Id": "string"
}
```

## Request Parameters
<a name="API_DescribeStatement_RequestParameters"></a>

For information about the parameters that are common to all actions, see [Common Parameters](CommonParameters.md).

The request accepts the following data in JSON format.

**Note**  
In the following list, the required parameters are described first.

 ** [Id](#API_DescribeStatement_RequestSyntax) **   <a name="redshiftdata-DescribeStatement-request-Id"></a>
The identifier of the SQL statement to describe. This value is a universally unique identifier (UUID) generated by Amazon Redshift Data API. A suffix indicates the number of the SQL statement. For example, `d9b6c0c9-0747-4bf4-b142-e8883122f766:2` has a suffix of `:2` that indicates the second SQL statement of a batch query. This identifier is returned by `BatchExecuteStatment`, `ExecuteStatement`, and `ListStatements`.   
Type: String  
Pattern: `[a-z0-9]{8}(-[a-z0-9]{4}){3}-[a-z0-9]{12}(:\d+)?`   
Required: Yes

## Response Syntax
<a name="API_DescribeStatement_ResponseSyntax"></a>

```
{
   "ClusterIdentifier": "string",
   "CreatedAt": number,
   "Database": "string",
   "DbUser": "string",
   "Duration": number,
   "Error": "string",
   "HasResultSet": boolean,
   "Id": "string",
   "QueryParameters": [ 
      { 
         "name": "string",
         "value": "string"
      }
   ],
   "QueryString": "string",
   "RedshiftPid": number,
   "RedshiftQueryId": number,
   "ResultFormat": "string",
   "ResultRows": number,
   "ResultSize": number,
   "SecretArn": "string",
   "SessionId": "string",
   "Status": "string",
   "SubStatements": [ 
      { 
         "CreatedAt": number,
         "Duration": number,
         "Error": "string",
         "HasResultSet": boolean,
         "Id": "string",
         "QueryString": "string",
         "RedshiftQueryId": number,
         "ResultRows": number,
         "ResultSize": number,
         "Status": "string",
         "UpdatedAt": number
      }
   ],
   "UpdatedAt": number,
   "WorkgroupName": "string"
}
```

## Response Elements
<a name="API_DescribeStatement_ResponseElements"></a>

If the action is successful, the service sends back an HTTP 200 response.

The following data is returned in JSON format by the service.

 ** [Id](#API_DescribeStatement_ResponseSyntax) **   <a name="redshiftdata-DescribeStatement-response-Id"></a>
The identifier of the SQL statement described. This value is a universally unique identifier (UUID) generated by Amazon Redshift Data API.   
Type: String  
Pattern: `[a-z0-9]{8}(-[a-z0-9]{4}){3}-[a-z0-9]{12}(:\d+)?` 

 ** [ClusterIdentifier](#API_DescribeStatement_ResponseSyntax) **   <a name="redshiftdata-DescribeStatement-response-ClusterIdentifier"></a>
The cluster identifier.   
Type: String

 ** [CreatedAt](#API_DescribeStatement_ResponseSyntax) **   <a name="redshiftdata-DescribeStatement-response-CreatedAt"></a>
The date and time (UTC) when the SQL statement was submitted to run.   
Type: Timestamp

 ** [Database](#API_DescribeStatement_ResponseSyntax) **   <a name="redshiftdata-DescribeStatement-response-Database"></a>
The name of the database.   
Type: String

 ** [DbUser](#API_DescribeStatement_ResponseSyntax) **   <a name="redshiftdata-DescribeStatement-response-DbUser"></a>
The database user name.   
Type: String

 ** [Duration](#API_DescribeStatement_ResponseSyntax) **   <a name="redshiftdata-DescribeStatement-response-Duration"></a>
The amount of time in nanoseconds that the statement ran.   
Type: Long

 ** [Error](#API_DescribeStatement_ResponseSyntax) **   <a name="redshiftdata-DescribeStatement-response-Error"></a>
The error message from the cluster if the SQL statement encountered an error while running.   
Type: String

 ** [HasResultSet](#API_DescribeStatement_ResponseSyntax) **   <a name="redshiftdata-DescribeStatement-response-HasResultSet"></a>
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.  
Type: Boolean

 ** [QueryParameters](#API_DescribeStatement_ResponseSyntax) **   <a name="redshiftdata-DescribeStatement-response-QueryParameters"></a>
The parameters for the SQL statement.  
Type: Array of [SqlParameter](API_SqlParameter.md) objects  
Array Members: Minimum number of 1 item.

 ** [QueryString](#API_DescribeStatement_ResponseSyntax) **   <a name="redshiftdata-DescribeStatement-response-QueryString"></a>
The SQL statement text.   
Type: String

 ** [RedshiftPid](#API_DescribeStatement_ResponseSyntax) **   <a name="redshiftdata-DescribeStatement-response-RedshiftPid"></a>
The process identifier from Amazon Redshift.   
Type: Long

 ** [RedshiftQueryId](#API_DescribeStatement_ResponseSyntax) **   <a name="redshiftdata-DescribeStatement-response-RedshiftQueryId"></a>
The identifier of the query generated by Amazon Redshift. These identifiers are also available in the `query` column of the `STL_QUERY` system view.   
Type: Long

 ** [ResultFormat](#API_DescribeStatement_ResponseSyntax) **   <a name="redshiftdata-DescribeStatement-response-ResultFormat"></a>
The data format of the result of the SQL statement.  
Type: String  
Valid Values: `JSON | CSV` 

 ** [ResultRows](#API_DescribeStatement_ResponseSyntax) **   <a name="redshiftdata-DescribeStatement-response-ResultRows"></a>
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.  
Type: Long

 ** [ResultSize](#API_DescribeStatement_ResponseSyntax) **   <a name="redshiftdata-DescribeStatement-response-ResultSize"></a>
The size in bytes of the returned results. A `-1` indicates the value is null.  
Type: Long

 ** [SecretArn](#API_DescribeStatement_ResponseSyntax) **   <a name="redshiftdata-DescribeStatement-response-SecretArn"></a>
The name or Amazon Resource Name (ARN) of the secret that enables access to the database.   
Type: String

 ** [SessionId](#API_DescribeStatement_ResponseSyntax) **   <a name="redshiftdata-DescribeStatement-response-SessionId"></a>
The session identifier of the query.  
Type: String

 ** [Status](#API_DescribeStatement_ResponseSyntax) **   <a name="redshiftdata-DescribeStatement-response-Status"></a>
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. 
Type: String  
Valid Values: `SUBMITTED | PICKED | STARTED | FINISHED | ABORTED | FAILED | ALL` 

 ** [SubStatements](#API_DescribeStatement_ResponseSyntax) **   <a name="redshiftdata-DescribeStatement-response-SubStatements"></a>
The SQL statements from a multiple statement run.  
Type: Array of [SubStatementData](API_SubStatementData.md) objects

 ** [UpdatedAt](#API_DescribeStatement_ResponseSyntax) **   <a name="redshiftdata-DescribeStatement-response-UpdatedAt"></a>
The date and time (UTC) that the metadata for the SQL statement was last updated. An example is the time the status last changed.   
Type: Timestamp

 ** [WorkgroupName](#API_DescribeStatement_ResponseSyntax) **   <a name="redshiftdata-DescribeStatement-response-WorkgroupName"></a>
The serverless workgroup name or Amazon Resource Name (ARN).  
Type: String  
Length Constraints: Minimum length of 3. Maximum length of 128.  
Pattern: `(([a-z0-9-]+)|(arn:(aws(-[a-z]+)*):redshift-serverless:[a-z]{2}(-gov|(-iso[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}))` 

## Errors
<a name="API_DescribeStatement_Errors"></a>

For information about the errors that are common to all actions, see [Common Error Types](CommonErrors.md).

 ** InternalServerException **   
The Amazon Redshift Data API operation failed due to invalid input.     
 ** Message **   
The exception message.
HTTP Status Code: 500

 ** ResourceNotFoundException **   
The Amazon Redshift Data API operation failed due to a missing resource.     
 ** Message **   
The exception message.  
 ** ResourceId **   
Resource identifier associated with the exception.
HTTP Status Code: 400

 ** ValidationException **   
The Amazon Redshift Data API operation failed due to invalid input.     
 ** Message **   
The exception message.
HTTP Status Code: 400

## See Also
<a name="API_DescribeStatement_SeeAlso"></a>

For more information about using this API in one of the language-specific AWS SDKs, see the following:
+  [AWS Command Line Interface V2](https://docs.aws.amazon.com/goto/cli2/redshift-data-2019-12-20/DescribeStatement) 
+  [AWS SDK for .NET V4](https://docs.aws.amazon.com/goto/DotNetSDKV4/redshift-data-2019-12-20/DescribeStatement) 
+  [AWS SDK for C\$1\$1](https://docs.aws.amazon.com/goto/SdkForCpp/redshift-data-2019-12-20/DescribeStatement) 
+  [AWS SDK for Go v2](https://docs.aws.amazon.com/goto/SdkForGoV2/redshift-data-2019-12-20/DescribeStatement) 
+  [AWS SDK for Java V2](https://docs.aws.amazon.com/goto/SdkForJavaV2/redshift-data-2019-12-20/DescribeStatement) 
+  [AWS SDK for JavaScript V3](https://docs.aws.amazon.com/goto/SdkForJavaScriptV3/redshift-data-2019-12-20/DescribeStatement) 
+  [AWS SDK for Kotlin](https://docs.aws.amazon.com/goto/SdkForKotlin/redshift-data-2019-12-20/DescribeStatement) 
+  [AWS SDK for PHP V3](https://docs.aws.amazon.com/goto/SdkForPHPV3/redshift-data-2019-12-20/DescribeStatement) 
+  [AWS SDK for Python](https://docs.aws.amazon.com/goto/boto3/redshift-data-2019-12-20/DescribeStatement) 
+  [AWS SDK for Ruby V3](https://docs.aws.amazon.com/goto/SdkForRubyV3/redshift-data-2019-12-20/DescribeStatement) 