Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Different precision for window funtion when using unparallel hashagg. #26886

Open
wshwsh12 opened this issue Aug 4, 2021 · 3 comments
Open
Assignees
Labels
affects-5.0 This bug affects 5.0.x versions. affects-5.1 This bug affects 5.1.x versions. affects-5.2 This bug affects 5.2.x versions. affects-5.3 This bug affects 5.3.x versions. affects-5.4 This bug affects the 5.4.x(LTS) versions. affects-6.0 affects-6.1 This bug affects the 6.1.x(LTS) versions. severity/minor sig/execution SIG execution type/bug The issue is confirmed as a bug.

Comments

@wshwsh12
Copy link
Contributor

wshwsh12 commented Aug 4, 2021

Bug Report

Please answer these questions before submitting your issue. Thanks!

1. Minimal reproduce step (Required)

set tidb_hashagg_final_concurrency =1 ;
set tidb_hashagg_partial_concurrency =1 ;
drop table sales;
CREATE TABLE sales(id INT AUTO_INCREMENT PRIMARY KEY, `date` DATE, sale INT);
INSERT INTO sales(`date`, sale) VALUES
('2017-03-01', 200),
('2017-04-01', 300),
('2017-05-01', 400),
('2017-06-01', 200),
('2017-07-01', 600),
('2017-08-01', 100),
('2017-03-01', 400),
('2017-04-01', 300),
('2017-05-01', 500),
('2017-06-01', 400),
('2017-07-01', 600),
('2017-08-01', 150);
set sql_mode='';
SELECT MONTH(date), SUM(sale),
AVG(SUM(sale)) OVER w AS sliding_avg FROM sales GROUP BY MONTH(date)
WINDOW w AS (ORDER BY MONTH(date)
RANGE BETWEEN 1 PRECEDING AND 1 FOLLOWING)
ORDER BY AVG(SUM(sale)) OVER (ORDER BY MONTH(date)
RANGE BETWEEN 1 PRECEDING AND 1 FOLLOWING),
MONTH(date);

2. What did you expect to see? (Required)

+-------------+-----------+-------------+
| MONTH(date) | SUM(sale) | sliding_avg |
+-------------+-----------+-------------+
|           3 |       600 |    600.0000 |
|           7 |      1200 |    683.3333 |
|           4 |       600 |    700.0000 |
|           5 |       900 |    700.0000 |
|           8 |       250 |    725.0000 |
|           6 |       600 |    900.0000 |
+-------------+-----------+-------------+
6 rows in set (0.001 sec)

3. What did you see instead (Required)

+-------------+-----------+-------------+
| MONTH(date) | SUM(sale) | sliding_avg |
+-------------+-----------+-------------+
|           3 |  600.0000 |    600.0000 |
|           7 | 1200.0000 |    683.3333 |
|           4 |  600.0000 |    700.0000 |
|           5 |  900.0000 |    700.0000 |
|           8 |  250.0000 |    725.0000 |
|           6 |  600.0000 |    900.0000 |
+-------------+-----------+-------------+
6 rows in set (0.002 sec)

4. What is your TiDB version? (Required)

master, v5.0,v5.1,v4.0

@wshwsh12 wshwsh12 added type/bug The issue is confirmed as a bug. sig/execution SIG execution labels Aug 4, 2021
@Yisaer
Copy link
Contributor

Yisaer commented Aug 4, 2021

/assign

@fuzhe1989
Copy link
Contributor

Hi @Yisaer, do you have any progress on this bug?

@jebter jebter added affects-5.0 This bug affects 5.0.x versions. affects-5.1 This bug affects 5.1.x versions. affects-5.2 This bug affects 5.2.x versions. affects-5.3 This bug affects 5.3.x versions. affects-5.4 This bug affects the 5.4.x(LTS) versions. labels Jan 11, 2022
@VelocityLight VelocityLight added the affects-6.1 This bug affects the 6.1.x(LTS) versions. label May 20, 2022
@zanmato1984
Copy link
Contributor

Adjusting severity to minor.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
affects-5.0 This bug affects 5.0.x versions. affects-5.1 This bug affects 5.1.x versions. affects-5.2 This bug affects 5.2.x versions. affects-5.3 This bug affects 5.3.x versions. affects-5.4 This bug affects the 5.4.x(LTS) versions. affects-6.0 affects-6.1 This bug affects the 6.1.x(LTS) versions. severity/minor sig/execution SIG execution type/bug The issue is confirmed as a bug.
Projects
None yet
Development

No branches or pull requests

7 participants