mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-16 18:46:40 -05:00
Change default max table rows returned in notebook to 5000, make it user configurable (#4084)
This commit is contained in:
@@ -31,6 +31,11 @@
|
|||||||
"type": "boolean",
|
"type": "boolean",
|
||||||
"default": true,
|
"default": true,
|
||||||
"description": "%notebook.overrideEditorTheming.description%"
|
"description": "%notebook.overrideEditorTheming.description%"
|
||||||
|
},
|
||||||
|
"notebook.maxTableRows": {
|
||||||
|
"type": "number",
|
||||||
|
"default": 5000,
|
||||||
|
"description": "%notebook.maxTableRows.description%"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -3,8 +3,9 @@
|
|||||||
"description": "Defines the Data-procotol based Notebook contribution and many Notebook commands and contributions.",
|
"description": "Defines the Data-procotol based Notebook contribution and many Notebook commands and contributions.",
|
||||||
"notebook.configuration.title": "Notebook configuration",
|
"notebook.configuration.title": "Notebook configuration",
|
||||||
"notebook.pythonPath.description": "Local path to python installation used by Notebooks.",
|
"notebook.pythonPath.description": "Local path to python installation used by Notebooks.",
|
||||||
"notebook.sqlKernelEnabled.description": "Enable SQL kernel in notebook editor (Preview). Requires reloading this window to take effect",
|
"notebook.sqlKernelEnabled.description": "Enable SQL kernel in Notebook editor (Preview). Requires reloading this window to take effect",
|
||||||
"notebook.overrideEditorTheming.description": "Override editor default settings in the Notebook editor. Settings include background color, current line color and border",
|
"notebook.overrideEditorTheming.description": "Override editor default settings in the Notebook editor. Settings include background color, current line color and border",
|
||||||
|
"notebook.maxTableRows.description": "Maximum number of rows returned per table in the Notebook editor",
|
||||||
"notebook.command.new": "New Notebook",
|
"notebook.command.new": "New Notebook",
|
||||||
"notebook.command.open": "Open Notebook",
|
"notebook.command.open": "Open Notebook",
|
||||||
"notebook.analyzeJupyterNotebook": "Analyze in Notebook",
|
"notebook.analyzeJupyterNotebook": "Analyze in Notebook",
|
||||||
|
|||||||
@@ -13,15 +13,18 @@ import { IInstantiationService } from 'vs/platform/instantiation/common/instanti
|
|||||||
import Severity from 'vs/base/common/severity';
|
import Severity from 'vs/base/common/severity';
|
||||||
import * as Utils from 'sql/platform/connection/common/utils';
|
import * as Utils from 'sql/platform/connection/common/utils';
|
||||||
import { Deferred } from 'sql/base/common/promise';
|
import { Deferred } from 'sql/base/common/promise';
|
||||||
import { Disposable, IDisposable } from 'vs/base/common/lifecycle';
|
import { Disposable } from 'vs/base/common/lifecycle';
|
||||||
import { IErrorMessageService } from 'sql/platform/errorMessage/common/errorMessageService';
|
import { IErrorMessageService } from 'sql/platform/errorMessage/common/errorMessageService';
|
||||||
import { ConnectionProfile } from 'sql/platform/connection/common/connectionProfile';
|
import { ConnectionProfile } from 'sql/platform/connection/common/connectionProfile';
|
||||||
import { IConnectionProfile } from 'sql/platform/connection/common/interfaces';
|
import { IConnectionProfile } from 'sql/platform/connection/common/interfaces';
|
||||||
import { escape } from 'sql/base/common/strings';
|
import { escape } from 'sql/base/common/strings';
|
||||||
|
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
|
||||||
|
|
||||||
export const sqlKernel: string = localize('sqlKernel', 'SQL');
|
export const sqlKernel: string = localize('sqlKernel', 'SQL');
|
||||||
export const sqlKernelError: string = localize("sqlKernelError", "SQL kernel error");
|
export const sqlKernelError: string = localize("sqlKernelError", "SQL kernel error");
|
||||||
export const MAX_ROWS = 2000;
|
export const MAX_ROWS = 5000;
|
||||||
|
export const NotebookConfigSectionName = 'notebook';
|
||||||
|
export const MaxTableRowsConfigName = 'maxTableRows';
|
||||||
|
|
||||||
let sqlKernelSpec: nb.IKernelSpec = ({
|
let sqlKernelSpec: nb.IKernelSpec = ({
|
||||||
name: sqlKernel,
|
name: sqlKernel,
|
||||||
@@ -135,7 +138,8 @@ class SqlKernel extends Disposable implements nb.IKernel {
|
|||||||
|
|
||||||
constructor( @IConnectionManagementService private _connectionManagementService: IConnectionManagementService,
|
constructor( @IConnectionManagementService private _connectionManagementService: IConnectionManagementService,
|
||||||
@IInstantiationService private _instantiationService: IInstantiationService,
|
@IInstantiationService private _instantiationService: IInstantiationService,
|
||||||
@IErrorMessageService private _errorMessageService: IErrorMessageService) {
|
@IErrorMessageService private _errorMessageService: IErrorMessageService,
|
||||||
|
@IConfigurationService private _configurationService: IConfigurationService) {
|
||||||
super();
|
super();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -217,7 +221,7 @@ class SqlKernel extends Disposable implements nb.IKernel {
|
|||||||
// TODO verify this is "canonical" behavior
|
// TODO verify this is "canonical" behavior
|
||||||
let count = canRun ? ++this._executionCount : undefined;
|
let count = canRun ? ++this._executionCount : undefined;
|
||||||
|
|
||||||
this._future = new SQLFuture(this._queryRunner, count);
|
this._future = new SQLFuture(this._queryRunner, count, this._configurationService);
|
||||||
if (!canRun) {
|
if (!canRun) {
|
||||||
// Complete early
|
// Complete early
|
||||||
this._future.handleDone(new Error(localize('connectionRequired', 'A connection must be chosen to run notebook cells')));
|
this._future.handleDone(new Error(localize('connectionRequired', 'A connection must be chosen to run notebook cells')));
|
||||||
@@ -270,9 +274,17 @@ export class SQLFuture extends Disposable implements FutureInternal {
|
|||||||
private ioHandler: nb.MessageHandler<nb.IIOPubMessage>;
|
private ioHandler: nb.MessageHandler<nb.IIOPubMessage>;
|
||||||
private doneHandler: nb.MessageHandler<nb.IShellMessage>;
|
private doneHandler: nb.MessageHandler<nb.IShellMessage>;
|
||||||
private doneDeferred = new Deferred<nb.IShellMessage>();
|
private doneDeferred = new Deferred<nb.IShellMessage>();
|
||||||
|
private configuredMaxRows: number = MAX_ROWS;
|
||||||
|
|
||||||
constructor(private _queryRunner: QueryRunner, private _executionCount: number | undefined) {
|
constructor(private _queryRunner: QueryRunner, private _executionCount: number | undefined, private configurationService: IConfigurationService) {
|
||||||
super();
|
super();
|
||||||
|
let config = configurationService.getValue(NotebookConfigSectionName);
|
||||||
|
if (config) {
|
||||||
|
let maxRows = config[MaxTableRowsConfigName] ? config[MaxTableRowsConfigName] : undefined;
|
||||||
|
if (maxRows && maxRows > 0) {
|
||||||
|
this.configuredMaxRows = maxRows;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
get inProgress(): boolean {
|
get inProgress(): boolean {
|
||||||
@@ -337,7 +349,7 @@ export class SQLFuture extends Disposable implements FutureInternal {
|
|||||||
public handleBatchEnd(batch: BatchSummary): void {
|
public handleBatchEnd(batch: BatchSummary): void {
|
||||||
if (this.ioHandler) {
|
if (this.ioHandler) {
|
||||||
for (let resultSet of batch.resultSetSummaries) {
|
for (let resultSet of batch.resultSetSummaries) {
|
||||||
let rowCount = resultSet.rowCount > MAX_ROWS ? MAX_ROWS : resultSet.rowCount;
|
let rowCount = resultSet.rowCount > this.configuredMaxRows ? this.configuredMaxRows : resultSet.rowCount;
|
||||||
this._queryRunner.getQueryRows(0, rowCount, resultSet.batchId, resultSet.id).then(d => {
|
this._queryRunner.getQueryRows(0, rowCount, resultSet.batchId, resultSet.id).then(d => {
|
||||||
|
|
||||||
let msg: nb.IIOPubMessage = {
|
let msg: nb.IIOPubMessage = {
|
||||||
|
|||||||
Reference in New Issue
Block a user