apache / apache/arrow-adbc

go/adbc/driver/snowflake: option for session parameters

Open
#2,539 3 comments 0 reactions 0 assignees View on GitHub
Type: enhancement
Dominant language
C#
Stars
627
Forks
217
Avg merge
17h
Merged PRs (30d)
57

Description

### What feature or improvement would you like to see?

If using `adbc.OptionKeyURI` to provide the DSN, multiple session parameters can be specified:
https://arrow.apache.org/adbc/current/driver/snowflake.html#uri-format

However, the DSN option is only compatible to user/password authentication (`snowflake.OptionValueAuthSnowflake`) since it is ensured by calling `gosnowflake.ParseDSN` to necessarily contain both of these fields. In a scenario where the user requires other types of authentication that do not rely on passwords (e.g. private key), if they wish to specify session parameters, they would have to construct a DSN with "mocked" password values, and additionally provide the account, in order to successfully specify the parameters in URI query format. Then, use the options to provide the correct authentication.
Otherwise, the user sends `ALTER SESSION SET` to set all parameters.

Instead, the driver could accept [session parameters](https://docs.snowflake.com/en/sql-reference/parameters#session-parameters) as a new option e.g. `adbc.snowflake.sql.session_parameters` expecting an encoded URI query segment. For instance:

```go
sessionParams := url.Values{
"param1": {"value1"},
"param2": {"value2"},
}

db, err := drv.NewDatabase(map[string]string{
"snowflake.OptionSessionParameters": sessionParams.Encode(),
})
```

Then the driver can decode these values using [url.ParseQuery](https://pkg.go.dev/net/url#ParseQuery) and send the ALTER SESSION statement to set all session parameters, which saves the effort for the user.

Contributor guide

Open the contributing guide

Research direction

Start in the Go Snowflake driver by tracing drv.NewDatabase and how adbc.OptionKeyURI is parsed before authentication is selected. Review url.ParseQuery and the existing ALTER SESSION path; the work is done when a session-parameters option accepts the encoded query segment and applies its values without requiring password authentication.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
database
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.