forked from ClickHouse/ClickHouse
-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request ClickHouse#32670 from CurtizJ/fix-reading-in-order
Fix reading in order of sorting key from `Distributed` and `Merge` tables
- Loading branch information
Showing
3 changed files
with
47 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
tests/queries/0_stateless/02147_order_by_optimizations.reference
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
SELECT | ||
date, | ||
v | ||
FROM t_02147 | ||
ORDER BY | ||
toStartOfHour(date) ASC, | ||
v ASC | ||
SELECT | ||
date, | ||
v | ||
FROM t_02147_dist | ||
ORDER BY | ||
toStartOfHour(date) ASC, | ||
v ASC | ||
SELECT | ||
date, | ||
v | ||
FROM t_02147_merge | ||
ORDER BY | ||
toStartOfHour(date) ASC, | ||
v ASC |
15 changes: 15 additions & 0 deletions
15
tests/queries/0_stateless/02147_order_by_optimizations.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
DROP TABLE IF EXISTS t_02147; | ||
DROP TABLE IF EXISTS t_02147_dist; | ||
DROP TABLE IF EXISTS t_02147_merge; | ||
|
||
CREATE TABLE t_02147 (date DateTime, v UInt32) | ||
ENGINE = MergeTree ORDER BY toStartOfHour(date); | ||
|
||
CREATE TABLE t_02147_dist AS t_02147 ENGINE = Distributed(test_shard_localhost, currentDatabase(), t_02147); | ||
CREATE TABLE t_02147_merge AS t_02147 ENGINE = Merge(currentDatabase(), 't_02147'); | ||
|
||
SET optimize_monotonous_functions_in_order_by = 1; | ||
|
||
EXPLAIN SYNTAX SELECT * FROM t_02147 ORDER BY toStartOfHour(date), v; | ||
EXPLAIN SYNTAX SELECT * FROM t_02147_dist ORDER BY toStartOfHour(date), v; | ||
EXPLAIN SYNTAX SELECT * FROM t_02147_merge ORDER BY toStartOfHour(date), v; |