Fix incorrect call to bqrs info when retrieving paginated results
When retrieving paginated results, need to make sure we are getting page offsets from the correct results file. Previously, we were incorrectly extracting page offsets from the default (unsorted) file. With this change, we ensure that we get offsets from the proper results file when there is a request for a page of results.
This commit is contained in:
@@ -352,40 +352,39 @@ export class InterfaceManager extends DisposableObject {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
const getParsedResultSets = async (): Promise<ParsedResultSets> => {
|
// Note that the resultSetSchemas will return offsets for the default (unsorted) page,
|
||||||
|
// which may not be correct. However, in this case, it doesn't matter since we only
|
||||||
|
// need the first offset, which will be the same no matter which sorting we use.
|
||||||
|
const resultSetSchemas = await this.getResultSetSchemas(results);
|
||||||
|
const resultSetNames = resultSetSchemas.map(schema => schema.name);
|
||||||
|
|
||||||
const resultSetSchemas = await this.getResultSetSchemas(results);
|
const selectedTable = getDefaultResultSetName(resultSetNames);
|
||||||
const resultSetNames = resultSetSchemas.map(schema => schema.name);
|
const schema = resultSetSchemas.find(
|
||||||
|
(resultSet) => resultSet.name == selectedTable
|
||||||
|
)!;
|
||||||
|
|
||||||
// This may not wind up being the page we actually show, if there are interpreted results,
|
// Use sorted results path if it exists. This may happen if we are
|
||||||
// but speculatively send it anyway.
|
// reloading the results view after it has been sorted in the past.
|
||||||
const selectedTable = getDefaultResultSetName(resultSetNames);
|
const resultsPath = results.sortedResultsInfo.get(selectedTable)?.resultsPath
|
||||||
const schema = resultSetSchemas.find(
|
|| results.query.resultsPaths.resultsPath;
|
||||||
(resultSet) => resultSet.name == selectedTable
|
|
||||||
)!;
|
|
||||||
|
|
||||||
// Use sorted results path if it exists. This may happen if we are
|
const chunk = await this.cliServer.bqrsDecode(
|
||||||
// reloading the results view after it has been sorted in the past.
|
resultsPath,
|
||||||
const resultsPath = results.sortedResultsInfo.get(selectedTable)?.resultsPath
|
schema.name,
|
||||||
|| results.query.resultsPaths.resultsPath;
|
{
|
||||||
|
// always use the first page. –
|
||||||
const chunk = await this.cliServer.bqrsDecode(
|
offset: schema.pagination?.offsets[0],
|
||||||
resultsPath,
|
pageSize: RAW_RESULTS_PAGE_SIZE
|
||||||
schema.name,
|
}
|
||||||
{
|
);
|
||||||
offset: schema.pagination?.offsets[0],
|
const resultSet = transformBqrsResultSet(schema, chunk);
|
||||||
pageSize: RAW_RESULTS_PAGE_SIZE
|
const parsedResultSets: ParsedResultSets = {
|
||||||
}
|
pageNumber: 0,
|
||||||
);
|
numPages: numPagesOfResultSet(resultSet),
|
||||||
const resultSet = transformBqrsResultSet(schema, chunk);
|
numInterpretedPages: numInterpretedPages(this._interpretation),
|
||||||
return {
|
resultSet: { ...resultSet, t: 'RawResultSet' },
|
||||||
pageNumber: 0,
|
selectedTable: undefined,
|
||||||
numPages: numPagesOfResultSet(resultSet),
|
resultSetNames,
|
||||||
numInterpretedPages: numInterpretedPages(this._interpretation),
|
|
||||||
resultSet: { t: 'RawResultSet', ...resultSet },
|
|
||||||
selectedTable: undefined,
|
|
||||||
resultSetNames,
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
|
|
||||||
await this.postMessage({
|
await this.postMessage({
|
||||||
@@ -395,7 +394,7 @@ export class InterfaceManager extends DisposableObject {
|
|||||||
resultsPath: this.convertPathToWebviewUri(
|
resultsPath: this.convertPathToWebviewUri(
|
||||||
results.query.resultsPaths.resultsPath
|
results.query.resultsPaths.resultsPath
|
||||||
),
|
),
|
||||||
parsedResultSets: await getParsedResultSets(),
|
parsedResultSets,
|
||||||
sortedResultsMap,
|
sortedResultsMap,
|
||||||
database: results.database,
|
database: results.database,
|
||||||
shouldKeepOldResultsWhileRendering,
|
shouldKeepOldResultsWhileRendering,
|
||||||
@@ -433,9 +432,11 @@ export class InterfaceManager extends DisposableObject {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private async getResultSetSchemas(results: CompletedQuery): Promise<ResultSetSchema[]> {
|
private async getResultSetSchemas(results: CompletedQuery, selectedTable = ''): Promise<ResultSetSchema[]> {
|
||||||
|
const resultsPath = results.sortedResultsInfo.get(selectedTable)?.resultsPath
|
||||||
|
|| results.query.resultsPaths.resultsPath;
|
||||||
const schemas = await this.cliServer.bqrsInfo(
|
const schemas = await this.cliServer.bqrsInfo(
|
||||||
results.query.resultsPaths.resultsPath,
|
resultsPath,
|
||||||
RAW_RESULTS_PAGE_SIZE
|
RAW_RESULTS_PAGE_SIZE
|
||||||
);
|
);
|
||||||
return schemas['result-sets'];
|
return schemas['result-sets'];
|
||||||
@@ -460,7 +461,7 @@ export class InterfaceManager extends DisposableObject {
|
|||||||
(sortedResultsMap[k] = this.convertPathPropertiesToWebviewUris(v))
|
(sortedResultsMap[k] = this.convertPathPropertiesToWebviewUris(v))
|
||||||
);
|
);
|
||||||
|
|
||||||
const resultSetSchemas = await this.getResultSetSchemas(results);
|
const resultSetSchemas = await this.getResultSetSchemas(results, sorted ? selectedTable : '');
|
||||||
const resultSetNames = resultSetSchemas.map(schema => schema.name);
|
const resultSetNames = resultSetSchemas.map(schema => schema.name);
|
||||||
|
|
||||||
const schema = resultSetSchemas.find(
|
const schema = resultSetSchemas.find(
|
||||||
|
|||||||
Reference in New Issue
Block a user