Skip to content

Feature/OutputLocationを指定できるようにオプション項目を追加 #82

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/athena-query.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@ type Options = {
* The name of the data catalog used in the query execution.
*/
catalog?: string;

/**
* The location in Amazon S3 where your query and calculation results are stored.
*/
outputLocation?: string;
};

export class AthenaQuery {
Expand Down
5 changes: 5 additions & 0 deletions src/helper.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import type {
Athena,
GetQueryResultsCommandOutput,
ResultConfiguration,
} from "@aws-sdk/client-athena";

export type AtheneRecordData = Record<string, string | number | BigInt | null>;
Expand All @@ -13,6 +14,7 @@ async function startQueryExecution(params: {
workgroup?: string;
db?: string;
catalog?: string;
outputLocation?: string;
}) {
const output = await params.athena.startQueryExecution({
QueryString: params.sql,
Expand All @@ -22,6 +24,9 @@ async function startQueryExecution(params: {
Database: params.db || "default",
Catalog: params.catalog,
},
ResultConfiguration: {
OutputLocation: params.outputLocation,
},
});

if (!output.QueryExecutionId) {
Expand Down
4 changes: 4 additions & 0 deletions test/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,7 @@ test("pass args to sdk", async () => {
db: "test-db",
workgroup: "test-workgroup",
catalog: "test-catalog",
outputLocation: "s3//example/path",
});
const resultGen = athenaQuery.query("SELECT test FROM test;", {
executionParameters: ["test", 123, 456n],
Expand All @@ -276,6 +277,9 @@ test("pass args to sdk", async () => {
Catalog: "test-catalog",
Database: "test-db",
},
ResultConfiguration: {
OutputLocation: "s3//example/path",
},
});

expect(
Expand Down
Loading