Skip to content

Commit 5943dd5

Browse files
author
awstools
committed
feat(client-redshift-data): Adding a new API GetStatementResultV2 that supports CSV formatted results from ExecuteStatement and BatchExecuteStatement calls.
1 parent 2ccb11c commit 5943dd5

15 files changed

+542
-8
lines changed

clients/client-redshift-data/README.md

+9-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ can run SQL statements, which are committed if the statement succeeds. </p>
1414

1515
## Installing
1616

17-
To install the this package, simply type add or install @aws-sdk/client-redshift-data
17+
To install this package, simply type add or install @aws-sdk/client-redshift-data
1818
using your favorite package manager:
1919

2020
- `npm install @aws-sdk/client-redshift-data`
@@ -254,6 +254,14 @@ GetStatementResult
254254

255255
[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/)
256256

257+
</details>
258+
<details>
259+
<summary>
260+
GetStatementResultV2
261+
</summary>
262+
263+
[Command API Reference](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/client/redshift-data/command/GetStatementResultV2Command/) / [Input](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/Package/-aws-sdk-client-redshift-data/Interface/GetStatementResultV2CommandInput/) / [Output](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/Package/-aws-sdk-client-redshift-data/Interface/GetStatementResultV2CommandOutput/)
264+
257265
</details>
258266
<details>
259267
<summary>

clients/client-redshift-data/src/RedshiftData.ts

+23
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,11 @@ import {
3232
GetStatementResultCommandInput,
3333
GetStatementResultCommandOutput,
3434
} from "./commands/GetStatementResultCommand";
35+
import {
36+
GetStatementResultV2Command,
37+
GetStatementResultV2CommandInput,
38+
GetStatementResultV2CommandOutput,
39+
} from "./commands/GetStatementResultV2Command";
3540
import {
3641
ListDatabasesCommand,
3742
ListDatabasesCommandInput,
@@ -53,6 +58,7 @@ const commands = {
5358
DescribeTableCommand,
5459
ExecuteStatementCommand,
5560
GetStatementResultCommand,
61+
GetStatementResultV2Command,
5662
ListDatabasesCommand,
5763
ListSchemasCommand,
5864
ListStatementsCommand,
@@ -153,6 +159,23 @@ export interface RedshiftData {
153159
cb: (err: any, data?: GetStatementResultCommandOutput) => void
154160
): void;
155161

162+
/**
163+
* @see {@link GetStatementResultV2Command}
164+
*/
165+
getStatementResultV2(
166+
args: GetStatementResultV2CommandInput,
167+
options?: __HttpHandlerOptions
168+
): Promise<GetStatementResultV2CommandOutput>;
169+
getStatementResultV2(
170+
args: GetStatementResultV2CommandInput,
171+
cb: (err: any, data?: GetStatementResultV2CommandOutput) => void
172+
): void;
173+
getStatementResultV2(
174+
args: GetStatementResultV2CommandInput,
175+
options: __HttpHandlerOptions,
176+
cb: (err: any, data?: GetStatementResultV2CommandOutput) => void
177+
): void;
178+
156179
/**
157180
* @see {@link ListDatabasesCommand}
158181
*/

clients/client-redshift-data/src/RedshiftDataClient.ts

+6
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,10 @@ import { DescribeStatementCommandInput, DescribeStatementCommandOutput } from ".
6262
import { DescribeTableCommandInput, DescribeTableCommandOutput } from "./commands/DescribeTableCommand";
6363
import { ExecuteStatementCommandInput, ExecuteStatementCommandOutput } from "./commands/ExecuteStatementCommand";
6464
import { GetStatementResultCommandInput, GetStatementResultCommandOutput } from "./commands/GetStatementResultCommand";
65+
import {
66+
GetStatementResultV2CommandInput,
67+
GetStatementResultV2CommandOutput,
68+
} from "./commands/GetStatementResultV2Command";
6569
import { ListDatabasesCommandInput, ListDatabasesCommandOutput } from "./commands/ListDatabasesCommand";
6670
import { ListSchemasCommandInput, ListSchemasCommandOutput } from "./commands/ListSchemasCommand";
6771
import { ListStatementsCommandInput, ListStatementsCommandOutput } from "./commands/ListStatementsCommand";
@@ -87,6 +91,7 @@ export type ServiceInputTypes =
8791
| DescribeTableCommandInput
8892
| ExecuteStatementCommandInput
8993
| GetStatementResultCommandInput
94+
| GetStatementResultV2CommandInput
9095
| ListDatabasesCommandInput
9196
| ListSchemasCommandInput
9297
| ListStatementsCommandInput
@@ -102,6 +107,7 @@ export type ServiceOutputTypes =
102107
| DescribeTableCommandOutput
103108
| ExecuteStatementCommandOutput
104109
| GetStatementResultCommandOutput
110+
| GetStatementResultV2CommandOutput
105111
| ListDatabasesCommandOutput
106112
| ListSchemasCommandOutput
107113
| ListStatementsCommandOutput

clients/client-redshift-data/src/commands/BatchExecuteStatementCommand.ts

+1
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ export interface BatchExecuteStatementCommandOutput extends BatchExecuteStatemen
8585
* ClientToken: "STRING_VALUE",
8686
* SessionKeepAliveSeconds: Number("int"),
8787
* SessionId: "STRING_VALUE",
88+
* ResultFormat: "STRING_VALUE",
8889
* };
8990
* const command = new BatchExecuteStatementCommand(input);
9091
* const response = await client.send(command);

clients/client-redshift-data/src/commands/DescribeStatementCommand.ts

+1
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ export interface DescribeStatementCommandOutput extends DescribeStatementRespons
8585
* // ],
8686
* // WorkgroupName: "STRING_VALUE",
8787
* // SessionId: "STRING_VALUE",
88+
* // ResultFormat: "STRING_VALUE",
8889
* // };
8990
*
9091
* ```

clients/client-redshift-data/src/commands/ExecuteStatementCommand.ts

+1
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ export interface ExecuteStatementCommandOutput extends ExecuteStatementOutput, _
8989
* ClientToken: "STRING_VALUE",
9090
* SessionKeepAliveSeconds: Number("int"),
9191
* SessionId: "STRING_VALUE",
92+
* ResultFormat: "STRING_VALUE",
9293
* };
9394
* const command = new ExecuteStatementCommand(input);
9495
* const response = await client.send(command);

clients/client-redshift-data/src/commands/GetStatementResultCommand.ts

+4-2
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,10 @@ export interface GetStatementResultCommandInput extends GetStatementResultReques
2828
export interface GetStatementResultCommandOutput extends GetStatementResultResponse, __MetadataBearer {}
2929

3030
/**
31-
* <p>Fetches the temporarily cached result of an SQL statement.
32-
* A token is returned to page through the statement results. </p>
31+
* <p>Fetches the temporarily cached result of an SQL statement in JSON format.
32+
* The <code>ExecuteStatement</code> or <code>BatchExecuteStatement</code> operation that ran the SQL statement must have specified <code>ResultFormat</code> as <code>JSON</code>
33+
* , or let the format default to JSON.
34+
* A token is returned to page through the statement results.</p>
3335
* <p>For more information about the Amazon Redshift Data API and CLI usage examples, see
3436
* <a href="https://docs.aws.amazon.com/redshift/latest/mgmt/data-api.html">Using the Amazon Redshift Data API</a> in the
3537
* <i>Amazon Redshift Management Guide</i>. </p>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,131 @@
1+
// smithy-typescript generated code
2+
import { getEndpointPlugin } from "@smithy/middleware-endpoint";
3+
import { getSerdePlugin } from "@smithy/middleware-serde";
4+
import { Command as $Command } from "@smithy/smithy-client";
5+
import { MetadataBearer as __MetadataBearer } from "@smithy/types";
6+
7+
import { commonParams } from "../endpoint/EndpointParameters";
8+
import { GetStatementResultV2Request, GetStatementResultV2Response } from "../models/models_0";
9+
import { de_GetStatementResultV2Command, se_GetStatementResultV2Command } from "../protocols/Aws_json1_1";
10+
import { RedshiftDataClientResolvedConfig, ServiceInputTypes, ServiceOutputTypes } from "../RedshiftDataClient";
11+
12+
/**
13+
* @public
14+
*/
15+
export type { __MetadataBearer };
16+
export { $Command };
17+
/**
18+
* @public
19+
*
20+
* The input for {@link GetStatementResultV2Command}.
21+
*/
22+
export interface GetStatementResultV2CommandInput extends GetStatementResultV2Request {}
23+
/**
24+
* @public
25+
*
26+
* The output of {@link GetStatementResultV2Command}.
27+
*/
28+
export interface GetStatementResultV2CommandOutput extends GetStatementResultV2Response, __MetadataBearer {}
29+
30+
/**
31+
* <p>Fetches the temporarily cached result of an SQL statement in CSV format.
32+
* The <code>ExecuteStatement</code> or <code>BatchExecuteStatement</code> operation that ran the SQL statement must have specified <code>ResultFormat</code> as <code>CSV</code>.
33+
* A token is returned to page through the statement results.</p>
34+
* <p>For more information about the Amazon Redshift Data API and CLI usage examples, see
35+
* <a href="https://docs.aws.amazon.com/redshift/latest/mgmt/data-api.html">Using the Amazon Redshift Data API</a> in the
36+
* <i>Amazon Redshift Management Guide</i>. </p>
37+
* @example
38+
* Use a bare-bones client and the command you need to make an API call.
39+
* ```javascript
40+
* import { RedshiftDataClient, GetStatementResultV2Command } from "@aws-sdk/client-redshift-data"; // ES Modules import
41+
* // const { RedshiftDataClient, GetStatementResultV2Command } = require("@aws-sdk/client-redshift-data"); // CommonJS import
42+
* const client = new RedshiftDataClient(config);
43+
* const input = { // GetStatementResultV2Request
44+
* Id: "STRING_VALUE", // required
45+
* NextToken: "STRING_VALUE",
46+
* };
47+
* const command = new GetStatementResultV2Command(input);
48+
* const response = await client.send(command);
49+
* // { // GetStatementResultV2Response
50+
* // Records: [ // FormattedSqlRecords // required
51+
* // { // QueryRecords Union: only one key present
52+
* // CSVRecords: "STRING_VALUE",
53+
* // },
54+
* // ],
55+
* // ColumnMetadata: [ // ColumnMetadataList
56+
* // { // ColumnMetadata
57+
* // isCaseSensitive: true || false,
58+
* // isCurrency: true || false,
59+
* // isSigned: true || false,
60+
* // label: "STRING_VALUE",
61+
* // name: "STRING_VALUE",
62+
* // nullable: Number("int"),
63+
* // precision: Number("int"),
64+
* // scale: Number("int"),
65+
* // schemaName: "STRING_VALUE",
66+
* // tableName: "STRING_VALUE",
67+
* // typeName: "STRING_VALUE",
68+
* // length: Number("int"),
69+
* // columnDefault: "STRING_VALUE",
70+
* // },
71+
* // ],
72+
* // TotalNumRows: Number("long"),
73+
* // ResultFormat: "STRING_VALUE",
74+
* // NextToken: "STRING_VALUE",
75+
* // };
76+
*
77+
* ```
78+
*
79+
* @param GetStatementResultV2CommandInput - {@link GetStatementResultV2CommandInput}
80+
* @returns {@link GetStatementResultV2CommandOutput}
81+
* @see {@link GetStatementResultV2CommandInput} for command's `input` shape.
82+
* @see {@link GetStatementResultV2CommandOutput} for command's `response` shape.
83+
* @see {@link RedshiftDataClientResolvedConfig | config} for RedshiftDataClient's `config` shape.
84+
*
85+
* @throws {@link InternalServerException} (server fault)
86+
* <p>The Amazon Redshift Data API operation failed due to invalid input. </p>
87+
*
88+
* @throws {@link ResourceNotFoundException} (client fault)
89+
* <p>The Amazon Redshift Data API operation failed due to a missing resource. </p>
90+
*
91+
* @throws {@link ValidationException} (client fault)
92+
* <p>The Amazon Redshift Data API operation failed due to invalid input. </p>
93+
*
94+
* @throws {@link RedshiftDataServiceException}
95+
* <p>Base exception class for all service exceptions from RedshiftData service.</p>
96+
*
97+
* @public
98+
*/
99+
export class GetStatementResultV2Command extends $Command
100+
.classBuilder<
101+
GetStatementResultV2CommandInput,
102+
GetStatementResultV2CommandOutput,
103+
RedshiftDataClientResolvedConfig,
104+
ServiceInputTypes,
105+
ServiceOutputTypes
106+
>()
107+
.ep(commonParams)
108+
.m(function (this: any, Command: any, cs: any, config: RedshiftDataClientResolvedConfig, o: any) {
109+
return [
110+
getSerdePlugin(config, this.serialize, this.deserialize),
111+
getEndpointPlugin(config, Command.getEndpointParameterInstructions()),
112+
];
113+
})
114+
.s("RedshiftData", "GetStatementResultV2", {})
115+
.n("RedshiftDataClient", "GetStatementResultV2Command")
116+
.f(void 0, void 0)
117+
.ser(se_GetStatementResultV2Command)
118+
.de(de_GetStatementResultV2Command)
119+
.build() {
120+
/** @internal type navigation helper, not in runtime. */
121+
protected declare static __types: {
122+
api: {
123+
input: GetStatementResultV2Request;
124+
output: GetStatementResultV2Response;
125+
};
126+
sdk: {
127+
input: GetStatementResultV2CommandInput;
128+
output: GetStatementResultV2CommandOutput;
129+
};
130+
};
131+
}

clients/client-redshift-data/src/commands/ListStatementsCommand.ts

+1
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ export interface ListStatementsCommandOutput extends ListStatementsResponse, __M
6969
* // ],
7070
* // IsBatchStatement: true || false,
7171
* // SessionId: "STRING_VALUE",
72+
* // ResultFormat: "STRING_VALUE",
7273
* // },
7374
* // ],
7475
* // NextToken: "STRING_VALUE",

clients/client-redshift-data/src/commands/index.ts

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ export * from "./DescribeStatementCommand";
55
export * from "./DescribeTableCommand";
66
export * from "./ExecuteStatementCommand";
77
export * from "./GetStatementResultCommand";
8+
export * from "./GetStatementResultV2Command";
89
export * from "./ListDatabasesCommand";
910
export * from "./ListSchemasCommand";
1011
export * from "./ListStatementsCommand";

0 commit comments

Comments
 (0)