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

Result from first window function reused by other window functions #4140

Closed
knutwannheden opened this issue Aug 18, 2022 · 6 comments · Fixed by dolthub/go-mysql-server#1447
Assignees
Labels
bug Something isn't working sql Issue with SQL

Comments

@knutwannheden
Copy link

It looks like when a query contains multiple window functions, that the result evaluated by the first window function will also be returned by the other window functions. Take this example:

create table t(a int, b int);
insert into t(a, b) values (1, 1), (1, 2), (1, 3), (2, 4), (2, 5), (2, 6);

select a, b, sum(b) over (order by b) total_sum, sum(b) over (partition by a order by b) a_sum
from t
order by 1, 2;

In the result set the last two columns always contain the same value, while they clearly should not (compare against https://www.db-fiddle.com/f/pQav68zxdV4gnRjcaoXdrm/0).

@fulghum fulghum added the bug Something isn't working label Aug 18, 2022
@fulghum
Copy link
Contributor

fulghum commented Aug 18, 2022

Hey Knut, thanks for reporting this one. This definitely looks like a bug where Dolt is not returning the same data as MySQL.

Thanks for the good repro case; we'll dig in and see what we can find.

@fulghum fulghum self-assigned this Aug 22, 2022
@fulghum
Copy link
Contributor

fulghum commented Aug 22, 2022

Quick update... I started repro and debugging through this one on Friday and it's top of my stack today. I'll keep you updated on today's progress.

@knutwannheden
Copy link
Author

Thanks for looking into this!

@fulghum
Copy link
Contributor

fulghum commented Aug 23, 2022

My pleasure! This is a fun one to debug through. I had a few other meetings and reviews today, but still made some progress on this one. I found what I suspect is a simpler repro case (but could end up being a separate issue). I've got a lot more time available tomorrow to keep focused on this one and will keep you updated.

@timsehn timsehn added the sql Issue with SQL label Aug 24, 2022
@fulghum
Copy link
Contributor

fulghum commented Aug 27, 2022

Hey Knut, just following up... I needed to prioritize a couple of issues this week for customers with support contracts, so that preempted this work. It's still on my radar though, and we'll get back to it.

@PavelSafronov
Copy link
Contributor

@knutwannheden Thanks again for the report. I've just merged a fix for this issue. It should make it into the dolt executable some time next week.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working sql Issue with SQL
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants