Skip to content

Commit

Permalink
feat: add support to provide query_tag for snowflake connection (#188)
Browse files Browse the repository at this point in the history
# Description

Add support to provide `query_tag` in the connection parameters for
Snowflake.
[Documentation
Link](https://docs.snowflake.com/en/sql-reference/parameters#query-tag)

## Linear Ticket

[Linear
Task](https://linear.app/rudderstack/issue/PRO-3422/add-support-to-provide-query-tag-in-snowflake-connection-parameters)

## Security

- [x] The code changed/added as part of this pull request won't create
any security issues with how the software is being used.
  • Loading branch information
kuldeep0020 authored Sep 17, 2024
1 parent 9fd3a91 commit 27b3df9
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions sqlconnect/internal/snowflake/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,9 @@ type Config struct {

LoginTimeout time.Duration `json:"loginTimeout"` // default: 5m

KeepSessionAlive bool `json:"keepSessionAlive"`
UseLegacyMappings bool `json:"useLegacyMappings"`
KeepSessionAlive bool `json:"keepSessionAlive"`
UseLegacyMappings bool `json:"useLegacyMappings"`
QueryTag string `json:"queryTag"`
}

func (c Config) ConnectionString() (dsn string, err error) {
Expand All @@ -47,6 +48,7 @@ func (c Config) ConnectionString() (dsn string, err error) {
Role: c.Role,
Application: c.Application,
LoginTimeout: c.LoginTimeout,
Params: make(map[string]*string),
}

if c.UseKeyPairAuth {
Expand All @@ -59,10 +61,12 @@ func (c Config) ConnectionString() (dsn string, err error) {
}

if c.KeepSessionAlive {
params := make(map[string]*string)
valueTrue := "true"
params["client_session_keep_alive"] = &valueTrue
sc.Params = params
sc.Params["client_session_keep_alive"] = &valueTrue
}

if c.QueryTag != "" {
sc.Params["query_tag"] = &c.QueryTag
}

dsn, err = gosnowflake.DSN(&sc)
Expand Down

0 comments on commit 27b3df9

Please sign in to comment.