Skip to content

Commit

Permalink
feat(go/adbc/driver/snowflake): add support for a client config file (a…
Browse files Browse the repository at this point in the history
…pache#2197)

Adds a new option to set a client config file to set
https://github.com/snowflakedb/gosnowflake/blob/a26ac8a1b9a0dda854ac5db9c2c145f79d5ac4c0/doc.go#L130
as a driver option.

---------

Co-authored-by: David Coe <[email protected]>
  • Loading branch information
davidhcoe and David Coe authored Oct 2, 2024
1 parent b230493 commit d4163d9
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 0 deletions.
4 changes: 4 additions & 0 deletions docs/source/driver/snowflake.rst
Original file line number Diff line number Diff line change
Expand Up @@ -446,6 +446,10 @@ These options map 1:1 with the Snowflake `Config object <https://pkg.go.dev/gith
disabled by setting this to ``true``. Value should be either ``true``
or ``false``.

``adbc.snowflake.sql.client_option.config_file``
Specifies the location of the client configuration JSON file. See the
[Snowflake Go docs](https://github.com/snowflakedb/gosnowflake/blob/a26ac8a1b9a0dda854ac5db9c2c145f79d5ac4c0/doc.go#L130) for more details.

``adbc.snowflake.sql.client_option.tracing``
Set the logging level

Expand Down
2 changes: 2 additions & 0 deletions go/adbc/driver/snowflake/driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,8 @@ const (
OptionDisableTelemetry = "adbc.snowflake.sql.client_option.disable_telemetry"
// snowflake driver logging level
OptionLogTracing = "adbc.snowflake.sql.client_option.tracing"
// snowflake driver client logging config file
OptionClientConfigFile = "adbc.snowflake.sql.client_option.config_file"
// When true, the MFA token is cached in the credential manager. True by default
// on Windows/OSX, false for Linux
OptionClientRequestMFAToken = "adbc.snowflake.sql.client_option.cache_mfa_token"
Expand Down
14 changes: 14 additions & 0 deletions go/adbc/driver/snowflake/driver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2144,3 +2144,17 @@ func (suite *SnowflakeTests) TestChangeDatabaseAndGetObjects() {
_, err2 := suite.cnxn.GetObjects(suite.ctx, adbc.ObjectDepthAll, &newCatalog, &cfg.Schema, &getObjectsTable, nil, nil)
suite.NoError(err2)
}

func (suite *SnowflakeTests) TestGetSetClientConfigFile() {
file := "fileNameJustForTest.json"
options := map[string]string{
driver.OptionClientConfigFile: file,
}
getSetDB, ok := suite.db.(adbc.GetSetOptions)
suite.True(ok)
err := suite.db.SetOptions(options)
suite.NoError(err)
result, err := getSetDB.GetOption(driver.OptionClientConfigFile)
suite.NoError(err)
suite.True(file == result)
}
4 changes: 4 additions & 0 deletions go/adbc/driver/snowflake/snowflake_database.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,8 @@ func (d *databaseImpl) GetOption(key string) (string, error) {
return adbc.OptionValueDisabled, nil
case OptionLogTracing:
return d.cfg.Tracing, nil
case OptionClientConfigFile:
return d.cfg.ClientConfigFile, nil
case OptionUseHighPrecision:
if d.useHighPrecision {
return adbc.OptionValueEnabled, nil
Expand Down Expand Up @@ -415,6 +417,8 @@ func (d *databaseImpl) SetOptions(cnOptions map[string]string) error {
}
case OptionLogTracing:
d.cfg.Tracing = v
case OptionClientConfigFile:
d.cfg.ClientConfigFile = v
case OptionUseHighPrecision:
switch v {
case adbc.OptionValueEnabled:
Expand Down

0 comments on commit d4163d9

Please sign in to comment.