Clickhouse 查询问题解决: int 类型判断等于0无结果

234 阅读1分钟

问题描述

现有一张表, 两个字段:

id String,
num UInt64

数据如下:

id    num
a     123
b     0
c     123    

执行找出 num 为 0 的查询,结果可能会为空:

select * from test_table where num = 0

解决方案

num 修改为 toUInt64(num), 如下:

select * from test_table where toUInt64(num) = 0

原因猜测

数据库存储为空,但查询时没有进行类型转换。

End!!