forked from ClickHouse/ClickHouse
-
Notifications
You must be signed in to change notification settings - Fork 6
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#55905 from ClickHouse/backport/23.7/55895
Backport ClickHouse#55895 to 23.7: Fix window functions in case of sparse columns.
- Loading branch information
Showing
3 changed files
with
51 additions
and
1 deletion.
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
5 changes: 5 additions & 0 deletions
5
tests/queries/0_stateless/02900_window_function_with_sparse_column.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,5 @@ | ||
false | ||
false | ||
false | ||
|
||
|
45 changes: 45 additions & 0 deletions
45
tests/queries/0_stateless/02900_window_function_with_sparse_column.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,45 @@ | ||
-- https://github.com/ClickHouse/ClickHouse/issues/55843 | ||
-- These tests pass without the fix when either of | ||
-- - optimize_read_in_window_order = 0 and optimize_read_in_order = 0 | ||
-- - ratio_of_defaults_for_sparse_serialization = 1 | ||
-- However it is better to leave the settings as randomized because we run | ||
-- stateless tests quite a few times during a PR, so if a bug is introduced | ||
-- then there is a big chance of catching it. Furthermore, randomized settings | ||
-- might identify new bugs. | ||
|
||
CREATE TABLE test1 | ||
( | ||
id String, | ||
time DateTime64(9), | ||
key Int64, | ||
value Bool, | ||
) | ||
ENGINE = MergeTree | ||
PARTITION BY toYYYYMM(time) | ||
ORDER BY (key, id, time); | ||
|
||
INSERT INTO test1 VALUES ('id0', now(), 3, false) | ||
|
||
SELECT last_value(value) OVER (PARTITION BY id ORDER BY time ASC) as last_value | ||
FROM test1 | ||
WHERE (key = 3); | ||
|
||
SELECT last_value(value) OVER (ORDER BY time ASC) as last_value | ||
FROM test1 | ||
WHERE (key = 3); | ||
|
||
SELECT last_value(value) OVER (PARTITION BY id ORDER BY time ASC) as last_value | ||
FROM test1; | ||
|
||
|
||
|
||
CREATE TABLE test2 | ||
( | ||
time DateTime, | ||
value String | ||
) | ||
ENGINE = MergeTree | ||
ORDER BY (time) AS SELECT 0, ''; | ||
|
||
SELECT any(value) OVER (ORDER BY time ASC) FROM test2; | ||
SELECT last_value(value) OVER (ORDER BY time ASC) FROM test2; |