clickhouse-client --preferred_block_size_bytes=10000 -q "SELECT max(i) FROM test.pbs PREWHERE s = 1"
clickhouse-client -q "INSERT INTO test.pbs (i, s) SELECT number AS i, 1 AS s FROM system.numbers LIMIT 9000"
clickhouse-client --preferred_block_size_bytes=10000 -q "SELECT max(i) FROM test.pbs PREWHERE s = 1"
clickhouse-client -q "DROP TABLE test.pbs"
# Nullable PREWHERE
clickhouse-client -q "DROP TABLE IF EXISTS test.nullable_prewhere"
clickhouse-client -q "CREATE TABLE test.nullable_prewhere (p Date, f Nullable(UInt64), d UInt64) ENGINE = MergeTree(p, p, 8)"
clickhouse-client -q "INSERT INTO test.nullable_prewhere SELECT toDate(0) AS p, if(number % 2 = 0, CAST(number AS Nullable(UInt64)), CAST(NULL AS Nullable(UInt64))) AS f, number as d FROM system.numbers LIMIT 1001"
clickhouse-client -q "SELECT sum(d), sum(f), max(d) FROM test.nullable_prewhere PREWHERE NOT isNull(f)"
clickhouse-client -q "DROP TABLE IF EXISTS test.nullable_prewhere"