File tree Expand file tree Collapse file tree 2 files changed +18
-4
lines changed Expand file tree Collapse file tree 2 files changed +18
-4
lines changed Original file line number Diff line number Diff line change @@ -15,12 +15,26 @@ export class AthenaQuery {
1515
1616 async * query (
1717 sql : string ,
18- options ?: { executionParameters ?: string [ ] ; maxResults ?: number }
18+ options ?: {
19+ executionParameters ?: ( string | number | BigInt ) [ ] ;
20+ maxResults ?: number ;
21+ }
1922 ) : AsyncGenerator < helpers . AtheneRecordData , void , undefined > {
2023 const QueryExecutionId = await helpers . startQueryExecution ( {
2124 athena : this . athena ,
2225 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+ } ) ,
2438 ...this . options ,
2539 } ) ;
2640
Original file line number Diff line number Diff line change @@ -251,7 +251,7 @@ test("pass args to sdk", async () => {
251251 catalog : "test-catalog" ,
252252 } ) ;
253253 const resultGen = athenaQuery . query ( "SELECT test FROM test;" , {
254- executionParameters : [ "' test' " , " 123" ] ,
254+ executionParameters : [ "test" , 123 , 456n ] ,
255255 maxResults : 100 ,
256256 } ) ;
257257
@@ -261,7 +261,7 @@ test("pass args to sdk", async () => {
261261 athenaMock . commandCalls ( StartQueryExecutionCommand ) [ 0 ] . args [ 0 ] . input
262262 ) . toEqual ( {
263263 QueryString : "SELECT test FROM test;" ,
264- ExecutionParameters : [ "'test'" , "123" ] ,
264+ ExecutionParameters : [ "'test'" , "123" , "456" ] ,
265265 WorkGroup : "test-workgroup" ,
266266 QueryExecutionContext : {
267267 Catalog : "test-catalog" ,
You can’t perform that action at this time.
0 commit comments