Details
-
Bug
-
Status: Closed (View Workflow)
-
Major
-
Resolution: Duplicate
-
12.3.2
-
None
-
Not for Release Notes
Description
Description
MariaDB Server 12.3.2 returns no rows for a grouped COUNT DISTINCT query with DENSE_RANK and HAVING, although all three groups satisfy HAVING. Removing the window function, or replacing COUNT DISTINCT with ordinary COUNT, returns the surviving groups. Projecting the HAVING aggregates confirms their values satisfy both conditions.
How to repeat
|
|
CREATE TEMPORARY TABLE win_count (id INT,k VARCHAR(10),x DOUBLE,txt LONGTEXT); |
INSERT INTO win_count VALUES
|
(1,'a',3.71,'one'),(2,'b',5.25,'two'),(3,'c',9.12,'three'); |
CREATE TEMPORARY TABLE win_copies (v INT);
|
INSERT INTO win_copies VALUES (1),(2),(3); |
|
|
SELECT DENSE_RANK() OVER (ORDER BY p.txt) AS r,COUNT(DISTINCT p.k) AS n
|
FROM win_count p CROSS JOIN win_copies d GROUP BY p.txt
|
HAVING AVG(p.id)<78 AND SUM(d.v)>=1; |
Expected result
Three rows: `(1,1),(2,1),(3,1)`. Each group contains three copies of one source row and one distinct k. The group AVG(id) values are 1, 3 and 2, and SUM(d.v) is 6 for every group, so every group satisfies HAVING.
Actual result
No rows.
Attachments
Issue Links
- duplicates
-
MDEV-40884 Materializing a grouped input changes the result of a window query with `HAVING SUM(DISTINCT ...)`
-
- Confirmed
-