Repository navigation
Connect to Snowflake and Databricks from ggsql with Workbench managed credentials - #17577
Conversation
|
E2E Tests 🚀 Why these tags?
More on automatic tags from changed files. Test count: Linux: 103 tests. |
| * 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]; |
There was a problem hiding this comment.
@thomasp85, what will be the next release of ggsql? 0.5.3 or something else?
|
0.6.0 in all likelihood |
|
I got this all tested today in a Workbench build with dev ggsql from posit-dev/ggsql#625. All working!
@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. |
samclark2015
left a comment
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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[]>(); |
There was a problem hiding this comment.
Nit: interrupts constructor's docstring. Consider moving above.
|
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? |


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.workbenchrow fromconnections.tomlgets one too, with the warehouse, database, schema, and role from that entry.GGSQL_DATABRICKS_TOKEN_VERSION, to update when the ggsql release is known.API change
DataConnectionDriverinpositron.d.tsgets an optionalgetSupportedLanguageIds(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
getConnectionCodecommand, 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.tsis copied into both drivers, andextensions/ggsqlOdbc-copies.vitest.tskeeps the two copies identical.Known limits
SnowflakeorDatabricks. Workbench images include the Pro Drivers.Release Notes
New Features
Bug Fixes
Validation Steps
@:connections @:workbench-snowflake @:workbench-databricks
On Posit Workbench, start a session with Snowflake and Databricks managed credentials and the ggsql extension.
.sqlfile on the connection, and runSELECT CURRENT_ROLE();with Cmd+Enter. Expected: a ggsql console shows one row. A second statement uses the same console.workbenchrow. Expected: the same line and the same console.Token=.workbench. Expected: no ggsql item. The connections.toml row has no R item.SELECT current_catalog();.