Skip to content

Commit

Permalink
feat(client-redshift-data): Adding a new API GetStatementResultV2 tha…
Browse files Browse the repository at this point in the history
…t supports CSV formatted results from ExecuteStatement and BatchExecuteStatement calls.
  • Loading branch information
awstools committed Oct 29, 2024
1 parent 2ccb11c commit 5943dd5
Show file tree
Hide file tree
Showing 15 changed files with 542 additions and 8 deletions.
10 changes: 9 additions & 1 deletion clients/client-redshift-data/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ can run SQL statements, which are committed if the statement succeeds. </p>

## 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`
Expand Down Expand Up @@ -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/)

</details>
<details>
<summary>
GetStatementResultV2
</summary>

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

</details>
<details>
<summary>
Expand Down
23 changes: 23 additions & 0 deletions clients/client-redshift-data/src/RedshiftData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,11 @@ import {
GetStatementResultCommandInput,
GetStatementResultCommandOutput,
} from "./commands/GetStatementResultCommand";
import {
GetStatementResultV2Command,
GetStatementResultV2CommandInput,
GetStatementResultV2CommandOutput,
} from "./commands/GetStatementResultV2Command";
import {
ListDatabasesCommand,
ListDatabasesCommandInput,
Expand All @@ -53,6 +58,7 @@ const commands = {
DescribeTableCommand,
ExecuteStatementCommand,
GetStatementResultCommand,
GetStatementResultV2Command,
ListDatabasesCommand,
ListSchemasCommand,
ListStatementsCommand,
Expand Down Expand Up @@ -153,6 +159,23 @@ export interface RedshiftData {
cb: (err: any, data?: GetStatementResultCommandOutput) => void
): void;

/**
* @see {@link GetStatementResultV2Command}
*/
getStatementResultV2(
args: GetStatementResultV2CommandInput,
options?: __HttpHandlerOptions
): Promise<GetStatementResultV2CommandOutput>;
getStatementResultV2(
args: GetStatementResultV2CommandInput,
cb: (err: any, data?: GetStatementResultV2CommandOutput) => void
): void;
getStatementResultV2(
args: GetStatementResultV2CommandInput,
options: __HttpHandlerOptions,
cb: (err: any, data?: GetStatementResultV2CommandOutput) => void
): void;

/**
* @see {@link ListDatabasesCommand}
*/
Expand Down
6 changes: 6 additions & 0 deletions clients/client-redshift-data/src/RedshiftDataClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,10 @@ import { DescribeStatementCommandInput, DescribeStatementCommandOutput } from ".
import { DescribeTableCommandInput, DescribeTableCommandOutput } from "./commands/DescribeTableCommand";
import { ExecuteStatementCommandInput, ExecuteStatementCommandOutput } from "./commands/ExecuteStatementCommand";
import { GetStatementResultCommandInput, GetStatementResultCommandOutput } from "./commands/GetStatementResultCommand";
import {
GetStatementResultV2CommandInput,
GetStatementResultV2CommandOutput,
} from "./commands/GetStatementResultV2Command";
import { ListDatabasesCommandInput, ListDatabasesCommandOutput } from "./commands/ListDatabasesCommand";
import { ListSchemasCommandInput, ListSchemasCommandOutput } from "./commands/ListSchemasCommand";
import { ListStatementsCommandInput, ListStatementsCommandOutput } from "./commands/ListStatementsCommand";
Expand All @@ -87,6 +91,7 @@ export type ServiceInputTypes =
| DescribeTableCommandInput
| ExecuteStatementCommandInput
| GetStatementResultCommandInput
| GetStatementResultV2CommandInput
| ListDatabasesCommandInput
| ListSchemasCommandInput
| ListStatementsCommandInput
Expand All @@ -102,6 +107,7 @@ export type ServiceOutputTypes =
| DescribeTableCommandOutput
| ExecuteStatementCommandOutput
| GetStatementResultCommandOutput
| GetStatementResultV2CommandOutput
| ListDatabasesCommandOutput
| ListSchemasCommandOutput
| ListStatementsCommandOutput
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ export interface BatchExecuteStatementCommandOutput extends BatchExecuteStatemen
* ClientToken: "STRING_VALUE",
* SessionKeepAliveSeconds: Number("int"),
* SessionId: "STRING_VALUE",
* ResultFormat: "STRING_VALUE",
* };
* const command = new BatchExecuteStatementCommand(input);
* const response = await client.send(command);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ export interface DescribeStatementCommandOutput extends DescribeStatementRespons
* // ],
* // WorkgroupName: "STRING_VALUE",
* // SessionId: "STRING_VALUE",
* // ResultFormat: "STRING_VALUE",
* // };
*
* ```
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ export interface ExecuteStatementCommandOutput extends ExecuteStatementOutput, _
* ClientToken: "STRING_VALUE",
* SessionKeepAliveSeconds: Number("int"),
* SessionId: "STRING_VALUE",
* ResultFormat: "STRING_VALUE",
* };
* const command = new ExecuteStatementCommand(input);
* const response = await client.send(command);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,10 @@ export interface GetStatementResultCommandInput extends GetStatementResultReques
export interface GetStatementResultCommandOutput extends GetStatementResultResponse, __MetadataBearer {}

/**
* <p>Fetches the temporarily cached result of an SQL statement.
* A token is returned to page through the statement results. </p>
* <p>Fetches the temporarily cached result of an SQL statement in JSON format.
* The <code>ExecuteStatement</code> or <code>BatchExecuteStatement</code> operation that ran the SQL statement must have specified <code>ResultFormat</code> as <code>JSON</code>
* , or let the format default to JSON.
* A token is returned to page through the statement results.</p>
* <p>For more information about the Amazon Redshift Data API and CLI usage examples, see
* <a href="https://docs.aws.amazon.com/redshift/latest/mgmt/data-api.html">Using the Amazon Redshift Data API</a> in the
* <i>Amazon Redshift Management Guide</i>. </p>
Expand Down
Original file line number Diff line number Diff line change
@@ -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 {}

/**
* <p>Fetches the temporarily cached result of an SQL statement in CSV format.
* The <code>ExecuteStatement</code> or <code>BatchExecuteStatement</code> operation that ran the SQL statement must have specified <code>ResultFormat</code> as <code>CSV</code>.
* A token is returned to page through the statement results.</p>
* <p>For more information about the Amazon Redshift Data API and CLI usage examples, see
* <a href="https://docs.aws.amazon.com/redshift/latest/mgmt/data-api.html">Using the Amazon Redshift Data API</a> in the
* <i>Amazon Redshift Management Guide</i>. </p>
* @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)
* <p>The Amazon Redshift Data API operation failed due to invalid input. </p>
*
* @throws {@link ResourceNotFoundException} (client fault)
* <p>The Amazon Redshift Data API operation failed due to a missing resource. </p>
*
* @throws {@link ValidationException} (client fault)
* <p>The Amazon Redshift Data API operation failed due to invalid input. </p>
*
* @throws {@link RedshiftDataServiceException}
* <p>Base exception class for all service exceptions from RedshiftData service.</p>
*
* @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;
};
};
}
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ export interface ListStatementsCommandOutput extends ListStatementsResponse, __M
* // ],
* // IsBatchStatement: true || false,
* // SessionId: "STRING_VALUE",
* // ResultFormat: "STRING_VALUE",
* // },
* // ],
* // NextToken: "STRING_VALUE",
Expand Down
1 change: 1 addition & 0 deletions clients/client-redshift-data/src/commands/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down
Loading

0 comments on commit 5943dd5

Please sign in to comment.