Skip to content

Commit

Permalink
[Snowflake] Fixing DSN for custom host (#62)
Browse files Browse the repository at this point in the history
  • Loading branch information
Tang8330 authored Mar 7, 2023
1 parent ec33415 commit 1c601b4
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
11 changes: 9 additions & 2 deletions clients/snowflake/snowflake.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,14 +105,21 @@ func (s *Store) Merge(ctx context.Context, tableData *optimization.TableData) er
}

func (s *Store) ReestablishConnection(ctx context.Context) {
dsn, err := gosnowflake.DSN(&gosnowflake.Config{
cfg := &gosnowflake.Config{
Account: config.GetSettings().Config.Snowflake.AccountID,
User: config.GetSettings().Config.Snowflake.Username,
Password: config.GetSettings().Config.Snowflake.Password,
Warehouse: config.GetSettings().Config.Snowflake.Warehouse,
Region: config.GetSettings().Config.Snowflake.Region,
})
}

if config.GetSettings().Config.Snowflake.Host != "" {
// If the host is specified
cfg.Host = config.GetSettings().Config.Snowflake.Host
cfg.Region = ""
}

dsn, err := gosnowflake.DSN(cfg)
if err != nil {
logger.FromContext(ctx).Fatalf("failed to get snowflake dsn, err: %v", err)
}
Expand Down
1 change: 1 addition & 0 deletions lib/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ type Config struct {
Password string `yaml:"password"`
Warehouse string `yaml:"warehouse"`
Region string `yaml:"region"`
Host string `yaml:"host"`
}

Reporting struct {
Expand Down

0 comments on commit 1c601b4

Please sign in to comment.