Skip to content

Commit cdd15d8

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 57724e8 commit cdd15d8

1 file changed

Lines changed: 26 additions & 20 deletions

File tree

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

Lines changed: 26 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ export class CompareView extends AbstractWebview<
144144
panel.reveal(undefined, true);
145145

146146
await this.waitForPanelLoaded();
147-
const { currentResultSetDisplayName, fromResultSet, toResultSet } =
147+
const { currentResultSetDisplayName, fromResultSetName, toResultSetName } =
148148
await this.findResultSetsToCompare(
149149
this.comparePair,
150150
selectedResultSetName,
@@ -153,7 +153,11 @@ export class CompareView extends AbstractWebview<
153153
let result: RawQueryCompareResult | undefined;
154154
let message: string | undefined;
155155
try {
156-
result = this.compareResults(fromResultSet, toResultSet);
156+
result = await this.compareResults(
157+
this.comparePair,
158+
fromResultSetName,
159+
toResultSetName,
160+
);
157161
} catch (e) {
158162
message = getErrorMessage(e);
159163
}
@@ -230,7 +234,7 @@ export class CompareView extends AbstractWebview<
230234
}
231235

232236
private async findResultSetsToCompare(
233-
{ from, fromInfo, to, toInfo, commonResultSetNames }: ComparePair,
237+
{ fromInfo, toInfo, commonResultSetNames }: ComparePair,
234238
selectedResultSetName: string | undefined,
235239
) {
236240
const { currentResultSetDisplayName, fromResultSetName, toResultSetName } =
@@ -241,20 +245,10 @@ export class CompareView extends AbstractWebview<
241245
selectedResultSetName,
242246
);
243247

244-
const fromResultSet = await this.getResultSet(
245-
fromInfo.schemas,
246-
fromResultSetName,
247-
from.completedQuery.query.resultsPaths.resultsPath,
248-
);
249-
const toResultSet = await this.getResultSet(
250-
toInfo.schemas,
251-
toResultSetName,
252-
to.completedQuery.query.resultsPaths.resultsPath,
253-
);
254248
return {
255249
currentResultSetDisplayName,
256-
fromResultSet,
257-
toResultSet,
250+
fromResultSetName,
251+
toResultSetName,
258252
};
259253
}
260254

@@ -276,12 +270,24 @@ export class CompareView extends AbstractWebview<
276270
return await this.cliServer.bqrsDecode(resultsPath, resultSetName);
277271
}
278272

279-
private compareResults(
280-
fromResults: DecodedBqrsChunk,
281-
toResults: DecodedBqrsChunk,
282-
): RawQueryCompareResult {
273+
private async compareResults(
274+
{ from, fromInfo, to, toInfo }: ComparePair,
275+
fromResultSetName: string,
276+
toResultSetName: string,
277+
): Promise<RawQueryCompareResult> {
278+
const fromResultSet = await this.getResultSet(
279+
fromInfo.schemas,
280+
fromResultSetName,
281+
from.completedQuery.query.resultsPaths.resultsPath,
282+
);
283+
const toResultSet = await this.getResultSet(
284+
toInfo.schemas,
285+
toResultSetName,
286+
to.completedQuery.query.resultsPaths.resultsPath,
287+
);
288+
283289
// Only compare columns that have the same name
284-
return resultsDiff(fromResults, toResults);
290+
return resultsDiff(fromResultSet, toResultSet);
285291
}
286292

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

0 commit comments

Comments
 (0)