File tree Expand file tree Collapse file tree 2 files changed +41
-2
lines changed Expand file tree Collapse file tree 2 files changed +41
-2
lines changed Original file line number Diff line number Diff line change @@ -88,7 +88,7 @@ function cleanUpPaginatedDML(
8888 if ( ! Data ) return acc ;
8989
9090 const rowObject = Data ?. reduce ( ( acc , row , index ) => {
91- if ( row . VarCharValue ) {
91+ if ( row . VarCharValue !== undefined && row . VarCharValue !== null ) {
9292 // use mutable operation for performance
9393 acc [ columnNames [ index ] ] = row . VarCharValue ;
9494 }
@@ -113,7 +113,7 @@ function addDataType(
113113 > = { } ;
114114
115115 for ( const key in input ) {
116- if ( ! input [ key ] ) {
116+ if ( input [ key ] === null || input [ key ] === undefined ) {
117117 updatedObjectWithDataType [ key ] = null ;
118118 } else {
119119 switch ( dataTypes [ key ] ) {
Original file line number Diff line number Diff line change @@ -312,3 +312,42 @@ test("throw exception when query is respond as failed", async () => {
312312 "No QueryExecutionId was responded."
313313 ) ;
314314} ) ;
315+
316+ test . only ( "If empty string is returned from AthenaSDK, it will be returned as an empty string" , async ( ) => {
317+ athenaMock
318+ . on ( StartQueryExecutionCommand )
319+ . resolves ( { QueryExecutionId : "test-QueryExecutionId" } )
320+ . on ( GetQueryExecutionCommand )
321+ . resolves ( { QueryExecution : { Status : { State : "SUCCEEDED" } } } )
322+ . on ( GetQueryResultsCommand )
323+ . resolves ( {
324+ ResultSet : {
325+ ResultSetMetadata : {
326+ ColumnInfo : [
327+ { Name : "nullValue" , Type : "unknown" } ,
328+ { Name : "emptyValue" , Type : "varchar" } ,
329+ ] ,
330+ } ,
331+ Rows : [
332+ {
333+ // header row
334+ Data : [
335+ { VarCharValue : "nullValue" } ,
336+ { VarCharValue : "emptyValue" } ,
337+ ] ,
338+ } ,
339+ {
340+ Data : [ { } , { VarCharValue : "" } ] ,
341+ } ,
342+ ] ,
343+ } ,
344+ } ) ;
345+
346+ const athenaQuery = new AthenaQuery ( athena ) ;
347+ const resultGen = athenaQuery . query ( "" ) ;
348+ const res1 = await resultGen . next ( ) ;
349+ expect ( res1 . value ) . toEqual ( {
350+ // nullValue is removed from the object
351+ emptyValue : "" ,
352+ } ) ;
353+ } ) ;
You can’t perform that action at this time.
0 commit comments