Skip to content

Connect to Snowflake and Databricks from ggsql with Workbench managed credentials - #17577

Merged
juliasilge merged 10 commits into
mainfrom
data-connections/snowflake-workbench-ggsql
Dec 4, 2026
Merged

juliasilge merged 10 commits into
mainfrom
data-connections/snowflake-workbench-ggsql

Conversation

@juliasilge

@juliasilge juliasilge commented Dec 1, 2026 •

Copy link
Copy Markdown
Member

On Posit Workbench, Data Connections can now generate ggsql connection code for Snowflake and Databricks connections that use Workbench managed credentials. Connect With > ggsql writes a -- @connect: odbc://... line. The line names the ODBC driver and the account or workspace. It does not contain a token. ggsql adds the Workbench token when it connects, so the token never shows in the console, and the line stays the same when Workbench rotates the token.

  • Snowflake works with ggsql 0.5.2. The Workbench Managed Credentials mechanism gets a line, and the detected workbench row from connections.toml gets one too, with the warehouse, database, schema, and role from that entry.
  • Databricks needs Use Posit Workbench managed credentials for Databricks and Snowflake ODBC connections ggsql#625, which adds the Databricks token to ggsql. The driver offers ggsql only when the preferred ggsql runtime is version 0.5.3 or later. This minimum is the constant GGSQL_DATABRICKS_TOKEN_VERSION, to update when the ggsql release is known.
  • ODBC driver: the line uses the Posit Pro Drivers library path when it exists, then it tries the vendor install paths, and then the registered name.

API change

DataConnectionDriver in positron.d.ts gets an optional getSupportedLanguageIds(mechanismId, parameters) method. It gives the languages that one connection can generate code for. Before, Connect With showed every driver language on every row. A row with no code for a language reported "Could not generate connection code". A saved connection with a stored secret first asked whether to include its secrets, and then failed.

Now the menu, the agent getConnectionCode command, and the connections catalog offer only the languages that each connection supports. Drivers that do not implement the method work as before. The menu waits for the driver for 500 ms at most. After that, it uses the last answer from the driver for that connection, or every declared language. Snowflake and Databricks implement the method. As a result, connections.toml rows and Databricks OAuth machine-to-machine connections no longer offer R, because they have no R code.

ggsqlOdbc.ts is copied into both drivers, and extensions/ggsqlOdbc-copies.vitest.ts keeps the two copies identical.

Known limits

  • A Databricks ggsql session fails when the Workbench token expires, after about an hour, because ggsql does not reconnect yet. A follow-up in ggsql can add the reconnect. Snowflake sessions continue to work.
  • The line needs the Posit Pro Drivers, the vendor ODBC driver, or a driver registered as Snowflake or Databricks. Workbench images include the Pro Drivers.

Release Notes

New Features

Bug Fixes

  • N/A

Validation Steps

@:connections @:workbench-snowflake @:workbench-databricks

On Posit Workbench, start a session with Snowflake and Databricks managed credentials and the ggsql extension.

  1. In the Data Connections pane, add a Snowflake connection with Workbench Managed Credentials. Select Connect With > ggsql and run the code. Open a .sql file on the connection, and run SELECT CURRENT_ROLE(); with Cmd+Enter. Expected: a ggsql console shows one row. A second statement uses the same console.
  2. Do step 1 again from the detected workbench row. Expected: the same line and the same console.
  3. Look at the console history. Expected: no Token=.
  4. Open Connect With on a Snowflake PAT connection, and on a connections.toml row other than workbench. Expected: no ggsql item. The connections.toml row has no R item.
  5. With ggsql 0.5.2, open Connect With on a Databricks connection with Workbench Managed Credentials. Expected: no ggsql item. With a ggsql that includes Use Posit Workbench managed credentials for Databricks and Snowflake ODBC connections ggsql#625, do step 1 for Databricks with SELECT current_catalog();.
  6. On desktop, open Connect With on a Snowflake or Databricks connection. Expected: no ggsql item.

@github-actions

github-actions Bot commented Dec 1, 2026

Copy link
Copy Markdown
Contributor

E2E Tests 🚀
This PR will run tests tagged with: @:critical @:connections @:workbench-snowflake @:workbench-databricks

Why these tags?
Tag Source
@:critical Always runs (required)
@:connections PR description
@:workbench-snowflake PR description
@:workbench-databricks PR description

More on automatic tags from changed files.

Test count: Linux: 103 tests.

readme  valid tags

Comment on lines +173 to +175
* TODO: set this to the ggsql release that ships posit-dev/ggsql#625, if it is not 0.5.3.
*/
const GGSQL_DATABRICKS_TOKEN_VERSION: readonly [number, number, number] = [0, 5, 3];

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@thomasp85, what will be the next release of ggsql? 0.5.3 or something else?

@thomasp85

Copy link
Copy Markdown
Contributor

0.6.0 in all likelihood

@juliasilge

juliasilge commented Dec 2, 2026 •

Copy link
Copy Markdown
Member Author

I got this all tested today in a Workbench build with dev ggsql from posit-dev/ggsql#625. All working!

Screenshot 2026-12-01 at 5 51 35 PM

@thomasp85, I set us up to require 0.6.0 for the Databricks Workbench token in 5cc84bb so let me know if that needs to change after you do the actual release.

@juliasilge
juliasilge marked this pull request as ready for review December 2, 2026 00:57

@samclark2015 samclark2015 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great! One real issue inline re: ggsql discovery, plus a nit.

Also consider updating the PR description from 0.5.3 -> 0.6.0, and possibly waiting to merge until that version is pinned down, if it's not already.

* @param version The `languageVersion` of the preferred ggsql runtime, or undefined when there is none.
*/
export function ggsqlAddsDatabricksToken(version: string | undefined): boolean {
if (version === undefined) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think undefined here covers two cases: ggsql isn't installed, or the ggsql extension is installed but hasn't registered its runtime yet.

In the second case, someone with ggsql 0.5.2 who opens Connect With right after startup gets offered ggsql, and the line can't sign in. We could avoid this by waiting for discovery, but extensions have no API for that.

Could we use the ggsql extension being installed as the signal? Something like:

export function ggsqlAddsDatabricksToken(version: string | undefined, ggsqlExtensionInstalled: boolean): boolean {
	if (version === undefined) {
		return !ggsqlExtensionInstalled;
	}
	...
}

with ggsqlExtensionInstalled being the result of vscode.extensions.getExtension('ggsql.ggsql') !== undefined. During discovery it hides ggsql until the next menu open, and a truly missing ggsql still gets the Not Installed dialog.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch, thank you! I made this change in b926fa2. When the ggsql extension is installed but its runtime is not registered yet, the driver does not offer ggsql. Connect With asks the driver again each time it opens, so ggsql shows when the runtime registers. When no ggsql extension is installed, the driver still offers ggsql, so Connect shows the dialog that tells the user to install it.

I didn't use the extension version as the ggsql version since it is possible for the extension to run a ggsql kernel from ggsql.kernelPath, a Jupyter kernelspec, the PATH, etc (so the runtime version can be different from the extension version).

* The driver's last answer to getSupportedLanguageIds for each connection (keyed by mechanism and
* parameter values), used when the driver is slow or fails.
*/
private readonly _lastSupportedLanguageIds = new Map<string, string[]>();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: interrupts constructor's docstring. Consider moving above.

@juliasilge

Copy link
Copy Markdown
Member Author

I think this is now ready to go but I do want to confirm the next release version from @thomasp85.

Right now, this PR uses 0.6.0; is that still what the plan is for the release before next week?

@juliasilge

Copy link
Copy Markdown
Member Author

I have just tested out this PR one more time with ggsql main and everything still looks good!

Screenshot 2026-12-04 at 12 49 18 PM

@juliasilge
juliasilge merged commit 5a182fc into main Dec 4, 2026
18 checks passed
@juliasilge
juliasilge deleted the data-connections/snowflake-workbench-ggsql branch December 4, 2026 19:52
@github-actions github-actions Bot locked and limited conversation to collaborators Dec 4, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants