Skip to content

Commit

Permalink
Merge pull request #82 from KantaHasegawa/feat/add-option-output-loca…
Browse files Browse the repository at this point in the history
…tion

Feature/OutputLocationを指定できるようにオプション項目を追加
  • Loading branch information
yamatatsu authored Mar 31, 2024
2 parents f159b8f + 8a8467d commit 92c9014
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 0 deletions.
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

0 comments on commit 92c9014

Please sign in to comment.