diff --git a/clients/client-redshift-data/README.md b/clients/client-redshift-data/README.md index 1f2743b77458..a76ef157cebb 100644 --- a/clients/client-redshift-data/README.md +++ b/clients/client-redshift-data/README.md @@ -14,7 +14,7 @@ can run SQL statements, which are committed if the statement succeeds.
## Installing -To install the this package, simply type add or install @aws-sdk/client-redshift-data +To install this package, simply type add or install @aws-sdk/client-redshift-data using your favorite package manager: - `npm install @aws-sdk/client-redshift-data` @@ -254,6 +254,14 @@ GetStatementResult [Command API Reference](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/client/redshift-data/command/GetStatementResultCommand/) / [Input](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/Package/-aws-sdk-client-redshift-data/Interface/GetStatementResultCommandInput/) / [Output](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/Package/-aws-sdk-client-redshift-data/Interface/GetStatementResultCommandOutput/) + +Fetches the temporarily cached result of an SQL statement. - * A token is returned to page through the statement results.
+ *Fetches the temporarily cached result of an SQL statement in JSON format.
+ * The ExecuteStatement
or BatchExecuteStatement
operation that ran the SQL statement must have specified ResultFormat
as JSON
+ * , or let the format default to JSON.
+ * A token is returned to page through the statement results.
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.
diff --git a/clients/client-redshift-data/src/commands/GetStatementResultV2Command.ts b/clients/client-redshift-data/src/commands/GetStatementResultV2Command.ts new file mode 100644 index 000000000000..efc4d949f282 --- /dev/null +++ b/clients/client-redshift-data/src/commands/GetStatementResultV2Command.ts @@ -0,0 +1,131 @@ +// smithy-typescript generated code +import { getEndpointPlugin } from "@smithy/middleware-endpoint"; +import { getSerdePlugin } from "@smithy/middleware-serde"; +import { Command as $Command } from "@smithy/smithy-client"; +import { MetadataBearer as __MetadataBearer } from "@smithy/types"; + +import { commonParams } from "../endpoint/EndpointParameters"; +import { GetStatementResultV2Request, GetStatementResultV2Response } from "../models/models_0"; +import { de_GetStatementResultV2Command, se_GetStatementResultV2Command } from "../protocols/Aws_json1_1"; +import { RedshiftDataClientResolvedConfig, ServiceInputTypes, ServiceOutputTypes } from "../RedshiftDataClient"; + +/** + * @public + */ +export type { __MetadataBearer }; +export { $Command }; +/** + * @public + * + * The input for {@link GetStatementResultV2Command}. + */ +export interface GetStatementResultV2CommandInput extends GetStatementResultV2Request {} +/** + * @public + * + * The output of {@link GetStatementResultV2Command}. + */ +export interface GetStatementResultV2CommandOutput extends GetStatementResultV2Response, __MetadataBearer {} + +/** + *Fetches the temporarily cached result of an SQL statement in CSV format.
+ * The ExecuteStatement
or BatchExecuteStatement
operation that ran the SQL statement must have specified ResultFormat
as CSV
.
+ * A token is returned to page through the statement results.
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.
+ * @example + * Use a bare-bones client and the command you need to make an API call. + * ```javascript + * import { RedshiftDataClient, GetStatementResultV2Command } from "@aws-sdk/client-redshift-data"; // ES Modules import + * // const { RedshiftDataClient, GetStatementResultV2Command } = require("@aws-sdk/client-redshift-data"); // CommonJS import + * const client = new RedshiftDataClient(config); + * const input = { // GetStatementResultV2Request + * Id: "STRING_VALUE", // required + * NextToken: "STRING_VALUE", + * }; + * const command = new GetStatementResultV2Command(input); + * const response = await client.send(command); + * // { // GetStatementResultV2Response + * // Records: [ // FormattedSqlRecords // required + * // { // QueryRecords Union: only one key present + * // CSVRecords: "STRING_VALUE", + * // }, + * // ], + * // ColumnMetadata: [ // ColumnMetadataList + * // { // ColumnMetadata + * // isCaseSensitive: true || false, + * // isCurrency: true || false, + * // isSigned: true || false, + * // label: "STRING_VALUE", + * // name: "STRING_VALUE", + * // nullable: Number("int"), + * // precision: Number("int"), + * // scale: Number("int"), + * // schemaName: "STRING_VALUE", + * // tableName: "STRING_VALUE", + * // typeName: "STRING_VALUE", + * // length: Number("int"), + * // columnDefault: "STRING_VALUE", + * // }, + * // ], + * // TotalNumRows: Number("long"), + * // ResultFormat: "STRING_VALUE", + * // NextToken: "STRING_VALUE", + * // }; + * + * ``` + * + * @param GetStatementResultV2CommandInput - {@link GetStatementResultV2CommandInput} + * @returns {@link GetStatementResultV2CommandOutput} + * @see {@link GetStatementResultV2CommandInput} for command's `input` shape. + * @see {@link GetStatementResultV2CommandOutput} for command's `response` shape. + * @see {@link RedshiftDataClientResolvedConfig | config} for RedshiftDataClient's `config` shape. + * + * @throws {@link InternalServerException} (server fault) + *The Amazon Redshift Data API operation failed due to invalid input.
+ * + * @throws {@link ResourceNotFoundException} (client fault) + *The Amazon Redshift Data API operation failed due to a missing resource.
+ * + * @throws {@link ValidationException} (client fault) + *The Amazon Redshift Data API operation failed due to invalid input.
+ * + * @throws {@link RedshiftDataServiceException} + *Base exception class for all service exceptions from RedshiftData service.
+ * + * @public + */ +export class GetStatementResultV2Command extends $Command + .classBuilder< + GetStatementResultV2CommandInput, + GetStatementResultV2CommandOutput, + RedshiftDataClientResolvedConfig, + ServiceInputTypes, + ServiceOutputTypes + >() + .ep(commonParams) + .m(function (this: any, Command: any, cs: any, config: RedshiftDataClientResolvedConfig, o: any) { + return [ + getSerdePlugin(config, this.serialize, this.deserialize), + getEndpointPlugin(config, Command.getEndpointParameterInstructions()), + ]; + }) + .s("RedshiftData", "GetStatementResultV2", {}) + .n("RedshiftDataClient", "GetStatementResultV2Command") + .f(void 0, void 0) + .ser(se_GetStatementResultV2Command) + .de(de_GetStatementResultV2Command) + .build() { + /** @internal type navigation helper, not in runtime. */ + protected declare static __types: { + api: { + input: GetStatementResultV2Request; + output: GetStatementResultV2Response; + }; + sdk: { + input: GetStatementResultV2CommandInput; + output: GetStatementResultV2CommandOutput; + }; + }; +} diff --git a/clients/client-redshift-data/src/commands/ListStatementsCommand.ts b/clients/client-redshift-data/src/commands/ListStatementsCommand.ts index 2598d5610b96..6adca25f9eb1 100644 --- a/clients/client-redshift-data/src/commands/ListStatementsCommand.ts +++ b/clients/client-redshift-data/src/commands/ListStatementsCommand.ts @@ -69,6 +69,7 @@ export interface ListStatementsCommandOutput extends ListStatementsResponse, __M * // ], * // IsBatchStatement: true || false, * // SessionId: "STRING_VALUE", + * // ResultFormat: "STRING_VALUE", * // }, * // ], * // NextToken: "STRING_VALUE", diff --git a/clients/client-redshift-data/src/commands/index.ts b/clients/client-redshift-data/src/commands/index.ts index 32522b0e5009..7847228d442d 100644 --- a/clients/client-redshift-data/src/commands/index.ts +++ b/clients/client-redshift-data/src/commands/index.ts @@ -5,6 +5,7 @@ export * from "./DescribeStatementCommand"; export * from "./DescribeTableCommand"; export * from "./ExecuteStatementCommand"; export * from "./GetStatementResultCommand"; +export * from "./GetStatementResultV2Command"; export * from "./ListDatabasesCommand"; export * from "./ListSchemasCommand"; export * from "./ListStatementsCommand"; diff --git a/clients/client-redshift-data/src/models/models_0.ts b/clients/client-redshift-data/src/models/models_0.ts index 1aaa833923b9..15960714df5d 100644 --- a/clients/client-redshift-data/src/models/models_0.ts +++ b/clients/client-redshift-data/src/models/models_0.ts @@ -75,6 +75,20 @@ export class BatchExecuteStatementException extends __BaseException { } } +/** + * @public + * @enum + */ +export const ResultFormatString = { + CSV: "CSV", + JSON: "JSON", +} as const; + +/** + * @public + */ +export type ResultFormatString = (typeof ResultFormatString)[keyof typeof ResultFormatString]; + /** * @public */ @@ -148,6 +162,12 @@ export interface BatchExecuteStatementInput { * @public */ SessionId?: string; + + /** + *The data format of the result of the SQL statement. If no format is specified, the default is JSON.
+ * @public + */ + ResultFormat?: ResultFormatString; } /** @@ -725,6 +745,12 @@ export interface DescribeStatementResponse { * @public */ SessionId?: string; + + /** + *The data format of the result of the SQL statement.
+ * @public + */ + ResultFormat?: ResultFormatString; } /** @@ -948,6 +974,12 @@ export interface ExecuteStatementInput { * @public */ SessionId?: string; + + /** + *The data format of the result of the SQL statement. If no format is specified, the default is JSON.
+ * @public + */ + ResultFormat?: ResultFormatString; } /** @@ -1144,6 +1176,44 @@ export namespace Field { }; } +/** + *The results of the SQL statement.
+ * @public + */ +export type QueryRecords = QueryRecords.CSVRecordsMember | QueryRecords.$UnknownMember; + +/** + * @public + */ +export namespace QueryRecords { + /** + *The results of the SQL statement in CSV format.
+ * @public + */ + export interface CSVRecordsMember { + CSVRecords: string; + $unknown?: never; + } + + /** + * @public + */ + export interface $UnknownMember { + CSVRecords?: never; + $unknown: [string, any]; + } + + export interface VisitorThe results of the SQL statement.
+ *The results of the SQL statement in JSON format.
* @public */ Records: Field[][] | undefined; @@ -1194,6 +1264,62 @@ export interface GetStatementResultResponse { NextToken?: string; } +/** + * @public + */ +export interface GetStatementResultV2Request { + /** + *The identifier of the SQL statement whose results are to be fetched. This value is a universally unique identifier (UUID) generated by Amazon Redshift Data API.
+ * A suffix indicates then 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
, ExecuteStatment
, and ListStatements
.
A value that indicates the starting point for the next set of response records in a subsequent request. If a value is returned in a response, you can retrieve the next set of records by providing this returned NextToken value in the next NextToken parameter and retrying the command. If the NextToken field is empty, all response records have been retrieved for the request.
+ * @public + */ + NextToken?: string; +} + +/** + * @public + */ +export interface GetStatementResultV2Response { + /** + *The results of the SQL statement in CSV format.
+ * @public + */ + Records: QueryRecords[] | undefined; + + /** + *The properties (metadata) of a column.
+ * @public + */ + ColumnMetadata?: ColumnMetadata[]; + + /** + *The total number of rows in the result set returned from a query.
+ * You can use this number to estimate the number of calls to the GetStatementResultV2
operation needed to page through the results.
The data format of the result of the SQL statement.
+ * @public + */ + ResultFormat?: ResultFormatString; + + /** + *A value that indicates the starting point for the next set of response records in a subsequent request. If a value is returned in a response, you can retrieve the next set of records by providing this returned NextToken value in the next NextToken parameter and retrying the command. If the NextToken field is empty, all response records have been retrieved for the request.
+ * @public + */ + NextToken?: string; +} + /** * @public */ @@ -1474,6 +1600,12 @@ export interface StatementData { * @public */ SessionId?: string; + + /** + *The data format of the result of the SQL statement.
+ * @public + */ + ResultFormat?: ResultFormatString; } /** diff --git a/clients/client-redshift-data/src/pagination/GetStatementResultV2Paginator.ts b/clients/client-redshift-data/src/pagination/GetStatementResultV2Paginator.ts new file mode 100644 index 000000000000..b9359ab79fd3 --- /dev/null +++ b/clients/client-redshift-data/src/pagination/GetStatementResultV2Paginator.ts @@ -0,0 +1,24 @@ +// smithy-typescript generated code +import { createPaginator } from "@smithy/core"; +import { Paginator } from "@smithy/types"; + +import { + GetStatementResultV2Command, + GetStatementResultV2CommandInput, + GetStatementResultV2CommandOutput, +} from "../commands/GetStatementResultV2Command"; +import { RedshiftDataClient } from "../RedshiftDataClient"; +import { RedshiftDataPaginationConfiguration } from "./Interfaces"; + +/** + * @public + */ +export const paginateGetStatementResultV2: ( + config: RedshiftDataPaginationConfiguration, + input: GetStatementResultV2CommandInput, + ...rest: any[] +) => PaginatorThe session identifier of the query.
" } + }, + "ResultFormat": { + "target": "com.amazonaws.redshiftdata#ResultFormatString", + "traits": { + "smithy.api#documentation": "The data format of the result of the SQL statement. If no format is specified, the default is JSON.
" + } } }, "traits": { @@ -299,8 +305,7 @@ "smithy.api#length": { "min": 1, "max": 63 - }, - "smithy.api#pattern": "^[a-z]([a-z0-9]|-[a-z0-9])*$" + } } }, "com.amazonaws.redshiftdata#ColumnList": { @@ -603,6 +608,12 @@ "traits": { "smithy.api#documentation": "The session identifier of the query.
" } + }, + "ResultFormat": { + "target": "com.amazonaws.redshiftdata#ResultFormatString", + "traits": { + "smithy.api#documentation": "The data format of the result of the SQL statement.
" + } } }, "traits": { @@ -867,6 +878,12 @@ "traits": { "smithy.api#documentation": "The session identifier of the query.
" } + }, + "ResultFormat": { + "target": "com.amazonaws.redshiftdata#ResultFormatString", + "traits": { + "smithy.api#documentation": "The data format of the result of the SQL statement. If no format is specified, the default is JSON.
" + } } }, "traits": { @@ -985,6 +1002,12 @@ "target": "com.amazonaws.redshiftdata#Field" } }, + "com.amazonaws.redshiftdata#FormattedSqlRecords": { + "type": "list", + "member": { + "target": "com.amazonaws.redshiftdata#QueryRecords" + } + }, "com.amazonaws.redshiftdata#GetStatementResult": { "type": "operation", "input": { @@ -1005,7 +1028,7 @@ } ], "traits": { - "smithy.api#documentation": "Fetches the temporarily cached result of an SQL statement. \n A token is returned to page through the statement results.
\nFor more information about the Amazon Redshift Data API and CLI usage examples, see \n Using the Amazon Redshift Data API in the \n Amazon Redshift Management Guide.
", + "smithy.api#documentation": "Fetches the temporarily cached result of an SQL statement in JSON format. \n The ExecuteStatement
or BatchExecuteStatement
operation that ran the SQL statement must have specified ResultFormat
as JSON
\n , or let the format default to JSON.\n A token is returned to page through the statement results.
For more information about the Amazon Redshift Data API and CLI usage examples, see \n Using the Amazon Redshift Data API in the \n Amazon Redshift Management Guide.
", "smithy.api#paginated": { "inputToken": "NextToken", "outputToken": "NextToken", @@ -1041,7 +1064,7 @@ "Records": { "target": "com.amazonaws.redshiftdata#SqlRecords", "traits": { - "smithy.api#documentation": "The results of the SQL statement.
", + "smithy.api#documentation": "The results of the SQL statement in JSON format.
", "smithy.api#required": {} } }, @@ -1069,6 +1092,96 @@ "smithy.api#output": {} } }, + "com.amazonaws.redshiftdata#GetStatementResultV2": { + "type": "operation", + "input": { + "target": "com.amazonaws.redshiftdata#GetStatementResultV2Request" + }, + "output": { + "target": "com.amazonaws.redshiftdata#GetStatementResultV2Response" + }, + "errors": [ + { + "target": "com.amazonaws.redshiftdata#InternalServerException" + }, + { + "target": "com.amazonaws.redshiftdata#ResourceNotFoundException" + }, + { + "target": "com.amazonaws.redshiftdata#ValidationException" + } + ], + "traits": { + "smithy.api#documentation": "Fetches the temporarily cached result of an SQL statement in CSV format. \n The ExecuteStatement
or BatchExecuteStatement
operation that ran the SQL statement must have specified ResultFormat
as CSV
.\n A token is returned to page through the statement results.
For more information about the Amazon Redshift Data API and CLI usage examples, see \n Using the Amazon Redshift Data API in the \n Amazon Redshift Management Guide.
", + "smithy.api#paginated": { + "inputToken": "NextToken", + "outputToken": "NextToken", + "items": "Records" + }, + "smithy.api#readonly": {} + } + }, + "com.amazonaws.redshiftdata#GetStatementResultV2Request": { + "type": "structure", + "members": { + "Id": { + "target": "com.amazonaws.redshiftdata#UUID", + "traits": { + "smithy.api#documentation": "The identifier of the SQL statement whose results are to be fetched. This value is a universally unique identifier (UUID) generated by Amazon Redshift Data API. \n A suffix indicates then number of the SQL statement.\n For example, d9b6c0c9-0747-4bf4-b142-e8883122f766:2
has a suffix of :2
that indicates the second SQL statement of a batch query.\n This identifier is returned by BatchExecuteStatment
, ExecuteStatment
, and ListStatements
.
A value that indicates the starting point for the next set of response records in a subsequent request. If a value is returned in a response, you can retrieve the next set of records by providing this returned NextToken value in the next NextToken parameter and retrying the command. If the NextToken field is empty, all response records have been retrieved for the request.
" + } + } + }, + "traits": { + "smithy.api#input": {} + } + }, + "com.amazonaws.redshiftdata#GetStatementResultV2Response": { + "type": "structure", + "members": { + "Records": { + "target": "com.amazonaws.redshiftdata#FormattedSqlRecords", + "traits": { + "smithy.api#documentation": "The results of the SQL statement in CSV format.
", + "smithy.api#required": {} + } + }, + "ColumnMetadata": { + "target": "com.amazonaws.redshiftdata#ColumnMetadataList", + "traits": { + "smithy.api#documentation": "The properties (metadata) of a column.
" + } + }, + "TotalNumRows": { + "target": "com.amazonaws.redshiftdata#Long", + "traits": { + "smithy.api#default": 0, + "smithy.api#documentation": "The total number of rows in the result set returned from a query. \n You can use this number to estimate the number of calls to the GetStatementResultV2
operation needed to page through the results.
The data format of the result of the SQL statement.
" + } + }, + "NextToken": { + "target": "com.amazonaws.redshiftdata#String", + "traits": { + "smithy.api#documentation": "A value that indicates the starting point for the next set of response records in a subsequent request. If a value is returned in a response, you can retrieve the next set of records by providing this returned NextToken value in the next NextToken parameter and retrying the command. If the NextToken field is empty, all response records have been retrieved for the request.
" + } + } + }, + "traits": { + "smithy.api#output": {} + } + }, "com.amazonaws.redshiftdata#Integer": { "type": "integer", "traits": { @@ -1564,6 +1677,20 @@ } } }, + "com.amazonaws.redshiftdata#QueryRecords": { + "type": "union", + "members": { + "CSVRecords": { + "target": "com.amazonaws.redshiftdata#String", + "traits": { + "smithy.api#documentation": "The results of the SQL statement in CSV format.
" + } + } + }, + "traits": { + "smithy.api#documentation": "The results of the SQL statement.
" + } + }, "com.amazonaws.redshiftdata#QueryTimeoutException": { "type": "structure", "members": { @@ -1599,6 +1726,9 @@ { "target": "com.amazonaws.redshiftdata#GetStatementResult" }, + { + "target": "com.amazonaws.redshiftdata#GetStatementResultV2" + }, { "target": "com.amazonaws.redshiftdata#ListDatabases" }, @@ -2278,6 +2408,21 @@ "smithy.api#httpError": 404 } }, + "com.amazonaws.redshiftdata#ResultFormatString": { + "type": "string", + "traits": { + "smithy.api#enum": [ + { + "name": "JSON", + "value": "JSON" + }, + { + "name": "CSV", + "value": "CSV" + } + ] + } + }, "com.amazonaws.redshiftdata#SchemaList": { "type": "list", "member": { @@ -2416,6 +2561,12 @@ "traits": { "smithy.api#documentation": "The session identifier of the query.
" } + }, + "ResultFormat": { + "target": "com.amazonaws.redshiftdata#ResultFormatString", + "traits": { + "smithy.api#documentation": "The data format of the result of the SQL statement.
" + } } }, "traits": {