Skip to content

Commit 0d5dc22

Browse files
committed
feat(db): update Clickhouse type handling for boolean and add checksum function for boolean fields
1 parent 564b059 commit 0d5dc22

2 files changed

Lines changed: 3 additions & 2 deletions

File tree

cmd/sling/sling_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -871,14 +871,14 @@ func runOneTask(t *testing.T, file g.FileItem, connType dbio.Type) {
871871
correctType = iop.DatetimeType // clickhouse uses datetime
872872
}
873873
if correctType == iop.BoolType {
874-
correctType = iop.TextType // clickhouse doesn't have bool
874+
correctType = iop.IntegerType // clickhouse bool is integer
875875
}
876876
if correctType == iop.JsonType {
877877
correctType = iop.TextType // clickhouse uses varchar(max) for json
878878
}
879879
case srcType == dbio.TypeDbClickhouse && tgtType == dbio.TypeDbPostgres:
880880
if correctType == iop.BoolType {
881-
correctType = iop.TextType // clickhouse doesn't have bool
881+
correctType = iop.IntegerType // clickhouse bool is integer
882882
}
883883
if correctType == iop.JsonType {
884884
correctType = iop.TextType // clickhouse uses varchar(max) for json

core/dbio/templates/clickhouse.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -262,6 +262,7 @@ function:
262262
checksum_datetime: toUnixTimestamp64Nano(toDateTime64({field}, 6)) / 1000
263263
# checksum_datetime: toUnixTimestamp64Nano(toDateTime64({field}, 6)) / 1000
264264
checksum_decimal: ABS(CAST({field} as Nullable(Int64)))
265+
checksum_boolean: length(case when {field} is null then '' when {field} > 0 then 'true' else 'false' end)
265266
now: now()
266267
cast_to_string: 'toString({field})'
267268

0 commit comments

Comments
 (0)