diff --git a/src/sql/workbench/contrib/notebook/browser/notebookActions.ts b/src/sql/workbench/contrib/notebook/browser/notebookActions.ts index ef63990038..fe566dbe76 100644 --- a/src/sql/workbench/contrib/notebook/browser/notebookActions.ts +++ b/src/sql/workbench/contrib/notebook/browser/notebookActions.ts @@ -457,8 +457,15 @@ export class AttachToDropdown extends SelectBox { try { // Get all providers to show all available connections in connection dialog let providers = this.model.getApplicableConnectionProviderIds(this.model.clientSession.kernel.name); - for (let alias of this.model.kernelAliases) { - providers = providers.concat(this.model.getApplicableConnectionProviderIds(alias)); + // Spark kernels are unable to get providers from above, therefore ensure that we get the + // correct providers for the selected kernel and load the proper connections for the connection dialog + // Example Scenario: Spark Kernels should only have MSSQL connections in connection dialog + if (!this.model.kernelAliases.includes(this.model.selectedKernelDisplayName) && this.model.clientSession.kernel.name !== 'SQL') { + providers = providers.concat(this.model.getApplicableConnectionProviderIds(this.model.selectedKernelDisplayName)); + } else { + for (let alias of this.model.kernelAliases) { + providers = providers.concat(this.model.getApplicableConnectionProviderIds(alias)); + } } let connection = await this._connectionDialogService.openDialogAndWait(this._connectionManagementService, { diff --git a/src/sql/workbench/services/notebook/browser/models/notebookModel.ts b/src/sql/workbench/services/notebook/browser/models/notebookModel.ts index d8a663f0f7..274af61249 100644 --- a/src/sql/workbench/services/notebook/browser/models/notebookModel.ts +++ b/src/sql/workbench/services/notebook/browser/models/notebookModel.ts @@ -658,8 +658,11 @@ export class NotebookModel extends Disposable implements INotebookModel { let providerFeatures = this._capabilitiesService.getCapabilities(profile.providerName); if (connectionProviderIds?.length) { this._currentKernelAlias = providerFeatures?.connection.notebookKernelAlias; - // Adds Kernel Alias and Connection Provider to Map if new Notebook connection contains notebookKernelAlias - if (this._currentKernelAlias) { + // Switching from Kusto to another kernel should set the currentKernelAlias to undefined + if (this._selectedKernelDisplayName !== this._currentKernelAlias && this._selectedKernelDisplayName) { + this._currentKernelAlias = undefined; + } else { + // Adds Kernel Alias and Connection Provider to Map if new Notebook connection contains notebookKernelAlias this._kernelDisplayNameToConnectionProviderIds.set(this._currentKernelAlias, [profile.providerName]); } }