Skip to content

Commit

Permalink
chore: remove rudder schema
Browse files Browse the repository at this point in the history
  • Loading branch information
atzoum committed Mar 11, 2024
1 parent 9b259dc commit 00a18cd
Show file tree
Hide file tree
Showing 17 changed files with 14 additions and 58 deletions.
2 changes: 0 additions & 2 deletions sqlconnect/db.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,6 @@ type sqlDB interface {
type SchemaAdmin interface {
// CreateSchema creates a schema
CreateSchema(ctx context.Context, schema SchemaRef) error
// GetRudderSchema returns the name of the rudder schema
GetRudderSchema() string
// GetSchemas returns a list of schemas
ListSchemas(ctx context.Context) ([]SchemaRef, error)
// SchemaExists returns true if the schema exists
Expand Down
4 changes: 1 addition & 3 deletions sqlconnect/internal/base/db.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
"github.com/rudderlabs/sqlconnect-go/sqlconnect"
)

func NewDB(db *sql.DB, rudderSchema string, opts ...Option) *DB {
func NewDB(db *sql.DB, opts ...Option) *DB {
d := &DB{
DB: db,
Dialect: dialect{},
Expand All @@ -19,7 +19,6 @@ func NewDB(db *sql.DB, rudderSchema string, opts ...Option) *DB {
jsonRowMapper: func(databaseTypeName string, value any) any {
return value
},

Check warning on line 21 in sqlconnect/internal/base/db.go

View check run for this annotation

Codecov / codecov/patch

sqlconnect/internal/base/db.go#L17-L21

Added lines #L17 - L21 were not covered by tests
rudderSchema: rudderSchema,
sqlCommands: SQLCommands{
CreateSchema: func(schema string) string { return fmt.Sprintf("CREATE SCHEMA IF NOT EXISTS %[1]s", schema) },
ListSchemas: func() (string, string) {
Expand Down Expand Up @@ -69,7 +68,6 @@ type DB struct {
*sql.DB
sqlconnect.Dialect

rudderSchema string
columnTypeMapper func(ColumnType) string // map from database type to rudder type
jsonRowMapper func(databaseTypeName string, value any) any
sqlCommands SQLCommands
Expand Down
5 changes: 0 additions & 5 deletions sqlconnect/internal/base/schemaadmin.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,6 @@ import (
"github.com/rudderlabs/sqlconnect-go/sqlconnect"
)

// GetRudderSchema returns the name of the rudder schema
func (db *DB) GetRudderSchema() string {
return db.rudderSchema
}

// CreateSchema creates a schema
func (db *DB) CreateSchema(ctx context.Context, schema sqlconnect.SchemaRef) error {
if _, err := db.ExecContext(ctx, db.sqlCommands.CreateSchema(db.QuoteIdentifier(schema.Name))); err != nil {
Expand Down
4 changes: 1 addition & 3 deletions sqlconnect/internal/bigquery/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@ type Config struct {
ProjectID string `json:"project"`
CredentialsJSON string `json:"credentials"`

// RudderSchema is used to override the default rudder schema name during tests
RudderSchema string `json:"rudderSchema"`
UseLegacyMappings bool `json:"useLegacyMappings"`
UseLegacyMappings bool `json:"useLegacyMappings"`
}

// Parse parses the given JSON into the config
Expand Down
4 changes: 1 addition & 3 deletions sqlconnect/internal/bigquery/db.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@ import (
)

const (
DatabaseType = "bigquery"
defaultRudderSchema = "rudderstack_"
DatabaseType = "bigquery"
)

// NewDB creates a new bigquery db client
Expand All @@ -33,7 +32,6 @@ func NewDB(configJSON json.RawMessage) (*DB, error) {
return &DB{
DB: base.NewDB(
db,
lo.Ternary(config.RudderSchema != "", config.RudderSchema, defaultRudderSchema),
base.WithDialect(dialect{}),
base.WithColumnTypeMapper(getColumnTypeMapper(config)),
base.WithJsonRowMapper(getJonRowMapper(config)),
Expand Down
4 changes: 1 addition & 3 deletions sqlconnect/internal/databricks/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,7 @@ type Config struct {
MaxRetryWaitTime time.Duration `json:"maxRetryWaitTime"`
MaxConnIdleTime time.Duration `json:"maxConnIdleTime"`

// RudderSchema is used to override the default rudder schema name during tests
RudderSchema string `json:"rudderSchema"`
UseLegacyMappings bool `json:"useLegacyMappings"`
UseLegacyMappings bool `json:"useLegacyMappings"`
}

func (c *Config) Parse(configJson json.RawMessage) error {
Expand Down
4 changes: 1 addition & 3 deletions sqlconnect/internal/databricks/db.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@ import (
)

const (
DatabaseType = "databricks"
defaultRudderSchema = "_rudderstack"
DatabaseType = "databricks"
)

// NewDB creates a new databricks db client
Expand Down Expand Up @@ -48,7 +47,6 @@ func NewDB(configJson json.RawMessage) (*DB, error) {
return &DB{
DB: base.NewDB(
db,
lo.Ternary(config.RudderSchema != "", config.RudderSchema, defaultRudderSchema),
base.WithDialect(dialect{}),
base.WithColumnTypeMapper(getColumnTypeMapper(config)),
base.WithJsonRowMapper(getJonRowMapper(config)),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,6 @@ func TestDatabaseScenarios(t *testing.T, warehouse string, configJSON json.RawMe
})
})

t.Run("get rudder schema", func(t *testing.T) {
rudderSchema := db.GetRudderSchema()
require.Equal(t, schema.Name, rudderSchema, "it should be able to get the rudder schema")
})

t.Run("schema admin", func(t *testing.T) {
t.Run("schema doesn't exist", func(t *testing.T) {
exists, err := db.SchemaExists(ctx, schema)
Expand Down
4 changes: 1 addition & 3 deletions sqlconnect/internal/mysql/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,7 @@ type Config struct {

// SkipHostValidation is used to skip host validation during tests
SkipHostValidation bool `json:"skipHostValidation"`
// RudderSchema is used to override the default rudder schema name during tests
RudderSchema string `json:"rudderSchema"`
UseLegacyMappings bool `json:"useLegacyMappings"`
UseLegacyMappings bool `json:"useLegacyMappings"`
}

func (c Config) ConnectionString() (string, error) {
Expand Down
5 changes: 1 addition & 4 deletions sqlconnect/internal/mysql/db.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,13 @@ import (
"fmt"

_ "github.com/go-sql-driver/mysql" // mysql driver
"github.com/samber/lo"

"github.com/rudderlabs/sqlconnect-go/sqlconnect"
"github.com/rudderlabs/sqlconnect-go/sqlconnect/internal/base"
)

const (
DatabaseType = "mysql"
defaultRudderSchema = "_rudderstack"
DatabaseType = "mysql"
)

// NewDB creates a new mysql db client
Expand All @@ -37,7 +35,6 @@ func NewDB(configJSON json.RawMessage) (*DB, error) {
return &DB{
DB: base.NewDB(
db,
lo.Ternary(config.RudderSchema != "", config.RudderSchema, defaultRudderSchema),
base.WithColumnTypeMapper(getColumnTypeMapper(config)),
base.WithJsonRowMapper(getJonRowMapper(config)),
base.WithSQLCommandsOverride(func(cmds base.SQLCommands) base.SQLCommands {
Expand Down
4 changes: 1 addition & 3 deletions sqlconnect/internal/postgres/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,7 @@ type Config struct {

// SkipHostValidation is used to skip host validation during tests
SkipHostValidation bool `json:"skipHostValidation"`
// RudderSchema is used to override the default rudder schema name during tests
RudderSchema string `json:"rudderSchema"`
UseLegacyMappings bool `json:"useLegacyMappings"`
UseLegacyMappings bool `json:"useLegacyMappings"`
}

func (c Config) ConnectionString() string {
Expand Down
5 changes: 1 addition & 4 deletions sqlconnect/internal/postgres/db.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,13 @@ import (
"encoding/json"

_ "github.com/lib/pq" // postgres driver
"github.com/samber/lo"

"github.com/rudderlabs/sqlconnect-go/sqlconnect"
"github.com/rudderlabs/sqlconnect-go/sqlconnect/internal/base"
)

const (
DatabaseType = "postgres"
defaultRudderSchema = "_rudderstack"
DatabaseType = "postgres"
)

// NewDB creates a new postgres db client
Expand All @@ -32,7 +30,6 @@ func NewDB(credentialsJSON json.RawMessage) (*DB, error) {
return &DB{
DB: base.NewDB(
db,
lo.Ternary(config.RudderSchema != "", config.RudderSchema, defaultRudderSchema),
base.WithColumnTypeMappings(getColumnTypeMappings(config)),
base.WithJsonRowMapper(getJonRowMapper(config)),
),
Expand Down
5 changes: 1 addition & 4 deletions sqlconnect/internal/redshift/db.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,14 @@ import (
"fmt"

_ "github.com/lib/pq" // postgres driver
"github.com/samber/lo"

"github.com/rudderlabs/sqlconnect-go/sqlconnect"
"github.com/rudderlabs/sqlconnect-go/sqlconnect/internal/base"
"github.com/rudderlabs/sqlconnect-go/sqlconnect/internal/postgres"
)

const (
DatabaseType = "redshift"
defaultRudderSchema = "_rudderstack"
DatabaseType = "redshift"
)

// NewDB creates a new redshift db client
Expand All @@ -34,7 +32,6 @@ func NewDB(credentialsJSON json.RawMessage) (*DB, error) {
return &DB{
DB: base.NewDB(
db,
lo.Ternary(config.RudderSchema != "", config.RudderSchema, defaultRudderSchema),
base.WithColumnTypeMappings(getColumnTypeMappings(config)),
base.WithJsonRowMapper(getJonRowMapper(config)),
base.WithSQLCommandsOverride(func(cmds base.SQLCommands) base.SQLCommands {
Expand Down
6 changes: 2 additions & 4 deletions sqlconnect/internal/snowflake/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,8 @@ type Config struct {
Schema string `json:"schema"`
Role string `json:"role"`

// RudderSchema is used to override the default rudder schema name during tests
RudderSchema string `json:"rudderSchema"`
KeepSessionAlive bool `json:"keepSessionAlive"`
UseLegacyMappings bool `json:"useLegacyMappings"`
KeepSessionAlive bool `json:"keepSessionAlive"`
UseLegacyMappings bool `json:"useLegacyMappings"`
}

func (c Config) ConnectionString() (dsn string, err error) {
Expand Down
4 changes: 1 addition & 3 deletions sqlconnect/internal/snowflake/db.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@ import (
)

const (
DatabaseType = "snowflake"
defaultRudderSchema = "_RUDDERSTACK"
DatabaseType = "snowflake"
)

// NewDB creates a new snowflake db client
Expand All @@ -37,7 +36,6 @@ func NewDB(configJSON json.RawMessage) (*DB, error) {
return &DB{
DB: base.NewDB(
db,
lo.Ternary(config.RudderSchema != "", config.RudderSchema, defaultRudderSchema),
base.WithDialect(dialect{}),
base.WithColumnTypeMapper(getColumnTypeMapper(config)),
base.WithJsonRowMapper(getJonRowMapper(config)),
Expand Down
3 changes: 0 additions & 3 deletions sqlconnect/internal/trino/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,6 @@ type Config struct {
Catalog string `json:"catalog"`
User string `json:"user"`
Password string `json:"password"`

// RudderSchema is used to override the default rudder schema name during tests
RudderSchema string `json:"rudderSchema"`
}

func (c Config) ConnectionString() (string, error) {
Expand Down
4 changes: 1 addition & 3 deletions sqlconnect/internal/trino/db.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@ import (
)

const (
DatabaseType = "trino"
defaultRudderSchema = "_rudderstack"
DatabaseType = "trino"
)

// NewDB creates a new trino db client
Expand All @@ -38,7 +37,6 @@ func NewDB(configJSON json.RawMessage) (*DB, error) {
return &DB{
DB: base.NewDB(
db,
lo.Ternary(config.RudderSchema != "", config.RudderSchema, defaultRudderSchema),
base.WithColumnTypeMapper(columnTypeMapper),
base.WithJsonRowMapper(jsonRowMapper),
base.WithSQLCommandsOverride(func(cmds base.SQLCommands) base.SQLCommands {
Expand Down

0 comments on commit 00a18cd

Please sign in to comment.