Skip to content

Commit 8a8467d

Browse files
committedMar 13, 2024·
feat add option outputlocation
1 parent f159b8f commit 8a8467d

File tree

3 files changed

+14
-0
lines changed

3 files changed

+14
-0
lines changed
 

‎src/athena-query.ts

+5
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,11 @@ type Options = {
1717
* The name of the data catalog used in the query execution.
1818
*/
1919
catalog?: string;
20+
21+
/**
22+
* The location in Amazon S3 where your query and calculation results are stored.
23+
*/
24+
outputLocation?: string;
2025
};
2126

2227
export class AthenaQuery {

‎src/helper.ts

+5
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import type {
22
Athena,
33
GetQueryResultsCommandOutput,
4+
ResultConfiguration,
45
} from "@aws-sdk/client-athena";
56

67
export type AtheneRecordData = Record<string, string | number | BigInt | null>;
@@ -13,6 +14,7 @@ async function startQueryExecution(params: {
1314
workgroup?: string;
1415
db?: string;
1516
catalog?: string;
17+
outputLocation?: string;
1618
}) {
1719
const output = await params.athena.startQueryExecution({
1820
QueryString: params.sql,
@@ -22,6 +24,9 @@ async function startQueryExecution(params: {
2224
Database: params.db || "default",
2325
Catalog: params.catalog,
2426
},
27+
ResultConfiguration: {
28+
OutputLocation: params.outputLocation,
29+
},
2530
});
2631

2732
if (!output.QueryExecutionId) {

‎test/index.test.ts

+4
Original file line numberDiff line numberDiff line change
@@ -258,6 +258,7 @@ test("pass args to sdk", async () => {
258258
db: "test-db",
259259
workgroup: "test-workgroup",
260260
catalog: "test-catalog",
261+
outputLocation: "s3//example/path",
261262
});
262263
const resultGen = athenaQuery.query("SELECT test FROM test;", {
263264
executionParameters: ["test", 123, 456n],
@@ -276,6 +277,9 @@ test("pass args to sdk", async () => {
276277
Catalog: "test-catalog",
277278
Database: "test-db",
278279
},
280+
ResultConfiguration: {
281+
OutputLocation: "s3//example/path",
282+
},
279283
});
280284

281285
expect(

0 commit comments

Comments
 (0)