Skip to content

Commit

Permalink
Deprecate createAllColumnsIfAvailable setting (#786)
Browse files Browse the repository at this point in the history
  • Loading branch information
Tang8330 authored Jul 15, 2024
1 parent 57979a9 commit c7d15c9
Show file tree
Hide file tree
Showing 4 changed files with 1 addition and 22 deletions.
9 changes: 0 additions & 9 deletions lib/config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,10 @@ func TestSharedTransferConfig(t *testing.T) {
validBody := `
typingSettings:
additionalDateFormats: ["yyyy-MM-dd1"]
createAllColumnsIfAvailable: true
`
err := yaml.Unmarshal([]byte(validBody), &sharedTransferCfg)
assert.NoError(t, err)

assert.True(t, sharedTransferCfg.TypingSettings.CreateAllColumnsIfAvailable)
assert.Equal(t, "yyyy-MM-dd1", sharedTransferCfg.TypingSettings.AdditionalDateFormats[0])
}
}
Expand Down Expand Up @@ -372,12 +370,6 @@ snowflake:
warehouse: %s
region: %s
application: %s
sharedTransferConfig:
typingSettings:
createAllColumnsIfAvailable: true
reporting:
sentry:
dsn: %s
Expand All @@ -396,7 +388,6 @@ reporting:
assert.Equal(t, bootstrapServer, config.Kafka.BootstrapServer)
assert.Equal(t, groupID, config.Kafka.GroupID)
assert.Equal(t, password, config.Kafka.Password)
assert.True(t, config.SharedTransferConfig.TypingSettings.CreateAllColumnsIfAvailable)

orderIdx := -1
customerIdx := -1
Expand Down
5 changes: 0 additions & 5 deletions lib/typing/parse.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,6 @@ import (
)

func ParseValue(settings Settings, key string, optionalSchema map[string]KindDetails, val any) KindDetails {
if val == nil && !settings.CreateAllColumnsIfAvailable {
// If the value is nil and `createAllColumnsIfAvailable` = false, then return `Invalid
return Invalid
}

if len(optionalSchema) > 0 {
// If the column exists in the schema, let's early exit.
if kindDetail, isOk := optionalSchema[key]; isOk {
Expand Down
4 changes: 1 addition & 3 deletions lib/typing/parse_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import (

func Test_ParseValue(t *testing.T) {
{

// Invalid
assert.Equal(t, ParseValue(Settings{}, "", nil, nil), Invalid)
assert.Equal(t, ParseValue(Settings{}, "", nil, errors.New("hello")), Invalid)
Expand Down Expand Up @@ -135,7 +134,6 @@ func TestOptionalSchema(t *testing.T) {
// Respect the schema if the value is not null.
assert.Equal(t, String, ParseValue(Settings{}, "created_at", optionalSchema, "2023-01-01"))
// Kind is invalid because `createAllColumnsIfAvailable` is not enabled.
assert.Equal(t, Invalid, ParseValue(Settings{}, "created_at", optionalSchema, nil))
assert.Equal(t, String, ParseValue(Settings{CreateAllColumnsIfAvailable: true}, "created_at", optionalSchema, nil))
assert.Equal(t, String, ParseValue(Settings{}, "created_at", optionalSchema, nil))
}
}
5 changes: 0 additions & 5 deletions lib/typing/typing.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,6 @@ import (

type Settings struct {
AdditionalDateFormats []string `yaml:"additionalDateFormats"`

// CreateAllColumnsIfAvailable - If true, we will create all columns if the metadata is available regardless of
// whether we have a value from the column. This will also bypass our Typing library.
// This only works for data sources with a schema such as Postgres and MySQL
CreateAllColumnsIfAvailable bool `yaml:"createAllColumnsIfAvailable"`
}

type KindDetails struct {
Expand Down

0 comments on commit c7d15c9

Please sign in to comment.