From afafee844ce2b07eb55bdb6f40ee1ce88c0bbf4e Mon Sep 17 00:00:00 2001 From: Alan Ren Date: Tue, 28 Mar 2023 21:34:38 -0700 Subject: [PATCH] fix notebook serialization issue for non-mssql providers (#22504) * use mssql as notebook serialization provider * comment * use fallback --- .../platform/serialization/common/serializationService.ts | 6 ++++++ .../notebook/browser/outputs/gridOutput.component.ts | 7 +++++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/sql/platform/serialization/common/serializationService.ts b/src/sql/platform/serialization/common/serializationService.ts index be33078ca0..cb4335f9fb 100644 --- a/src/sql/platform/serialization/common/serializationService.ts +++ b/src/sql/platform/serialization/common/serializationService.ts @@ -49,6 +49,8 @@ export interface ISerializationService { hasProvider(): boolean; + isProviderRegistered(providerId: string): boolean; + saveAs(saveFormat: string, savePath: string, results: string, appendToFile: boolean): Thenable; disabledSaveAs(): Thenable; @@ -75,6 +77,10 @@ export class SerializationService implements ISerializationService { ) { } + public isProviderRegistered(providerId: string): boolean { + return this.providers.find(provider => provider.providerId.toUpperCase() === providerId.toUpperCase()) !== undefined; + } + public registerProvider(providerId: string, provider: azdata.SerializationProvider): void { this.providers.push({ providerId: providerId, provider: provider }); } diff --git a/src/sql/workbench/contrib/notebook/browser/outputs/gridOutput.component.ts b/src/sql/workbench/contrib/notebook/browser/outputs/gridOutput.component.ts index 0aed970cbb..62fc08074f 100644 --- a/src/sql/workbench/contrib/notebook/browser/outputs/gridOutput.component.ts +++ b/src/sql/workbench/contrib/notebook/browser/outputs/gridOutput.component.ts @@ -487,10 +487,13 @@ export class DataResourceDataProvider implements IGridDataProvider { let connProviders = this.cellModel.notebookModel.getApplicableConnectionProviderIds(this.cellModel.notebookModel.selectedKernelDisplayName); if (connProviders?.length > 0) { provider = connProviders[0]; - } else { - provider = mssqlProviderName; } } + if (!provider || !this._serializationService.isProviderRegistered(provider)) { + // Serializing notebook query results to file is agnostic of database engine since the data is already available in the notebook. + // If the provider doesn't have its own serializer we can let the mssql provider handle it. + provider = mssqlProviderName; + } let formatSpecificParams = serializer.getBasicSaveParameters(format); let formatAgnosticParams = >{ serializationProviderId: provider,