Skip to content

Commit

Permalink
clickhouse: extract more time types as string
Browse files Browse the repository at this point in the history
hoping clickhouse implicitly converts strings to date/time on insert
  • Loading branch information
serprex committed Feb 12, 2024
1 parent 2ab1609 commit 46d0d56
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions flow/connectors/clickhouse/normalize.go
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ func (c *ClickhouseConnector) NormalizeRecords(ctx context.Context, req *model.N
if err != nil {
return nil, fmt.Errorf("error while converting column type to clickhouse type: %w", err)
}
if clickhouseType == "DateTime64(6)" {
if clickhouseType == "DateTime64(6)" || clickhouseType == "Date" || clickhouseType == "TIMESTAMP" {
clickhouseType = "String"
}

Expand All @@ -166,7 +166,7 @@ func (c *ClickhouseConnector) NormalizeRecords(ctx context.Context, req *model.N

// add _peerdb_sign as _peerdb_record_type / 2
projection.WriteString(fmt.Sprintf("intDiv(_peerdb_record_type, 2) AS `%s`,", signColName))
colSelector.WriteString(fmt.Sprintf("%s,", signColName))
colSelector.WriteString(fmt.Sprintf("`%s`,", signColName))

// add _peerdb_timestamp as _peerdb_version
projection.WriteString(fmt.Sprintf("_peerdb_timestamp AS `%s`", versionColName))
Expand Down

0 comments on commit 46d0d56

Please sign in to comment.