Skip to content

Commit

Permalink
feat(client-athena): This feature allows customers to retrieve runtim…
Browse files Browse the repository at this point in the history
…e statistics for completed queries
  • Loading branch information
awstools committed Jul 21, 2022
1 parent a2aef86 commit 6fe9621
Show file tree
Hide file tree
Showing 9 changed files with 897 additions and 1 deletion.
40 changes: 40 additions & 0 deletions clients/client-athena/src/Athena.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,11 @@ import {
GetQueryResultsCommandInput,
GetQueryResultsCommandOutput,
} from "./commands/GetQueryResultsCommand";
import {
GetQueryRuntimeStatisticsCommand,
GetQueryRuntimeStatisticsCommandInput,
GetQueryRuntimeStatisticsCommandOutput,
} from "./commands/GetQueryRuntimeStatisticsCommand";
import {
GetTableMetadataCommand,
GetTableMetadataCommandInput,
Expand Down Expand Up @@ -772,6 +777,41 @@ export class Athena extends AthenaClient {
}
}

/**
* <p>Returns query execution runtime statistics related to a single execution of a query if you
* have access to the workgroup in which the query ran. The query execution runtime statistics
* is returned only when <a>QueryExecutionStatus$State</a> is in a SUCCEEDED
* or FAILED state.</p>
*/
public getQueryRuntimeStatistics(
args: GetQueryRuntimeStatisticsCommandInput,
options?: __HttpHandlerOptions
): Promise<GetQueryRuntimeStatisticsCommandOutput>;
public getQueryRuntimeStatistics(
args: GetQueryRuntimeStatisticsCommandInput,
cb: (err: any, data?: GetQueryRuntimeStatisticsCommandOutput) => void
): void;
public getQueryRuntimeStatistics(
args: GetQueryRuntimeStatisticsCommandInput,
options: __HttpHandlerOptions,
cb: (err: any, data?: GetQueryRuntimeStatisticsCommandOutput) => void
): void;
public getQueryRuntimeStatistics(
args: GetQueryRuntimeStatisticsCommandInput,
optionsOrCb?: __HttpHandlerOptions | ((err: any, data?: GetQueryRuntimeStatisticsCommandOutput) => void),
cb?: (err: any, data?: GetQueryRuntimeStatisticsCommandOutput) => void
): Promise<GetQueryRuntimeStatisticsCommandOutput> | void {
const command = new GetQueryRuntimeStatisticsCommand(args);
if (typeof optionsOrCb === "function") {
this.send(command, optionsOrCb);
} else if (typeof cb === "function") {
if (typeof optionsOrCb !== "object") throw new Error(`Expect http options but get ${typeof optionsOrCb}`);
this.send(command, optionsOrCb || {}, cb);
} else {
return this.send(command, optionsOrCb);
}
}

/**
* <p>Returns table metadata for the specified catalog, database, and table.</p>
*/
Expand Down
6 changes: 6 additions & 0 deletions clients/client-athena/src/AthenaClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,10 @@ import {
} from "./commands/GetPreparedStatementCommand";
import { GetQueryExecutionCommandInput, GetQueryExecutionCommandOutput } from "./commands/GetQueryExecutionCommand";
import { GetQueryResultsCommandInput, GetQueryResultsCommandOutput } from "./commands/GetQueryResultsCommand";
import {
GetQueryRuntimeStatisticsCommandInput,
GetQueryRuntimeStatisticsCommandOutput,
} from "./commands/GetQueryRuntimeStatisticsCommand";
import { GetTableMetadataCommandInput, GetTableMetadataCommandOutput } from "./commands/GetTableMetadataCommand";
import { GetWorkGroupCommandInput, GetWorkGroupCommandOutput } from "./commands/GetWorkGroupCommand";
import { ListDatabasesCommandInput, ListDatabasesCommandOutput } from "./commands/ListDatabasesCommand";
Expand Down Expand Up @@ -139,6 +143,7 @@ export type ServiceInputTypes =
| GetPreparedStatementCommandInput
| GetQueryExecutionCommandInput
| GetQueryResultsCommandInput
| GetQueryRuntimeStatisticsCommandInput
| GetTableMetadataCommandInput
| GetWorkGroupCommandInput
| ListDataCatalogsCommandInput
Expand Down Expand Up @@ -177,6 +182,7 @@ export type ServiceOutputTypes =
| GetPreparedStatementCommandOutput
| GetQueryExecutionCommandOutput
| GetQueryResultsCommandOutput
| GetQueryRuntimeStatisticsCommandOutput
| GetTableMetadataCommandOutput
| GetWorkGroupCommandOutput
| ListDataCatalogsCommandOutput
Expand Down
102 changes: 102 additions & 0 deletions clients/client-athena/src/commands/GetQueryRuntimeStatisticsCommand.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
// smithy-typescript generated code
import { getSerdePlugin } from "@aws-sdk/middleware-serde";
import { HttpRequest as __HttpRequest, HttpResponse as __HttpResponse } from "@aws-sdk/protocol-http";
import { Command as $Command } from "@aws-sdk/smithy-client";
import {
FinalizeHandlerArguments,
Handler,
HandlerExecutionContext,
HttpHandlerOptions as __HttpHandlerOptions,
MetadataBearer as __MetadataBearer,
MiddlewareStack,
SerdeContext as __SerdeContext,
} from "@aws-sdk/types";

import { AthenaClientResolvedConfig, ServiceInputTypes, ServiceOutputTypes } from "../AthenaClient";
import { GetQueryRuntimeStatisticsInput, GetQueryRuntimeStatisticsOutput } from "../models/models_0";
import {
deserializeAws_json1_1GetQueryRuntimeStatisticsCommand,
serializeAws_json1_1GetQueryRuntimeStatisticsCommand,
} from "../protocols/Aws_json1_1";

export interface GetQueryRuntimeStatisticsCommandInput extends GetQueryRuntimeStatisticsInput {}
export interface GetQueryRuntimeStatisticsCommandOutput extends GetQueryRuntimeStatisticsOutput, __MetadataBearer {}

/**
* <p>Returns query execution runtime statistics related to a single execution of a query if you
* have access to the workgroup in which the query ran. The query execution runtime statistics
* is returned only when <a>QueryExecutionStatus$State</a> is in a SUCCEEDED
* or FAILED state.</p>
* @example
* Use a bare-bones client and the command you need to make an API call.
* ```javascript
* import { AthenaClient, GetQueryRuntimeStatisticsCommand } from "@aws-sdk/client-athena"; // ES Modules import
* // const { AthenaClient, GetQueryRuntimeStatisticsCommand } = require("@aws-sdk/client-athena"); // CommonJS import
* const client = new AthenaClient(config);
* const command = new GetQueryRuntimeStatisticsCommand(input);
* const response = await client.send(command);
* ```
*
* @see {@link GetQueryRuntimeStatisticsCommandInput} for command's `input` shape.
* @see {@link GetQueryRuntimeStatisticsCommandOutput} for command's `response` shape.
* @see {@link AthenaClientResolvedConfig | config} for AthenaClient's `config` shape.
*
*/
export class GetQueryRuntimeStatisticsCommand extends $Command<
GetQueryRuntimeStatisticsCommandInput,
GetQueryRuntimeStatisticsCommandOutput,
AthenaClientResolvedConfig
> {
// Start section: command_properties
// End section: command_properties

constructor(readonly input: GetQueryRuntimeStatisticsCommandInput) {
// Start section: command_constructor
super();
// End section: command_constructor
}

/**
* @internal
*/
resolveMiddleware(
clientStack: MiddlewareStack<ServiceInputTypes, ServiceOutputTypes>,
configuration: AthenaClientResolvedConfig,
options?: __HttpHandlerOptions
): Handler<GetQueryRuntimeStatisticsCommandInput, GetQueryRuntimeStatisticsCommandOutput> {
this.middlewareStack.use(getSerdePlugin(configuration, this.serialize, this.deserialize));

const stack = clientStack.concat(this.middlewareStack);

const { logger } = configuration;
const clientName = "AthenaClient";
const commandName = "GetQueryRuntimeStatisticsCommand";
const handlerExecutionContext: HandlerExecutionContext = {
logger,
clientName,
commandName,
inputFilterSensitiveLog: GetQueryRuntimeStatisticsInput.filterSensitiveLog,
outputFilterSensitiveLog: GetQueryRuntimeStatisticsOutput.filterSensitiveLog,
};
const { requestHandler } = configuration;
return stack.resolve(
(request: FinalizeHandlerArguments<any>) =>
requestHandler.handle(request.request as __HttpRequest, options || {}),
handlerExecutionContext
);
}

private serialize(input: GetQueryRuntimeStatisticsCommandInput, context: __SerdeContext): Promise<__HttpRequest> {
return serializeAws_json1_1GetQueryRuntimeStatisticsCommand(input, context);
}

private deserialize(
output: __HttpResponse,
context: __SerdeContext
): Promise<GetQueryRuntimeStatisticsCommandOutput> {
return deserializeAws_json1_1GetQueryRuntimeStatisticsCommand(output, context);
}

// Start section: command_body_extra
// End section: command_body_extra
}
1 change: 1 addition & 0 deletions clients/client-athena/src/commands/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export * from "./GetNamedQueryCommand";
export * from "./GetPreparedStatementCommand";
export * from "./GetQueryExecutionCommand";
export * from "./GetQueryResultsCommand";
export * from "./GetQueryRuntimeStatisticsCommand";
export * from "./GetTableMetadataCommand";
export * from "./GetWorkGroupCommand";
export * from "./ListDataCatalogsCommand";
Expand Down
Loading

0 comments on commit 6fe9621

Please sign in to comment.