@@ -52,6 +52,7 @@ import {
5252 jumpToLocation ,
5353} from './interface-utils' ;
5454import { getDefaultResultSetName } from './interface-types' ;
55+ import { ResultSetSchema } from './bqrs-cli-types' ;
5556
5657/**
5758 * interface.ts
@@ -330,19 +331,13 @@ export class InterfaceManager extends DisposableObject {
330331
331332 const getParsedResultSets = async ( ) : Promise < ParsedResultSets > => {
332333 if ( EXPERIMENTAL_BQRS_SETTING . getValue ( ) ) {
333- const schemas = await this . cliServer . bqrsInfo (
334- results . query . resultsPaths . resultsPath ,
335- RAW_RESULTS_PAGE_SIZE
336- ) ;
337-
338- const resultSetNames = schemas [ 'result-sets' ] . map (
339- ( resultSet ) => resultSet . name
340- ) ;
334+ const resultSetSchemas = await this . getResultSetSchemas ( results ) ;
335+ const resultSetNames = resultSetSchemas . map ( schema => schema . name ) ;
341336
342337 // This may not wind up being the page we actually show, if there are interpreted results,
343338 // but speculatively send it anyway.
344339 const selectedTable = getDefaultResultSetName ( resultSetNames ) ;
345- const schema = schemas [ 'result-sets' ] . find (
340+ const schema = resultSetSchemas . find (
346341 ( resultSet ) => resultSet . name == selectedTable
347342 ) ! ;
348343 if ( schema === undefined ) {
@@ -401,16 +396,29 @@ export class InterfaceManager extends DisposableObject {
401396 if ( this . _interpretation . sarif . runs [ 0 ] . results === undefined ) {
402397 throw new Error ( `Trying to show interpreted results but results were undefined` ) ;
403398 }
399+
400+ const resultSetSchemas = await this . getResultSetSchemas ( this . _displayedQuery ) ;
401+ const resultSetNames = resultSetSchemas . map ( schema => schema . name ) ;
402+
404403 await this . postMessage ( {
405404 t : 'showInterpretedPage' ,
406405 interpretation : this . getPageOfInterpretedResults ( pageNumber ) ,
407406 database : this . _displayedQuery . database ,
408407 metadata : this . _displayedQuery . query . metadata ,
409408 pageNumber,
409+ resultSetNames,
410410 numPages : Math . ceil ( this . _interpretation . sarif . runs [ 0 ] . results . length / INTERPRETED_RESULTS_PAGE_SIZE ) ,
411411 } ) ;
412412 }
413413
414+ private async getResultSetSchemas ( results : CompletedQuery ) : Promise < ResultSetSchema [ ] > {
415+ const schemas = await this . cliServer . bqrsInfo (
416+ results . query . resultsPaths . resultsPath ,
417+ RAW_RESULTS_PAGE_SIZE
418+ ) ;
419+ return schemas [ 'result-sets' ] ;
420+ }
421+
414422 /**
415423 * Show a page of raw results from the chosen table.
416424 */
@@ -429,16 +437,10 @@ export class InterfaceManager extends DisposableObject {
429437 ( sortedResultsMap [ k ] = this . convertPathPropertiesToWebviewUris ( v ) )
430438 ) ;
431439
432- const schemas = await this . cliServer . bqrsInfo (
433- results . query . resultsPaths . resultsPath ,
434- RAW_RESULTS_PAGE_SIZE
435- ) ;
436-
437- const resultSetNames = schemas [ 'result-sets' ] . map (
438- ( resultSet ) => resultSet . name
439- ) ;
440+ const resultSetSchemas = await this . getResultSetSchemas ( results ) ;
441+ const resultSetNames = resultSetSchemas . map ( schema => schema . name ) ;
440442
441- const schema = schemas [ 'result-sets' ] . find (
443+ const schema = resultSetSchemas . find (
442444 ( resultSet ) => resultSet . name == selectedTable
443445 ) ! ;
444446 if ( schema === undefined )
0 commit comments