CREATE TABLE data(k UInt64, v UInt64) ENGINE = MergeTree ORDER BY k
INSERT INTO data SELECT number, 1 from numbers(10000000)
SELECT count() FROM data
SELECT count(k) FROM (SELECT k FROM data, numbers(20) _a)
SELECT count(k) FROM (SELECT toNullable(k) as k FROM data, numbers(20) _a)
DROP TABLE IF EXISTS data