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

Bug: subquery in partition by clause return wrong result #15977

Closed
xudong963 opened this issue Jul 4, 2024 · 4 comments · Fixed by #16567
Closed

Bug: subquery in partition by clause return wrong result #15977

xudong963 opened this issue Jul 4, 2024 · 4 comments · Fixed by #16567
Assignees
Labels
C-bug Category: something isn't working

Comments

@xudong963
Copy link
Member

Summary

mysql> insert into t1 values(1), (2), (2), (3);
Query OK, 4 rows affected (0.38 sec)

mysql> insert into t2 values(1), (2), (3);
Query OK, 3 rows affected (0.25 sec)

mysql> select count(distinct a) over (partition by (select b from t2)) from t1;
+-----------+
| count(_1) |
+-----------+
|         3 |
+-----------+
1 row in set (0.09 sec)
Read 4 rows, 17.00 B in 0.048 sec., 83.91 rows/sec., 356.61 B/sec.
@xudong963 xudong963 added the C-bug Category: something isn't working label Jul 4, 2024
@xudong963
Copy link
Member Author

pg: error: more than one row returned by a subquery used as an expression

mysql: error: ER_SUBQUERY_NO_1_ROW: Subquery returns more than 1 row

sqlite:

4
4
4
4

@xudong963
Copy link
Member Author

Which behavior should we follow? Open to discuss.

@TCeason
Copy link
Collaborator

TCeason commented Jul 4, 2024

I think pg is better. It's more clear.

@Dousir9
Copy link
Member

Dousir9 commented Jul 4, 2024

Snowflake:
截屏2024-07-04 21 53 30

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants