R,ClickHouse:预期:FixedString(34)。得到:UInt64:处理时

R, ClickHouse: Expected: FixedString(34). Got: UInt64: While processing

我正在尝试使用子集从 R 的 ClickHouse 数据库中查询数据。 这是例子

library(data.table)
library(RClickhouse)
library(DBI)

subset <- paste(traffic[,unique(IDs)][1:30], collapse = ',')

conClickHouse <- DBI::dbConnect('here is the connection')


DataX <- dbgetdbGetQuery(conClickHouse, paste0("select * from database
                    and  IDs in (", subset ,") ", sep = "") )

结果我得到错误:

DB::Exception: Type mismatch in IN or VALUES section. Expected: FixedString(34). Got: UInt64: While processing (IDs IN ....

感谢任何帮助

感谢@DennyCrane 的评论,

"select * from database where toFixedString(IDs,34) in
     (toFixedString(ID1, 34), toFixedString(ID2,34 ))"

此查询子集正确

https://clickhouse.tech/docs/en/sql-reference/functions/#strong-typing

强类型

与标准 SQL 相比,ClickHouse 具有强类型。换句话说,它不会在类型之间进行隐式转换。每个函数都适用于一组特定的类型。这意味着有时您需要使用类型转换函数。

https://clickhouse.tech/docs/en/sql-reference/functions/type-conversion-functions/#tofixedstrings-n

select * from (select 'x' B ) where B in (select toFixedString('x',1))
DB::Exception: Types of column 1 in section IN don't match: String on the left, FixedString(1) on the right.

使用转换为 toString 或 toFixedString

select * 来自 (select 'x' B ) 其中 toFixedString(B,1) 在 (select toFixedString ('x',1))