Notebook fixes: Fix #4129, fix #4116, Fix #3913, fix empty results error (#4150)

- Fixes #4129 Overlapping command help windows in notebook
  - Do not show parameter hints for inactive cells, to avoid them hanging around when no longer selected
- Fixes #4116 Notebooks: Intellisense Doesn't Work using Add New Connection
  - Move connect/disconnect logic to 1 place (code component) instead of 2
  - Handle the case where you connect after choosing active cell. We now hook to the event and update connection
- Fix issues in sql session manager where result outputs 0 rows. This was failing to show the empty resultset contents, which is a regression vs. query editor. It also put unhandled error on the debug console
- Fix #3913 Notebook: words selected in other cells should be unselected on cell change

Note: after fix, now looks as follows. Need to do follow up to get correct grid min height

![image](https://user-images.githubusercontent.com/10819925/53280226-9e629580-36cc-11e9-8f40-59cd913caeee.png)
This commit is contained in:
Kevin Cunnane
2019-02-25 10:52:07 -08:00
committed by GitHub
parent f2c9d968a4
commit 2ae369fbdb
4 changed files with 72 additions and 37 deletions

View File

@@ -5,7 +5,7 @@
'use strict';
import * as os from 'os';
import { nb, QueryExecuteSubsetResult, IDbColumn, BatchSummary, IResultMessage } from 'sqlops';
import { nb, QueryExecuteSubsetResult, IDbColumn, BatchSummary, IResultMessage, ResultSetSummary } from 'sqlops';
import { localize } from 'vs/nls';
import * as strings from 'vs/base/common/strings';
import { FutureInternal, ILanguageMagic } from 'sql/parts/notebook/models/modelInterfaces';
@@ -398,32 +398,51 @@ export class SQLFuture extends Disposable implements FutureInternal {
public handleBatchEnd(batch: BatchSummary): void {
if (this.ioHandler) {
this.handleMessage(strings.format(elapsedTimeLabel, batch.executionElapsed));
this.processResultSets(batch);
}
}
private async processResultSets(batch: BatchSummary): Promise<void> {
try {
for (let resultSet of batch.resultSetSummaries) {
let rowCount = resultSet.rowCount > this.configuredMaxRows ? this.configuredMaxRows : resultSet.rowCount;
this._queryRunner.getQueryRows(0, rowCount, resultSet.batchId, resultSet.id).then(d => {
let msg: nb.IIOPubMessage = {
channel: 'iopub',
type: 'iopub',
header: <nb.IHeader>{
msg_id: undefined,
msg_type: 'execute_result'
},
content: <nb.IExecuteResult>{
output_type: 'execute_result',
metadata: {},
execution_count: this._executionCount,
data: { 'application/vnd.dataresource+json': this.convertToDataResource(resultSet.columnInfo, d), 'text/html': this.convertToHtmlTable(resultSet.columnInfo, d) }
},
metadata: undefined,
parent_header: undefined
};
this.ioHandler.handle(msg);
});
await this.sendResultSetAsIOPub(rowCount, resultSet);
}
} catch (err) {
// TODO should we output this somewhere else?
console.log(`Error outputting result sets from Notebook query: ${err}`);
}
}
private async sendResultSetAsIOPub(rowCount: number, resultSet: ResultSetSummary): Promise<void> {
let subsetResult: QueryExecuteSubsetResult;
if (rowCount > 0) {
subsetResult = await this._queryRunner.getQueryRows(0, rowCount, resultSet.batchId, resultSet.id);
} else {
subsetResult = { message: '', resultSubset: { rowCount: 0, rows: [] }};
}
let msg: nb.IIOPubMessage = {
channel: 'iopub',
type: 'iopub',
header: <nb.IHeader>{
msg_id: undefined,
msg_type: 'execute_result'
},
content: <nb.IExecuteResult>{
output_type: 'execute_result',
metadata: {},
execution_count: this._executionCount,
data: {
'application/vnd.dataresource+json': this.convertToDataResource(resultSet.columnInfo, subsetResult),
'text/html': this.convertToHtmlTable(resultSet.columnInfo, subsetResult)
}
},
metadata: undefined,
parent_header: undefined
};
this.ioHandler.handle(msg);
}
setIOPubHandler(handler: nb.MessageHandler<nb.IIOPubMessage>): void {
this.ioHandler = handler;
}