mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-01-23 17:23:02 -05:00
Notebooks: Remove result set summary from saved metadata (#13616)
* remove result set summary from metadata * remove batchId and id from celloutputmetadata * remove extra line
This commit is contained in:
@@ -28,11 +28,15 @@ import { ICommandService } from 'vs/platform/commands/common/commands';
|
||||
import { tryMatchCellMagic, extractCellMagicCommandPlusArgs } from 'sql/workbench/services/notebook/browser/utils';
|
||||
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
|
||||
import { Disposable } from 'vs/base/common/lifecycle';
|
||||
import { ResultSetSummary } from 'sql/workbench/services/query/common/query';
|
||||
|
||||
let modelId = 0;
|
||||
const ads_execute_command = 'ads_execute_command';
|
||||
|
||||
export interface QueryResultId {
|
||||
batchId: number;
|
||||
id: number;
|
||||
}
|
||||
|
||||
export class CellModel extends Disposable implements ICellModel {
|
||||
public id: string;
|
||||
|
||||
@@ -43,6 +47,7 @@ export class CellModel extends Disposable implements ICellModel {
|
||||
private _cellGuid: string;
|
||||
private _future: FutureInternal;
|
||||
private _outputs: nb.ICellOutput[] = [];
|
||||
private _outputsIdMap: Map<nb.ICellOutput, QueryResultId> = new Map<nb.ICellOutput, QueryResultId>();
|
||||
private _renderedOutputTextContent: string[] = [];
|
||||
private _isEditMode: boolean;
|
||||
private _onOutputsChanged = new Emitter<IOutputChangedEvent>();
|
||||
@@ -238,6 +243,7 @@ export class CellModel extends Disposable implements ICellModel {
|
||||
this._cellType = type;
|
||||
// Regardless, get rid of outputs; this matches Jupyter behavior
|
||||
this._outputs = [];
|
||||
this._outputsIdMap.clear();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -515,6 +521,7 @@ export class CellModel extends Disposable implements ICellModel {
|
||||
try {
|
||||
// Need to reset outputs here (kernels do this on their own)
|
||||
this._outputs = [];
|
||||
this._outputsIdMap.clear();
|
||||
let commandExecuted = this._commandService?.executeCommand(result.commandId, result.args);
|
||||
// This will ensure that the run button turns into a stop button
|
||||
this.fireExecutionStateChanged();
|
||||
@@ -608,6 +615,7 @@ export class CellModel extends Disposable implements ICellModel {
|
||||
|
||||
public clearOutputs(): void {
|
||||
this._outputs = [];
|
||||
this._outputsIdMap.clear();
|
||||
this.fireOutputsChanged();
|
||||
|
||||
this.executionCount = undefined;
|
||||
@@ -634,6 +642,10 @@ export class CellModel extends Disposable implements ICellModel {
|
||||
return this._outputs;
|
||||
}
|
||||
|
||||
public getOutputId(output: nb.ICellOutput): QueryResultId | undefined {
|
||||
return this._outputsIdMap.get(output);
|
||||
}
|
||||
|
||||
public get renderedOutputTextContent(): string[] {
|
||||
return this._renderedOutputTextContent;
|
||||
}
|
||||
@@ -662,17 +674,19 @@ export class CellModel extends Disposable implements ICellModel {
|
||||
// Check if the table already exists
|
||||
for (let i = 0; i < this._outputs.length; i++) {
|
||||
if (this._outputs[i].output_type === 'execute_result') {
|
||||
let resultSet: ResultSetSummary = this._outputs[i].metadata.resultSet;
|
||||
let newResultSet: ResultSetSummary = output.metadata.resultSet;
|
||||
if (resultSet.batchId === newResultSet.batchId && resultSet.id === newResultSet.id) {
|
||||
let currentOutputId: QueryResultId = this._outputsIdMap.get(this._outputs[i]);
|
||||
if (currentOutputId.batchId === (<QueryResultId>msg.metadata).batchId
|
||||
&& currentOutputId.id === (<QueryResultId>msg.metadata).id) {
|
||||
// If it does, update output with data resource and html table
|
||||
(<nb.IExecuteResult>this._outputs[i]).data = (<nb.IExecuteResult>output).data;
|
||||
this._outputs[i].metadata = output.metadata;
|
||||
added = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!added) {
|
||||
this._outputsIdMap.set(output, { batchId: (<QueryResultId>msg.metadata).batchId, id: (<QueryResultId>msg.metadata).id });
|
||||
}
|
||||
break;
|
||||
case 'execute_result_update':
|
||||
let update = msg.content as nb.IExecuteResultUpdate;
|
||||
|
||||
@@ -22,6 +22,7 @@ import { NotebookModel } from 'sql/workbench/services/notebook/browser/models/no
|
||||
import { IModelContentChangedEvent } from 'vs/editor/common/model/textModelEvents';
|
||||
import type { FutureInternal } from 'sql/workbench/services/notebook/browser/interfaces';
|
||||
import { ICellValue, ResultSetSummary } from 'sql/workbench/services/query/common/query';
|
||||
import { QueryResultId } from 'sql/workbench/services/notebook/browser/models/cell';
|
||||
|
||||
export interface ICellRange {
|
||||
readonly start: number;
|
||||
@@ -469,6 +470,7 @@ export interface ICellModel {
|
||||
executionCount: number | undefined;
|
||||
readonly future: FutureInternal;
|
||||
readonly outputs: ReadonlyArray<nb.ICellOutput>;
|
||||
getOutputId(output: nb.ICellOutput): QueryResultId | undefined;
|
||||
renderedOutputTextContent?: string[];
|
||||
readonly onOutputsChanged: Event<IOutputChangedEvent>;
|
||||
readonly onTableUpdated: Event<ITableUpdatedEvent>;
|
||||
|
||||
@@ -597,13 +597,14 @@ export class SQLFuture extends Disposable implements FutureInternal {
|
||||
},
|
||||
content: <nb.IExecuteResult>{
|
||||
output_type: 'execute_result',
|
||||
metadata: {
|
||||
resultSet: resultSet
|
||||
},
|
||||
metadata: undefined,
|
||||
execution_count: this._executionCount,
|
||||
data: data
|
||||
},
|
||||
metadata: undefined,
|
||||
metadata: {
|
||||
batchId: resultSet.batchId,
|
||||
id: resultSet.id
|
||||
},
|
||||
parent_header: undefined
|
||||
};
|
||||
this.ioHandler.handle(msg);
|
||||
|
||||
Reference in New Issue
Block a user