ClickHouse/tests/queries/0_stateless/01395_limit_more_cases.sh

36 lines
1.3 KiB
Bash
Raw Normal View History

2020-07-12 22:23:21 +00:00
#!/usr/bin/env bash
CURDIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
2020-08-01 00:51:12 +00:00
. "$CURDIR"/../shell_config.sh
2020-07-12 22:23:21 +00:00
SIZE=13
for OFFSET in {0..15}; do
for LIMIT in {0..15}; do
echo "SELECT
$OFFSET, $LIMIT,
count() AS c, min(number) AS first, max(number) AS last,
throwIf(first != ($OFFSET < $SIZE AND $LIMIT > 0 ? $OFFSET : 0)),
throwIf(last != ($OFFSET < $SIZE AND $LIMIT > 0 ? least($SIZE - 1, $OFFSET + $LIMIT - 1) : 0)),
throwIf((c != 0 OR first != 0 OR last != 0) AND (c != last - first + 1))
FROM (SELECT * FROM numbers($SIZE) LIMIT $OFFSET, $LIMIT);
"
done
done | $CLICKHOUSE_CLIENT -n --max_block_size 5
2020-07-12 22:30:27 +00:00
# Randomized test
ITERATIONS=1000
2020-08-01 00:40:56 +00:00
for _ in $(seq $ITERATIONS); do
2020-07-12 22:30:27 +00:00
SIZE=$(($RANDOM % 100))
OFFSET=$(($RANDOM % 111))
LIMIT=$(($RANDOM % 111))
echo "WITH count() AS c, min(number) AS first, max(number) AS last
SELECT
throwIf(first != ($OFFSET < $SIZE AND $LIMIT > 0 ? $OFFSET : 0)),
throwIf(last != ($OFFSET < $SIZE AND $LIMIT > 0 ? least($SIZE - 1, $OFFSET + $LIMIT - 1) : 0)),
throwIf((c != 0 OR first != 0 OR last != 0) AND (c != last - first + 1))
FROM (SELECT * FROM numbers($SIZE) LIMIT $OFFSET, $LIMIT);
"
done | $CLICKHOUSE_CLIENT -n --max_block_size $(($RANDOM % 20 + 1)) | uniq