File tree 2 files changed +18
-4
lines changed 2 files changed +18
-4
lines changed Original file line number Diff line number Diff line change @@ -15,12 +15,26 @@ export class AthenaQuery {
15
15
16
16
async * query (
17
17
sql : string ,
18
- options ?: { executionParameters ?: string [ ] ; maxResults ?: number }
18
+ options ?: {
19
+ executionParameters ?: ( string | number | BigInt ) [ ] ;
20
+ maxResults ?: number ;
21
+ }
19
22
) : AsyncGenerator < helpers . AtheneRecordData , void , undefined > {
20
23
const QueryExecutionId = await helpers . startQueryExecution ( {
21
24
athena : this . athena ,
22
25
sql,
23
- executionParameters : options ?. executionParameters ,
26
+ executionParameters : options ?. executionParameters ?. map ( ( param ) => {
27
+ const typeOfParam = typeof param ;
28
+ switch ( typeOfParam ) {
29
+ case "bigint" :
30
+ case "number" :
31
+ return param . toString ( ) ;
32
+ case "string" :
33
+ return `'${ param } '` ;
34
+ default :
35
+ throw new Error ( `${ typeOfParam } type is not allowed.` ) ;
36
+ }
37
+ } ) ,
24
38
...this . options ,
25
39
} ) ;
26
40
Original file line number Diff line number Diff line change @@ -251,7 +251,7 @@ test("pass args to sdk", async () => {
251
251
catalog : "test-catalog" ,
252
252
} ) ;
253
253
const resultGen = athenaQuery . query ( "SELECT test FROM test;" , {
254
- executionParameters : [ "' test' " , " 123" ] ,
254
+ executionParameters : [ "test" , 123 , 456n ] ,
255
255
maxResults : 100 ,
256
256
} ) ;
257
257
@@ -261,7 +261,7 @@ test("pass args to sdk", async () => {
261
261
athenaMock . commandCalls ( StartQueryExecutionCommand ) [ 0 ] . args [ 0 ] . input
262
262
) . toEqual ( {
263
263
QueryString : "SELECT test FROM test;" ,
264
- ExecutionParameters : [ "'test'" , "123" ] ,
264
+ ExecutionParameters : [ "'test'" , "123" , "456" ] ,
265
265
WorkGroup : "test-workgroup" ,
266
266
QueryExecutionContext : {
267
267
Catalog : "test-catalog" ,
You can’t perform that action at this time.
0 commit comments