Skip to content

Commit 13fc321

Browse files
committed
Read raw result sets in compareResults
This moves reading of the result sets to the `compareResults` method since raw result sets don't need to be read for interpreted results and the `findResultSetsToCompare` method is shared between the two types of results.
1 parent 21352da commit 13fc321

1 file changed

Lines changed: 27 additions & 21 deletions

File tree

extensions/ql-vscode/src/compare/compare-view.ts

Lines changed: 27 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -96,8 +96,8 @@ export class CompareView extends AbstractWebview<
9696
const {
9797
commonResultSetNames,
9898
currentResultSetDisplayName,
99-
fromResultSet,
100-
toResultSet,
99+
fromResultSetName,
100+
toResultSetName,
101101
} = await this.findResultSetsToCompare(
102102
this.comparePair,
103103
selectedResultSetName,
@@ -106,7 +106,11 @@ export class CompareView extends AbstractWebview<
106106
let result: RawQueryCompareResult | undefined;
107107
let message: string | undefined;
108108
try {
109-
result = this.compareResults(fromResultSet, toResultSet);
109+
result = await this.compareResults(
110+
this.comparePair,
111+
fromResultSetName,
112+
toResultSetName,
113+
);
110114
} catch (e) {
111115
message = getErrorMessage(e);
112116
}
@@ -200,7 +204,7 @@ export class CompareView extends AbstractWebview<
200204
}
201205

202206
private async findResultSetsToCompare(
203-
{ from, fromInfo, to, toInfo }: ComparePair,
207+
{ fromInfo, toInfo }: ComparePair,
204208
selectedResultSetName: string | undefined,
205209
) {
206210
const {
@@ -210,21 +214,11 @@ export class CompareView extends AbstractWebview<
210214
toResultSetName,
211215
} = await findResultSetNames(fromInfo, toInfo, selectedResultSetName);
212216

213-
const fromResultSet = await this.getResultSet(
214-
fromInfo.schemas,
215-
fromResultSetName,
216-
from.completedQuery.query.resultsPaths.resultsPath,
217-
);
218-
const toResultSet = await this.getResultSet(
219-
toInfo.schemas,
220-
toResultSetName,
221-
to.completedQuery.query.resultsPaths.resultsPath,
222-
);
223217
return {
224218
commonResultSetNames,
225219
currentResultSetDisplayName,
226-
fromResultSet,
227-
toResultSet,
220+
fromResultSetName,
221+
toResultSetName,
228222
};
229223
}
230224

@@ -246,12 +240,24 @@ export class CompareView extends AbstractWebview<
246240
return await this.cliServer.bqrsDecode(resultsPath, resultSetName);
247241
}
248242

249-
private compareResults(
250-
fromResults: DecodedBqrsChunk,
251-
toResults: DecodedBqrsChunk,
252-
): RawQueryCompareResult {
243+
private async compareResults(
244+
{ from, fromInfo, to, toInfo }: ComparePair,
245+
fromResultSetName: string,
246+
toResultSetName: string,
247+
): Promise<RawQueryCompareResult> {
248+
const fromResultSet = await this.getResultSet(
249+
fromInfo.schemas,
250+
fromResultSetName,
251+
from.completedQuery.query.resultsPaths.resultsPath,
252+
);
253+
const toResultSet = await this.getResultSet(
254+
toInfo.schemas,
255+
toResultSetName,
256+
to.completedQuery.query.resultsPaths.resultsPath,
257+
);
258+
253259
// Only compare columns that have the same name
254-
return resultsDiff(fromResults, toResults);
260+
return resultsDiff(fromResultSet, toResultSet);
255261
}
256262

257263
private async openQuery(kind: "from" | "to") {

0 commit comments

Comments
 (0)