我有一张table
CREATE TABLE table (
id Int32,
values Array(Tuple(LowCardinality(String), Int32)),
date Date
) ENGINE MergeTree()
PARTITION BY toYYYYMM(date)
ORDER BY (id, date)
但在执行请求时
SELECT count(*)
FROM table
WHERE (arrayExists(x -> ((x.1) = toLowCardinality('pattern')), values) = 1)
我出错了
Code: 49. DB::Exception: Received from clickhouse:9000. DB::Exception: Cannot capture column 3 because it has incompatible type: got String, but LowCardinality(String) is expected..
如果替换“values”列的值数组(tuple(string,int32)),则执行请求时不会出错。
使用数组(tuple(lowcardinality(string),int32))时会出现什么问题?
2条答案
按热度按时间zazmityj1#
在修复之前(请参见bug 7815),可以使用以下解决方法:
对于有多个数组列的情况,可以这样使用:
rsaldnfx2#
值数组(元组(低基数(字符串),int32)),
不要使用
Tuple
. 它只带来缺点。磁盘上还有2个文件。如果只提取一个元组元素https://gist.github.com/den-crane/f20a2dce94a2926a1e7cfec7cdd12f6d