How to filter clickhouse table by array column contents?

I think the reason why you get 3 zeros is that arrayEnumerate enumerates over the array indexes not array values, and since none of your rows have more than 7 elements arrayEnumerates results in 0 for all the rows. To make this work,

SELECT arrayExists(
    val -> distance[val] > 7,
    arrayEnumerate(distance))
FROM ArrayTest;

You can use arrayExists in the WHERE clause.

SELECT * 
FROM ArrayTest
WHERE arrayExists(x -> x > 7, distance) = 1;

Another way is to use ARRAY JOIN, if you need to know which values is greater than 7:

SELECT d, distance, sessionSecond 
FROM ArrayTest
ARRAY JOIN distance as d
WHERE d > 7

Tags:

Clickhouse