Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Backport #60026 to 23.12: Fix optimize_uniq_to_count removing the col…
…umn alias
- Loading branch information
1 parent
7eec3d4
commit ed21b0f
Showing
3 changed files
with
43 additions
and
0 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
2 changes: 2 additions & 0 deletions
2
tests/queries/0_stateless/02990_optimize_uniq_to_count_alias.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,2 @@ | ||
1 | ||
1 |
37 changes: 37 additions & 0 deletions
37
tests/queries/0_stateless/02990_optimize_uniq_to_count_alias.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,37 @@ | ||
--https://github.com/ClickHouse/ClickHouse/issues/59999 | ||
DROP TABLE IF EXISTS tags; | ||
CREATE TABLE tags (dev_tag String) ENGINE = Memory AS SELECT '1'; | ||
|
||
SELECT * | ||
FROM | ||
( | ||
SELECT countDistinct(dev_tag) AS total_devtags | ||
FROM | ||
( | ||
SELECT dev_tag | ||
FROM | ||
( | ||
SELECT * | ||
FROM tags | ||
) AS t | ||
GROUP BY dev_tag | ||
) AS t | ||
) SETTINGS optimize_uniq_to_count=0; | ||
|
||
SELECT * | ||
FROM | ||
( | ||
SELECT countDistinct(dev_tag) AS total_devtags | ||
FROM | ||
( | ||
SELECT dev_tag | ||
FROM | ||
( | ||
SELECT * | ||
FROM tags | ||
) AS t | ||
GROUP BY dev_tag | ||
) AS t | ||
) SETTINGS optimize_uniq_to_count=1; | ||
|
||
DROP TABLE IF EXISTS tags; |