Skip to content

Commit

Permalink
Clean up.
Browse files Browse the repository at this point in the history
  • Loading branch information
Tang8330 committed Apr 26, 2024
1 parent 2de85e7 commit 7bfb2c0
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
9 changes: 6 additions & 3 deletions clients/snowflake/writes.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import (
"fmt"
"log/slog"

"github.com/artie-labs/transfer/lib/sql"

"github.com/artie-labs/transfer/clients/shared"
"github.com/artie-labs/transfer/lib/destination/types"
"github.com/artie-labs/transfer/lib/logger"
Expand Down Expand Up @@ -52,9 +54,10 @@ func (s *Store) Merge(tableData *optimization.TableData) error {
}

var additionalEqualityStrings []string
if len(tableData.TopicConfig.AdditionalMergeColumns) > 0 {
for _, additionalMergeCol := range tableData.TopicConfig.AdditionalMergeColumns {
additionalEqualityStrings = append(additionalEqualityStrings, fmt.Sprintf("c.%s = cc.%s", additionalMergeCol, additionalMergeCol))
if len(tableData.TopicConfig().AdditionalMergePredicates) > 0 {
for _, additionalMergePredicate := range tableData.TopicConfig().AdditionalMergePredicates {
mergePredicateColumn := sql.EscapeName(additionalMergePredicate.PartitionField, s.ShouldUppercaseEscapedNames(), s.Label())
additionalEqualityStrings = append(additionalEqualityStrings, fmt.Sprintf("c.%s = cc.%s", mergePredicateColumn, mergePredicateColumn))
}
}

Expand Down
4 changes: 4 additions & 0 deletions lib/kafkalib/partition/settings.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ var ValidPartitionBy = []string{
"daily",
}

type MergePredicates struct {
PartitionField string
}

type BigQuerySettings struct {
PartitionType string `yaml:"partitionType" json:"partitionType"`
PartitionField string `yaml:"partitionField" json:"partitionField"`
Expand Down
2 changes: 1 addition & 1 deletion lib/kafkalib/topic.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ type TopicConfig struct {
IncludeArtieUpdatedAt bool `yaml:"includeArtieUpdatedAt"`
IncludeDatabaseUpdatedAt bool `yaml:"includeDatabaseUpdatedAt"`
BigQueryPartitionSettings *partition.BigQuerySettings `yaml:"bigQueryPartitionSettings,omitempty"`
AdditionalMergeColumns []string `yaml:"additionalMergeColumns,omitempty"`
AdditionalMergePredicates []partition.MergePredicates `yaml:"additionalMergePredicates,omitempty"`

// Internal metadata
opsToSkipMap map[string]bool `yaml:"-"`
Expand Down

0 comments on commit 7bfb2c0

Please sign in to comment.