Skip to content

Commit e068de3

Browse files
authored
(fix go/snowflake) fix deprecated usage of client session keep alive (#100)
1 parent a79555b commit e068de3

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

go/adbc/driver/snowflake/driver.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,8 @@ const (
9292
OptionAuthToken = "adbc.snowflake.sql.client_option.auth_token"
9393
// specify the OKTAUrl to use for OKTA Authentication
9494
OptionAuthOktaUrl = "adbc.snowflake.sql.client_option.okta_url"
95-
// enable the session to persist even after the connection is closed
95+
// Enable a heartbeat in the background to keep the connection session alive.
96+
// Uses the client_session_keep_alive DSN parameter internally.
9697
OptionKeepSessionAlive = "adbc.snowflake.sql.client_option.keep_session_alive"
9798
// specify the RSA private key to use to sign the JWT
9899
// this should point to a file containing a PKCS1 private key to be

go/adbc/driver/snowflake/snowflake_database.go

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ func (d *databaseImpl) GetOption(key string) (string, error) {
135135
case OptionAuthOktaUrl:
136136
return d.cfg.OktaURL.String(), nil
137137
case OptionKeepSessionAlive:
138-
if d.cfg.KeepSessionAlive {
138+
if v, ok := d.cfg.Params["client_session_keep_alive"]; ok && v != nil && strings.ToLower(*v) == adbc.OptionValueEnabled {
139139
return adbc.OptionValueEnabled, nil
140140
}
141141
return adbc.OptionValueDisabled, nil
@@ -362,12 +362,14 @@ func (d *databaseImpl) SetOptionInternal(k string, v string, cnOptions *map[stri
362362
case OptionKeepSessionAlive:
363363
switch v {
364364
case adbc.OptionValueEnabled:
365-
d.cfg.KeepSessionAlive = true
365+
trueValue := adbc.OptionValueEnabled
366+
d.cfg.Params["client_session_keep_alive"] = &trueValue
366367
case adbc.OptionValueDisabled:
367-
d.cfg.KeepSessionAlive = false
368+
falseValue := adbc.OptionValueDisabled
369+
d.cfg.Params["client_session_keep_alive"] = &falseValue
368370
default:
369371
return adbc.Error{
370-
Msg: fmt.Sprintf("Invalid value for database option '%s': '%s'", OptionSSLSkipVerify, v),
372+
Msg: fmt.Sprintf("Invalid value for database option '%s': '%s'", OptionKeepSessionAlive, v),
371373
Code: adbc.StatusInvalidArgument,
372374
}
373375
}

0 commit comments

Comments
 (0)