diff --git a/sqlconnect/db.go b/sqlconnect/db.go index fbe7bed..d63aeb8 100644 --- a/sqlconnect/db.go +++ b/sqlconnect/db.go @@ -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 diff --git a/sqlconnect/internal/base/db.go b/sqlconnect/internal/base/db.go index 8272507..0b80f09 100644 --- a/sqlconnect/internal/base/db.go +++ b/sqlconnect/internal/base/db.go @@ -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{}, @@ -19,7 +19,6 @@ func NewDB(db *sql.DB, rudderSchema string, opts ...Option) *DB { jsonRowMapper: func(databaseTypeName string, value any) any { return value }, - rudderSchema: rudderSchema, sqlCommands: SQLCommands{ CreateSchema: func(schema string) string { return fmt.Sprintf("CREATE SCHEMA IF NOT EXISTS %[1]s", schema) }, ListSchemas: func() (string, string) { @@ -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 diff --git a/sqlconnect/internal/base/schemaadmin.go b/sqlconnect/internal/base/schemaadmin.go index 25ec9d2..03ef583 100644 --- a/sqlconnect/internal/base/schemaadmin.go +++ b/sqlconnect/internal/base/schemaadmin.go @@ -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 { diff --git a/sqlconnect/internal/bigquery/config.go b/sqlconnect/internal/bigquery/config.go index 27463c0..3428381 100644 --- a/sqlconnect/internal/bigquery/config.go +++ b/sqlconnect/internal/bigquery/config.go @@ -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 diff --git a/sqlconnect/internal/bigquery/db.go b/sqlconnect/internal/bigquery/db.go index b5e0e96..bd7979b 100644 --- a/sqlconnect/internal/bigquery/db.go +++ b/sqlconnect/internal/bigquery/db.go @@ -16,8 +16,7 @@ import ( ) const ( - DatabaseType = "bigquery" - defaultRudderSchema = "rudderstack_" + DatabaseType = "bigquery" ) // NewDB creates a new bigquery db client @@ -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)), diff --git a/sqlconnect/internal/databricks/config.go b/sqlconnect/internal/databricks/config.go index a794dbc..db233e3 100644 --- a/sqlconnect/internal/databricks/config.go +++ b/sqlconnect/internal/databricks/config.go @@ -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 { diff --git a/sqlconnect/internal/databricks/db.go b/sqlconnect/internal/databricks/db.go index 3b5876e..c3d28f6 100644 --- a/sqlconnect/internal/databricks/db.go +++ b/sqlconnect/internal/databricks/db.go @@ -13,8 +13,7 @@ import ( ) const ( - DatabaseType = "databricks" - defaultRudderSchema = "_rudderstack" + DatabaseType = "databricks" ) // NewDB creates a new databricks db client @@ -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)), diff --git a/sqlconnect/internal/integration_test/db_integration_test_scenario.go b/sqlconnect/internal/integration_test/db_integration_test_scenario.go index 3b7eb96..f149439 100644 --- a/sqlconnect/internal/integration_test/db_integration_test_scenario.go +++ b/sqlconnect/internal/integration_test/db_integration_test_scenario.go @@ -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) diff --git a/sqlconnect/internal/mysql/config.go b/sqlconnect/internal/mysql/config.go index 187baa3..d39d22d 100644 --- a/sqlconnect/internal/mysql/config.go +++ b/sqlconnect/internal/mysql/config.go @@ -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) { diff --git a/sqlconnect/internal/mysql/db.go b/sqlconnect/internal/mysql/db.go index 70c8195..fd4057d 100644 --- a/sqlconnect/internal/mysql/db.go +++ b/sqlconnect/internal/mysql/db.go @@ -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 @@ -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 { diff --git a/sqlconnect/internal/postgres/config.go b/sqlconnect/internal/postgres/config.go index a0e6e07..12fd17a 100644 --- a/sqlconnect/internal/postgres/config.go +++ b/sqlconnect/internal/postgres/config.go @@ -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 { diff --git a/sqlconnect/internal/postgres/db.go b/sqlconnect/internal/postgres/db.go index 9352f6a..10962ad 100644 --- a/sqlconnect/internal/postgres/db.go +++ b/sqlconnect/internal/postgres/db.go @@ -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 @@ -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)), ), diff --git a/sqlconnect/internal/redshift/db.go b/sqlconnect/internal/redshift/db.go index aadf8b4..d80d6af 100644 --- a/sqlconnect/internal/redshift/db.go +++ b/sqlconnect/internal/redshift/db.go @@ -6,7 +6,6 @@ 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" @@ -14,8 +13,7 @@ import ( ) const ( - DatabaseType = "redshift" - defaultRudderSchema = "_rudderstack" + DatabaseType = "redshift" ) // NewDB creates a new redshift db client @@ -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 { diff --git a/sqlconnect/internal/snowflake/config.go b/sqlconnect/internal/snowflake/config.go index b122754..2f59423 100644 --- a/sqlconnect/internal/snowflake/config.go +++ b/sqlconnect/internal/snowflake/config.go @@ -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) { diff --git a/sqlconnect/internal/snowflake/db.go b/sqlconnect/internal/snowflake/db.go index 17f12ee..0ed4956 100644 --- a/sqlconnect/internal/snowflake/db.go +++ b/sqlconnect/internal/snowflake/db.go @@ -13,8 +13,7 @@ import ( ) const ( - DatabaseType = "snowflake" - defaultRudderSchema = "_RUDDERSTACK" + DatabaseType = "snowflake" ) // NewDB creates a new snowflake db client @@ -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)), diff --git a/sqlconnect/internal/trino/config.go b/sqlconnect/internal/trino/config.go index 728ede7..c2efdf4 100644 --- a/sqlconnect/internal/trino/config.go +++ b/sqlconnect/internal/trino/config.go @@ -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) { diff --git a/sqlconnect/internal/trino/db.go b/sqlconnect/internal/trino/db.go index 04a556f..2f67170 100644 --- a/sqlconnect/internal/trino/db.go +++ b/sqlconnect/internal/trino/db.go @@ -14,8 +14,7 @@ import ( ) const ( - DatabaseType = "trino" - defaultRudderSchema = "_rudderstack" + DatabaseType = "trino" ) // NewDB creates a new trino db client @@ -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 {