Skip to content

Commit

Permalink
Merge branch 'master' into nv/kill-column-rawname
Browse files Browse the repository at this point in the history
  • Loading branch information
nathan-artie authored May 2, 2024
2 parents 7b8b7ea + 2291477 commit e3dceaf
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 4 deletions.
5 changes: 1 addition & 4 deletions clients/snowflake/snowflake.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,10 +128,7 @@ func (s *Store) reestablishConnection() error {
}

func (s *Store) generateDedupeQueries(tableID, stagingTableID types.TableIdentifier, primaryKeys []string, topicConfig kafkalib.TopicConfig) []string {
var primaryKeysEscaped []string
for _, pk := range primaryKeys {
primaryKeysEscaped = append(primaryKeysEscaped, s.Dialect().QuoteIdentifier(pk))
}
primaryKeysEscaped := sql.QuoteIdentifiers(primaryKeys, s.Dialect())

orderColsToIterate := primaryKeysEscaped
if topicConfig.IncludeArtieUpdatedAt {
Expand Down
8 changes: 8 additions & 0 deletions lib/sql/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,11 @@ import (
func QuoteLiteral(value string) string {
return fmt.Sprintf("'%s'", strings.ReplaceAll(stringutil.EscapeBackslashes(value), "'", `\'`))
}

func QuoteIdentifiers(identifiers []string, dialect Dialect) []string {
result := make([]string, len(identifiers))
for i, identifier := range identifiers {
result[i] = dialect.QuoteIdentifier(identifier)
}
return result
}
5 changes: 5 additions & 0 deletions lib/sql/util_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,8 @@ func TestQuoteLiteral(t *testing.T) {
assert.Equal(t, testCase.expected, QuoteLiteral(testCase.colVal), testCase.name)
}
}

func TestQuoteIdentifiers(t *testing.T) {
assert.Equal(t, []string{}, QuoteIdentifiers([]string{}, BigQueryDialect{}))
assert.Equal(t, []string{"`a`", "`b`", "`c`"}, QuoteIdentifiers([]string{"a", "b", "c"}, BigQueryDialect{}))
}

0 comments on commit e3dceaf

Please sign in to comment.