Skip to content

Commit

Permalink
add support for a client config file
Browse files Browse the repository at this point in the history
  • Loading branch information
David Coe committed Sep 27, 2024
1 parent f2b5f8d commit 0dad82a
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 0 deletions.
3 changes: 3 additions & 0 deletions docs/source/driver/snowflake.rst
Original file line number Diff line number Diff line change
Expand Up @@ -446,6 +446,9 @@ 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.

``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 0dad82a

Please sign in to comment.