ClickHouse/tests/queries/0_stateless/00687_top_and_offset.sh

30 lines
1.4 KiB
Bash
Raw Normal View History

#!/usr/bin/env bash
CURDIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
2020-12-28 11:46:53 +00:00
# shellcheck source=../shell_config.sh
2020-08-01 00:51:12 +00:00
. "$CURDIR"/../shell_config.sh
2019-06-03 17:36:27 +00:00
${CLICKHOUSE_CLIENT} --query "DROP TABLE IF EXISTS test_00687;"
2019-06-03 17:36:27 +00:00
${CLICKHOUSE_CLIENT} --query "CREATE TABLE test_00687(val Int64) engine = Memory;"
2019-06-03 17:36:27 +00:00
${CLICKHOUSE_CLIENT} --query "INSERT INTO test_00687 VALUES (1);"
${CLICKHOUSE_CLIENT} --query "INSERT INTO test_00687 VALUES (2);"
${CLICKHOUSE_CLIENT} --query "INSERT INTO test_00687 VALUES (3);"
${CLICKHOUSE_CLIENT} --query "INSERT INTO test_00687 VALUES (4);"
${CLICKHOUSE_CLIENT} --query "INSERT INTO test_00687 VALUES (5);"
${CLICKHOUSE_CLIENT} --query "INSERT INTO test_00687 VALUES (6);"
${CLICKHOUSE_CLIENT} --query "INSERT INTO test_00687 VALUES (7);"
${CLICKHOUSE_CLIENT} --query "INSERT INTO test_00687 VALUES (8);"
${CLICKHOUSE_CLIENT} --query "INSERT INTO test_00687 VALUES (9);"
2019-06-03 17:36:27 +00:00
${CLICKHOUSE_CLIENT} --query "SELECT TOP 2 * FROM test_00687 ORDER BY val;"
${CLICKHOUSE_CLIENT} --query "SELECT TOP (2) * FROM test_00687 ORDER BY val;"
${CLICKHOUSE_CLIENT} --query "SELECT * FROM test_00687 ORDER BY val LIMIT 2 OFFSET 2;"
2020-08-01 13:25:59 +00:00
echo "$(${CLICKHOUSE_CLIENT} --query "SELECT TOP 2 * FROM test_00687 ORDER BY val LIMIT 2;" 2>&1 | grep -c "Code: 406")"
echo "$(${CLICKHOUSE_CLIENT} --query "SELECT * FROM test_00687 ORDER BY val LIMIT 2,3 OFFSET 2;" 2>&1 | grep -c "Code: 62")"
2019-06-03 17:36:27 +00:00
${CLICKHOUSE_CLIENT} --query "DROP TABLE test_00687;"