From 27787ed5cc4dcf2f9f44b468899fb46f5d56daf6 Mon Sep 17 00:00:00 2001 From: Kaushik Iska Date: Wed, 28 Jun 2023 10:45:20 -0400 Subject: [PATCH] match case to what it is on snowflake (prior to quoting) (#172) --- flow/connectors/snowflake/qrep_avro_sync.go | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/flow/connectors/snowflake/qrep_avro_sync.go b/flow/connectors/snowflake/qrep_avro_sync.go index 6015872db7..18a22ead89 100644 --- a/flow/connectors/snowflake/qrep_avro_sync.go +++ b/flow/connectors/snowflake/qrep_avro_sync.go @@ -242,6 +242,19 @@ func GenerateMergeCommand( tempTableName string, dstTable string, ) (string, error) { + // all cols are acquired from snowflake schema, so let us try to make upsert key cols match the case + // and also the watermark col, then the quoting should be fine + caseMatchedCols := map[string]string{} + for _, col := range allCols { + caseMatchedCols[strings.ToLower(col)] = col + } + + for i, col := range upsertKeyCols { + upsertKeyCols[i] = caseMatchedCols[strings.ToLower(col)] + } + + watermarkCol = caseMatchedCols[strings.ToLower(watermarkCol)] + upsertKeys := []string{} partitionKeyCols := []string{} for _, key := range upsertKeyCols {