Skip to content

Conversation

@petermueller
Copy link
Contributor

This leans on adbc client options for the URI creation and options, which in turn relies on the Snowflake Driver's upstream snowflakedb/gosnowflake library

leans more on [adbc client options](https://arrow.apache.org/adbc/current/driver/snowflake.html#client-options)
and Snowflake Driver's underlying `snowflakedb/gosnowflake` library
@petermueller
Copy link
Contributor Author

petermueller commented Aug 15, 2025

I have tested this extensively for the JWT approach, and is something needed in general since Snowflake is deprecating password-only sign-ins.

I tried to set it up such that other auth'n types from the adbc Snowflake Driver docs could be implemented, but don't have the setup for testing those.

Please let me know if there's any other testing you'd like to see.
The way to_attr and to_source works along with all the Vue bits feels quite messy, but I tried to keep things fairly "clean"-ish, although it feels like there could be a set of structs per adapter that would help here in future iterations/clean-ups.

Copy link
Member

@jonatanklosko jonatanklosko left a comment

Choose a reason for hiding this comment

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

One comment and we can ship it!

"adbc.snowflake.sql.db": "default",
"adbc.snowflake.sql.schema": "schema",
"adbc.snowflake.sql.warehouse": "",
"adbc.snowflake.sql.auth_type": "auth_snowflake",
Copy link
Member

Choose a reason for hiding this comment

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

We should have a test for the code generated with auth_jwt as well :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Will do 😊

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Pushed!


assert ConnectionCell.to_source(put_in(attrs["type"], "snowflake")) == ~s'''
:ok = Adbc.download_driver!(:snowflake)
uri = "admin:pass@account/default/schema"
Copy link
Member

Choose a reason for hiding this comment

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

Btw, the URI can include parameters, so perhaps we could do ?warehouse={warehouse} (docs)? This way we can keep it as a URI, which is more condensed.

Copy link
Contributor Author

@petermueller petermueller Aug 15, 2025

Choose a reason for hiding this comment

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

There seems to be a bug upstream where if you provide adbc a URI and options related to other auth types, it will fail and claim that you need to provide a password. Interestingly, if you provide a dummy password in the URI, it will still connect.

This actually was the cause of a lot of this investigation, as I was previously converting the cell to source and then modifying it.

It seems that in adbc, the URI parsing is passed directly to the gosnowflake library (this was referenced in a closed issue as well, I'm on mobile but can edit once I find it, edit: this comment).

I read through a bunch of the gosnowflake code and I'm not sure if it's in that library or a combination of that library and it's usage in adbc, but if we build the URI ourselves then a lot of the auth options have to use undocumented query parameter names and values that aren't on the adbc documentation or the gosnowflake documentation.

I would also prefer building the URI ourselves, but mixing the adbc options in makes it difficult to consistently support and it seems like they are parsing the URI to get those options and then reconstructing it anyway so it seemed to me that the better option was to just use the options directly and remove the URI building in this library

Copy link
Member

Choose a reason for hiding this comment

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

Got it, sounds good then!

Copy link
Member

@jonatanklosko jonatanklosko left a comment

Choose a reason for hiding this comment

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

Thanks!

@jonatanklosko jonatanklosko merged commit 7b6457a into livebook-dev:main Aug 15, 2025
2 checks passed
@petermueller petermueller deleted the snowflake-more-auth branch August 15, 2025 19:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants