From 071871f46ad61a8c8f71ba99f9f39dc02ab77049 Mon Sep 17 00:00:00 2001 From: Edward Smart Date: Thu, 4 Dec 2025 14:35:23 -0700 Subject: [PATCH 1/2] Parsing out precision date types --- internal/pkg/object/command/clickhouse/column_types.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/internal/pkg/object/command/clickhouse/column_types.go b/internal/pkg/object/command/clickhouse/column_types.go index aa655d7..83e0fd0 100644 --- a/internal/pkg/object/command/clickhouse/column_types.go +++ b/internal/pkg/object/command/clickhouse/column_types.go @@ -139,6 +139,14 @@ func unwrapCHType(t string) (base string, nullable bool) { if isDecimal(s) { return "Decimal", nullable } + // DateTime64(precision) or DateTime64(precision, 'timezone') normalize to "DateTime64" + if strings.HasPrefix(s, "DateTime64(") { + return "DateTime64", nullable + } + // DateTime('timezone') normalize to "DateTime" + if strings.HasPrefix(s, "DateTime(") { + return "DateTime", nullable + } return s, nullable } From a655eaf095eac4ba4ec74b79bd8b1cd08c9108b3 Mon Sep 17 00:00:00 2001 From: Edward Smart Date: Thu, 4 Dec 2025 15:33:05 -0700 Subject: [PATCH 2/2] Lowercase fix --- .../pkg/object/command/clickhouse/column_types.go | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/internal/pkg/object/command/clickhouse/column_types.go b/internal/pkg/object/command/clickhouse/column_types.go index 83e0fd0..c982c96 100644 --- a/internal/pkg/object/command/clickhouse/column_types.go +++ b/internal/pkg/object/command/clickhouse/column_types.go @@ -139,12 +139,16 @@ func unwrapCHType(t string) (base string, nullable bool) { if isDecimal(s) { return "Decimal", nullable } - // DateTime64(precision) or DateTime64(precision, 'timezone') normalize to "DateTime64" - if strings.HasPrefix(s, "DateTime64(") { + // Normalize type names to handle case variations from driver + // Driver may return "Datetime64" or "DateTime64", etc. + sLower := strings.ToLower(s) + + // DateTime64 always has precision: DateTime64(3) or DateTime64(6, 'UTC') + if strings.HasPrefix(sLower, "datetime64(") { return "DateTime64", nullable } - // DateTime('timezone') normalize to "DateTime" - if strings.HasPrefix(s, "DateTime(") { + // DateTime may have timezone or not: DateTime or DateTime('UTC') + if sLower == "datetime" || strings.HasPrefix(sLower, "datetime(") { return "DateTime", nullable } return s, nullable