mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-10 09:32:06 +00:00
Remove filter column from HAVING when it is not needed.
This commit is contained in:
parent
841ef13dee
commit
09cd955aa6
40
tests/queries/0_stateless/2025_having_filter_column.sql
Normal file
40
tests/queries/0_stateless/2025_having_filter_column.sql
Normal file
@ -0,0 +1,40 @@
|
||||
drop table if exists test;
|
||||
|
||||
-- #29010
|
||||
CREATE TABLE test
|
||||
(
|
||||
d DateTime,
|
||||
a String,
|
||||
b UInt64
|
||||
)
|
||||
ENGINE = MergeTree
|
||||
PARTITION BY toDate(d)
|
||||
ORDER BY d;
|
||||
|
||||
SELECT *
|
||||
FROM (
|
||||
SELECT
|
||||
a,
|
||||
max((d, b)).2 AS value
|
||||
FROM test
|
||||
GROUP BY rollup(a)
|
||||
)
|
||||
WHERE a <> '';
|
||||
|
||||
-- the same query, but after syntax optimization
|
||||
SELECT
|
||||
a,
|
||||
value
|
||||
FROM
|
||||
(
|
||||
SELECT
|
||||
a,
|
||||
max((d, b)).2 AS value
|
||||
FROM test
|
||||
GROUP BY a
|
||||
WITH ROLLUP
|
||||
HAVING a != ''
|
||||
)
|
||||
WHERE a != '';
|
||||
|
||||
drop table if exists test;
|
Loading…
Reference in New Issue
Block a user