File tree Expand file tree Collapse file tree 1 file changed +15
-3
lines changed Expand file tree Collapse file tree 1 file changed +15
-3
lines changed Original file line number Diff line number Diff line change @@ -62,20 +62,32 @@ async function getQueryResults(params: {
6262 NextToken : params . NextToken ,
6363 } ) ;
6464 return {
65- items : await cleanUpPaginatedDML ( queryResults ) ,
65+ items : await cleanUpPaginatedDML (
66+ queryResults ,
67+ // If NextToken is not given, ignore first data.
68+ // Because the first data is header info.
69+ ! params . NextToken
70+ ) ,
6671 nextToken : queryResults . NextToken ,
6772 } ;
6873}
6974
70- async function cleanUpPaginatedDML ( queryResults : GetQueryResultsCommandOutput ) {
75+ async function cleanUpPaginatedDML (
76+ queryResults : GetQueryResultsCommandOutput ,
77+ ignoreFirstData : boolean
78+ ) {
7179 const dataTypes = await getDataTypes ( queryResults ) ;
7280 if ( ! dataTypes ) return [ ] ;
7381
7482 const columnNames = Object . keys ( dataTypes ) ;
7583 let unformattedS3RowArray : Datum [ ] | null = null ;
7684 let formattedArray : Record < string , string | number | BigInt | null > [ ] = [ ] ;
7785
78- for ( let i = 0 ; i < ( queryResults . ResultSet ?. Rows ?. length ?? 0 ) ; i ++ ) {
86+ for (
87+ let i = ignoreFirstData ? 1 : 0 ;
88+ i < ( queryResults . ResultSet ?. Rows ?. length ?? 0 ) ;
89+ i ++
90+ ) {
7991 unformattedS3RowArray = queryResults . ResultSet ?. Rows ?. [ i ] . Data ?? null ;
8092
8193 if ( ! unformattedS3RowArray ) continue ;
You can’t perform that action at this time.
0 commit comments