Skip to content

Commit

Permalink
also add dsn for postgres
Browse files Browse the repository at this point in the history
  • Loading branch information
k-anshul committed Dec 28, 2024
1 parent df1006a commit 8b052d5
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion runtime/drivers/duckdb/model_executor_sqlstore_self.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ func (e *sqlStoreToSelfExecutor) modelInputProperties(modelName, inputConnector
if err := mapstructure.Decode(inputHandle.Config(), &config); err != nil {
return nil, err
}
dsn = config.DatabaseURL
dsn = config.ResolveDSN()
}
if dsn == "" {
return nil, fmt.Errorf("must set `dsn` for models that transfer data from `postgres` to `duckdb`")
Expand Down
8 changes: 8 additions & 0 deletions runtime/drivers/postgres/postgres.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,14 @@ type driver struct{}

type ConfigProperties struct {
DatabaseURL string `mapstructure:"database_url"`
DSN string `mapstructure:"dsn"`
}

func (c *ConfigProperties) ResolveDSN() string {
if c.DSN != "" {
return c.DSN
}
return c.DatabaseURL
}

func (d driver) Open(instanceID string, config map[string]any, st *storage.Client, ac *activity.Client, logger *zap.Logger) (drivers.Handle, error) {
Expand Down

0 comments on commit 8b052d5

Please sign in to comment.