From a93243c009f5855137f398f73435845919e7000b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Philip=20Dub=C3=A9?= Date: Mon, 2 Dec 2024 16:35:54 +0000 Subject: [PATCH] compartmentalize code a bit --- flow/connectors/clickhouse/normalize.go | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/flow/connectors/clickhouse/normalize.go b/flow/connectors/clickhouse/normalize.go index dec9c396d..51bbf7c1e 100644 --- a/flow/connectors/clickhouse/normalize.go +++ b/flow/connectors/clickhouse/normalize.go @@ -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 { @@ -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