Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

clickhouse: specialize Date json extract #1260

Merged
merged 1 commit into from
Feb 12, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions flow/connectors/clickhouse/normalize.go
Original file line number Diff line number Diff line change
Expand Up @@ -161,12 +161,16 @@
clickhouseType = "String"
}

projection.WriteString(fmt.Sprintf("JSONExtract(_peerdb_data, '%s', '%s') AS `%s`,", cn, clickhouseType, cn))
if clickhouseType == "Date" {
projection.WriteString(fmt.Sprintf("toDate(parseDateTime64BestEffortOrNull(JSONExtractString(_peerdb_data, '%s'))) AS `%s`,", cn, cn))

Check failure on line 165 in flow/connectors/clickhouse/normalize.go

View workflow job for this annotation

GitHub Actions / lint

line is 150 characters (lll)
} else {
projection.WriteString(fmt.Sprintf("JSONExtract(_peerdb_data, '%s', '%s') AS `%s`,", cn, clickhouseType, cn))
}
}

// 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
Loading