diff --git a/tests/queries/0_stateless/01710_normal_projections.reference b/tests/queries/0_stateless/01710_normal_projections.reference new file mode 100644 index 00000000000..f3575f1d85d --- /dev/null +++ b/tests/queries/0_stateless/01710_normal_projections.reference @@ -0,0 +1,102 @@ +select where x < 10 +optimize_move_to_prewhere = 0, allow_experimental_projection_optimization = 0 +0 4294967295 +1 4294967294 +2 4294967293 +3 4294967292 +4 4294967291 +5 4294967290 +6 4294967289 +7 4294967288 +8 4294967287 +9 4294967286 +optimize_move_to_prewhere = 0, allow_experimental_projection_optimization = 1 +0 4294967295 +1 4294967294 +2 4294967293 +3 4294967292 +4 4294967291 +5 4294967290 +6 4294967289 +7 4294967288 +8 4294967287 +9 4294967286 +optimize_move_to_prewhere = 1, allow_experimental_projection_optimization = 0 +0 4294967295 +1 4294967294 +2 4294967293 +3 4294967292 +4 4294967291 +5 4294967290 +6 4294967289 +7 4294967288 +8 4294967287 +9 4294967286 +optimize_move_to_prewhere = 1, allow_experimental_projection_optimization = 1 +0 4294967295 +1 4294967294 +2 4294967293 +3 4294967292 +4 4294967291 +5 4294967290 +6 4294967289 +7 4294967288 +8 4294967287 +9 4294967286 +optimize_move_to_prewhere = 0, allow_experimental_projection_optimization = 0 + "rows_read": 8192, +optimize_move_to_prewhere = 0, allow_experimental_projection_optimization = 1 + "rows_read": 8192, +optimize_move_to_prewhere = 1, allow_experimental_projection_optimization = 0 + "rows_read": 8192, +optimize_move_to_prewhere = 1, allow_experimental_projection_optimization = 1 + "rows_read": 8192, +select where y > 4294967286 +optimize_move_to_prewhere = 0, allow_experimental_projection_optimization = 0 +0 4294967295 +1 4294967294 +2 4294967293 +3 4294967292 +4 4294967291 +5 4294967290 +6 4294967289 +7 4294967288 +8 4294967287 +optimize_move_to_prewhere = 0, allow_experimental_projection_optimization = 1 +0 4294967295 +1 4294967294 +2 4294967293 +3 4294967292 +4 4294967291 +5 4294967290 +6 4294967289 +7 4294967288 +8 4294967287 +optimize_move_to_prewhere = 1, allow_experimental_projection_optimization = 0 +0 4294967295 +1 4294967294 +2 4294967293 +3 4294967292 +4 4294967291 +5 4294967290 +6 4294967289 +7 4294967288 +8 4294967287 +optimize_move_to_prewhere = 1, allow_experimental_projection_optimization = 1 +0 4294967295 +1 4294967294 +2 4294967293 +3 4294967292 +4 4294967291 +5 4294967290 +6 4294967289 +7 4294967288 +8 4294967287 +optimize_move_to_prewhere = 0, allow_experimental_projection_optimization = 0 + "rows_read": 1000000, +optimize_move_to_prewhere = 0, allow_experimental_projection_optimization = 1 + "rows_read": 8768, +optimize_move_to_prewhere = 1, allow_experimental_projection_optimization = 0 + "rows_read": 1000000, +optimize_move_to_prewhere = 1, allow_experimental_projection_optimization = 1 + "rows_read": 8768, diff --git a/tests/queries/0_stateless/01710_normal_projections.sh b/tests/queries/0_stateless/01710_normal_projections.sh new file mode 100755 index 00000000000..6a8c1cbe168 --- /dev/null +++ b/tests/queries/0_stateless/01710_normal_projections.sh @@ -0,0 +1,79 @@ +#!/usr/bin/env bash + +CURDIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd) +# shellcheck source=../shell_config.sh +. "$CURDIR"/../shell_config.sh + +$CLICKHOUSE_CLIENT -q "CREATE TABLE test_sort_proj (x UInt32, y UInt32, PROJECTION p (SELECT x, y ORDER BY y) TYPE normal) ENGINE = MergeTree ORDER BY x" +$CLICKHOUSE_CLIENT -q "insert into test_sort_proj select number, toUInt32(-number - 1) from numbers(1000000)" + +echo "select where x < 10" + +echo "optimize_move_to_prewhere = 0, allow_experimental_projection_optimization = 0" +$CLICKHOUSE_CLIENT -q "SELECT * FROM test_sort_proj WHERE x < 10 order by x + SETTINGS optimize_move_to_prewhere = 0, allow_experimental_projection_optimization = 0" + +echo "optimize_move_to_prewhere = 0, allow_experimental_projection_optimization = 1" +$CLICKHOUSE_CLIENT -q "SELECT * FROM test_sort_proj WHERE x < 10 order by x + SETTINGS optimize_move_to_prewhere = 0, allow_experimental_projection_optimization = 1" + +echo "optimize_move_to_prewhere = 1, allow_experimental_projection_optimization = 0" +$CLICKHOUSE_CLIENT -q "SELECT * FROM test_sort_proj WHERE x < 10 order by x + SETTINGS optimize_move_to_prewhere = 1, allow_experimental_projection_optimization = 0" + +echo "optimize_move_to_prewhere = 1, allow_experimental_projection_optimization = 1" +$CLICKHOUSE_CLIENT -q "SELECT * FROM test_sort_proj WHERE x < 10 order by x + SETTINGS optimize_move_to_prewhere = 1, allow_experimental_projection_optimization = 1" + +echo "optimize_move_to_prewhere = 0, allow_experimental_projection_optimization = 0" +$CLICKHOUSE_CLIENT -q "SELECT * FROM test_sort_proj WHERE x < 10 order by x FORMAT JSON + SETTINGS optimize_move_to_prewhere = 0, allow_experimental_projection_optimization = 0" | grep rows_read + +echo "optimize_move_to_prewhere = 0, allow_experimental_projection_optimization = 1" +$CLICKHOUSE_CLIENT -q "SELECT * FROM test_sort_proj WHERE x < 10 order by x FORMAT JSON + SETTINGS optimize_move_to_prewhere = 0, allow_experimental_projection_optimization = 1" | grep rows_read + +echo "optimize_move_to_prewhere = 1, allow_experimental_projection_optimization = 0" +$CLICKHOUSE_CLIENT -q "SELECT * FROM test_sort_proj WHERE x < 10 order by x FORMAT JSON + SETTINGS optimize_move_to_prewhere = 1, allow_experimental_projection_optimization = 0" | grep rows_read + +echo "optimize_move_to_prewhere = 1, allow_experimental_projection_optimization = 1" +$CLICKHOUSE_CLIENT -q "SELECT * FROM test_sort_proj WHERE x < 10 order by x FORMAT JSON + SETTINGS optimize_move_to_prewhere = 1, allow_experimental_projection_optimization = 1" | grep rows_read + + +echo "select where y > 4294967286" + +echo "optimize_move_to_prewhere = 0, allow_experimental_projection_optimization = 0" +$CLICKHOUSE_CLIENT -q "SELECT * FROM test_sort_proj WHERE y > 4294967286 order by x + SETTINGS optimize_move_to_prewhere = 0, allow_experimental_projection_optimization = 0" + +echo "optimize_move_to_prewhere = 0, allow_experimental_projection_optimization = 1" +$CLICKHOUSE_CLIENT -q "SELECT * FROM test_sort_proj WHERE y > 4294967286 order by x + SETTINGS optimize_move_to_prewhere = 0, allow_experimental_projection_optimization = 1" + +echo "optimize_move_to_prewhere = 1, allow_experimental_projection_optimization = 0" +$CLICKHOUSE_CLIENT -q "SELECT * FROM test_sort_proj WHERE y > 4294967286 order by x + SETTINGS optimize_move_to_prewhere = 1, allow_experimental_projection_optimization = 0" + +echo "optimize_move_to_prewhere = 1, allow_experimental_projection_optimization = 1" +$CLICKHOUSE_CLIENT -q "SELECT * FROM test_sort_proj WHERE y > 4294967286 order by x + SETTINGS optimize_move_to_prewhere = 1, allow_experimental_projection_optimization = 1" + + +echo "optimize_move_to_prewhere = 0, allow_experimental_projection_optimization = 0" +$CLICKHOUSE_CLIENT -q "SELECT * FROM test_sort_proj WHERE y > 4294967286 order by x FORMAT JSON + SETTINGS optimize_move_to_prewhere = 0, allow_experimental_projection_optimization = 0" | grep rows_read + +echo "optimize_move_to_prewhere = 0, allow_experimental_projection_optimization = 1" +$CLICKHOUSE_CLIENT -q "SELECT * FROM test_sort_proj WHERE y > 4294967286 order by x FORMAT JSON + SETTINGS optimize_move_to_prewhere = 0, allow_experimental_projection_optimization = 1" | grep rows_read + +echo "optimize_move_to_prewhere = 1, allow_experimental_projection_optimization = 0" +$CLICKHOUSE_CLIENT -q "SELECT * FROM test_sort_proj WHERE y > 4294967286 order by x FORMAT JSON + SETTINGS optimize_move_to_prewhere = 1, allow_experimental_projection_optimization = 0" | grep rows_read + +echo "optimize_move_to_prewhere = 1, allow_experimental_projection_optimization = 1" +$CLICKHOUSE_CLIENT -q "SELECT * FROM test_sort_proj WHERE y > 4294967286 order by x FORMAT JSON + SETTINGS optimize_move_to_prewhere = 1, allow_experimental_projection_optimization = 1" | grep rows_read +