Skip to content

Commit

Permalink
compartmentalize code a bit
Browse files Browse the repository at this point in the history
  • Loading branch information
serprex committed Dec 2, 2024
1 parent 4e40bb2 commit a93243c
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions flow/connectors/clickhouse/normalize.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,6 @@ func getColName(overrides map[string]string, name string) string {
}

func getClickhouseTypeForNumericColumn(ctx context.Context, column *protos.FieldDescription, env map[string]string) (string, error) {
rawPrecision, _ := datatypes.ParseNumericTypmod(column.TypeModifier)
if column.TypeModifier == -1 {
numericAsStringEnabled, err := peerdbenv.PeerDBEnableClickHouseNumericAsString(ctx, env)
if err != nil {
Expand All @@ -91,12 +90,11 @@ func getClickhouseTypeForNumericColumn(ctx context.Context, column *protos.Field
if numericAsStringEnabled {
return "String", nil
}
precision, scale := datatypes.GetNumericTypeForWarehouse(column.TypeModifier, datatypes.ClickHouseNumericCompatibility{})
return fmt.Sprintf("Decimal(%d, %d)", precision, scale), nil
}

if rawPrecision > datatypes.PeerDBClickHouseMaxPrecision {
return "String", nil
} else {
rawPrecision, _ := datatypes.ParseNumericTypmod(column.TypeModifier)
if rawPrecision > datatypes.PeerDBClickHouseMaxPrecision {
return "String", nil
}
}
precision, scale := datatypes.GetNumericTypeForWarehouse(column.TypeModifier, datatypes.ClickHouseNumericCompatibility{})
return fmt.Sprintf("Decimal(%d, %d)", precision, scale), nil
Expand Down

0 comments on commit a93243c

Please sign in to comment.