You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@arrow.apache.org by cu...@apache.org on 2024/10/02 01:55:04 UTC

(arrow-adbc) branch main updated: feat(go/adbc/driver/snowflake): add support for a client config file (#2197)

This is an automated email from the ASF dual-hosted git repository.

curth pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/arrow-adbc.git


The following commit(s) were added to refs/heads/main by this push:
     new d4163d94c feat(go/adbc/driver/snowflake): add support for a client config file (#2197)
d4163d94c is described below

commit d4163d94ce50d91b649fb50fe33d58e772bf0c54
Author: davidhcoe <13...@users.noreply.github.com>
AuthorDate: Tue Oct 1 21:54:59 2024 -0400

    feat(go/adbc/driver/snowflake): add support for a client config file (#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 <co...@umich.edu>
---
 docs/source/driver/snowflake.rst               |  4 ++++
 go/adbc/driver/snowflake/driver.go             |  2 ++
 go/adbc/driver/snowflake/driver_test.go        | 14 ++++++++++++++
 go/adbc/driver/snowflake/snowflake_database.go |  4 ++++
 4 files changed, 24 insertions(+)

diff --git a/docs/source/driver/snowflake.rst b/docs/source/driver/snowflake.rst
index cd33b3646..260254ee9 100644
--- a/docs/source/driver/snowflake.rst
+++ b/docs/source/driver/snowflake.rst
@@ -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
 
diff --git a/go/adbc/driver/snowflake/driver.go b/go/adbc/driver/snowflake/driver.go
index 5dd29ab43..cc1f9c80b 100644
--- a/go/adbc/driver/snowflake/driver.go
+++ b/go/adbc/driver/snowflake/driver.go
@@ -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"
diff --git a/go/adbc/driver/snowflake/driver_test.go b/go/adbc/driver/snowflake/driver_test.go
index e56ce179a..d4a12a6cd 100644
--- a/go/adbc/driver/snowflake/driver_test.go
+++ b/go/adbc/driver/snowflake/driver_test.go
@@ -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)
+}
diff --git a/go/adbc/driver/snowflake/snowflake_database.go b/go/adbc/driver/snowflake/snowflake_database.go
index 581d9733e..ed203d85b 100644
--- a/go/adbc/driver/snowflake/snowflake_database.go
+++ b/go/adbc/driver/snowflake/snowflake_database.go
@@ -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
@@ -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: