File tree Expand file tree Collapse file tree 2 files changed +15
-7
lines changed Expand file tree Collapse file tree 2 files changed +15
-7
lines changed Original file line number Diff line number Diff line change 5
5
*/
6
6
7
7
import * as vscode from 'vscode'
8
- import { DefaultRedshiftClient , ExecuteQueryResponse } from '../../shared/clients/redshiftClient'
8
+ import { DefaultRedshiftClient } from '../../shared/clients/redshiftClient'
9
9
import { ConnectionParams } from '../models/models'
10
10
import { RedshiftData } from 'aws-sdk'
11
11
import { telemetry } from '../../shared/telemetry/telemetry'
@@ -84,16 +84,22 @@ export class RedshiftNotebookController {
84
84
let nextToken : string | undefined
85
85
// get all the pages of the result
86
86
do {
87
- const result : ExecuteQueryResponse = await this . redshiftClient ! . executeQuery (
87
+ const result = await this . redshiftClient ! . executeQuery (
88
88
connectionParams ,
89
89
cell . document . getText ( ) ,
90
90
nextToken ,
91
91
executionId
92
92
)
93
- nextToken = result . statementResultResponse . NextToken
94
- executionId = result . executionId
95
- columnMetadata = result . statementResultResponse . ColumnMetadata
96
- records . push ( ...result . statementResultResponse . Records )
93
+ if ( result ) {
94
+ nextToken = result . statementResultResponse . NextToken
95
+ executionId = result . executionId
96
+ columnMetadata = result . statementResultResponse . ColumnMetadata
97
+ records . push ( ...result . statementResultResponse . Records )
98
+ } else {
99
+ return new vscode . NotebookCellOutput ( [
100
+ vscode . NotebookCellOutputItem . text ( 'No records.' , 'text/plain' ) ,
101
+ ] )
102
+ }
97
103
} while ( nextToken )
98
104
99
105
if ( columnMetadata ) {
Original file line number Diff line number Diff line change @@ -149,7 +149,7 @@ export class DefaultRedshiftClient {
149
149
queryToExecute : string ,
150
150
nextToken ?: string ,
151
151
executionId ?: string
152
- ) : Promise < ExecuteQueryResponse > {
152
+ ) : Promise < ExecuteQueryResponse | undefined > {
153
153
const redshiftData = await this . redshiftDataClientProvider ( this . regionCode )
154
154
// if executionId is not passed in, that means that we're executing and retrieving the results of the query for the first time.
155
155
if ( ! executionId ) {
@@ -189,6 +189,8 @@ export class DefaultRedshiftClient {
189
189
throw new Error (
190
190
`Failed to run query: '${ queryToExecute } ': '${ describeStatementResponse . Error } '`
191
191
)
192
+ } else if ( status === 'FINISHED' ) {
193
+ return undefined
192
194
}
193
195
break
194
196
} else {
You can’t perform that action at this time.
0 commit comments