From 87b118a4e74b5d4985df80d74227fbf0701cb31d Mon Sep 17 00:00:00 2001 From: Jaime Oliveira Date: Tue, 9 Jun 2026 11:55:37 +0100 Subject: [PATCH] feat(snowflake): use maximum VARCHAR length (128 MB) for string columns --- flow/model/qvalue/kind.go | 2 +- flow/shared/types/kind.go | 11 +++++++++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/flow/model/qvalue/kind.go b/flow/model/qvalue/kind.go index 001eb9a6d..e613d46ac 100644 --- a/flow/model/qvalue/kind.go +++ b/flow/model/qvalue/kind.go @@ -71,7 +71,7 @@ func ToDWHColumnType( } else if val, ok := types.QValueKindToSnowflakeTypeMap[kind]; ok { colType = val } else { - colType = "STRING" + colType = types.SnowflakeMaxVarchar } if nullableEnabled && !column.Nullable { colType += " NOT NULL" diff --git a/flow/shared/types/kind.go b/flow/shared/types/kind.go index 76a184dad..6e5992d0d 100644 --- a/flow/shared/types/kind.go +++ b/flow/shared/types/kind.go @@ -69,6 +69,13 @@ func (kind QValueKind) IsArray() bool { return strings.HasPrefix(string(kind), "array_") } +// SnowflakeMaxVarchar is the maximum VARCHAR length Snowflake allows (128 MB). +// A bare STRING/VARCHAR declaration defaults to 16 MB, so we specify the max +// explicitly to avoid silently capping string columns. Snowflake bills storage +// based on actual data stored and documents no performance difference between +// max-length and shorter VARCHAR declarations. +const SnowflakeMaxVarchar = "VARCHAR(134217728)" + var QValueKindToSnowflakeTypeMap = map[QValueKind]string{ QValueKindBoolean: "BOOLEAN", QValueKindInt8: "INTEGER", @@ -82,7 +89,7 @@ var QValueKindToSnowflakeTypeMap = map[QValueKind]string{ QValueKindFloat32: "FLOAT", QValueKindFloat64: "FLOAT", QValueKindQChar: "CHAR", - QValueKindString: "STRING", + QValueKindString: SnowflakeMaxVarchar, QValueKindEnum: "STRING", QValueKindUint16Enum: "INTEGER", QValueKindJSON: "VARIANT", @@ -95,7 +102,7 @@ var QValueKindToSnowflakeTypeMap = map[QValueKind]string{ QValueKindDate: "DATE", QValueKindBytes: "BINARY", QValueKindUUID: "STRING", - QValueKindInvalid: "STRING", + QValueKindInvalid: SnowflakeMaxVarchar, QValueKindHStore: "VARIANT", QValueKindGeography: "GEOGRAPHY", QValueKindGeometry: "GEOMETRY",