From a23376cb6e23dac7b3c7b445cdaaa370abcef3f2 Mon Sep 17 00:00:00 2001 From: Robin Tang Date: Wed, 31 May 2023 12:49:56 -0700 Subject: [PATCH] Snowflake to use TIMESTAMP with TIME ZONE instead of TIMESTAMP_NTZ (#111) --- lib/typing/snowflake.go | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/lib/typing/snowflake.go b/lib/typing/snowflake.go index 771f04036..3571e2146 100644 --- a/lib/typing/snowflake.go +++ b/lib/typing/snowflake.go @@ -1,8 +1,9 @@ package typing import ( - "github.com/artie-labs/transfer/lib/typing/ext" "strings" + + "github.com/artie-labs/transfer/lib/typing/ext" ) type SnowflakeKind string @@ -82,7 +83,11 @@ func kindToSnowflake(kindDetails KindDetails) string { case ETime.Kind: switch kindDetails.ExtendedTimeDetails.Type { case ext.DateTimeKindType: - return "datetime" + // We are not using `TIMESTAMP_NTZ` because Snowflake does not join on this data very well. + // It ends up trying to parse this data into a TIMESTAMP_TZ and messes with the join order. + // Specifically, if my location is in SF, it'll try to parse TIMESTAMP_NTZ into PST then into UTC. + // When it was already stored as UTC. + return "timestamp_tz" case ext.DateKindType: return "date" case ext.TimeKindType: