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

Group by not work for negative #4891

Closed
BohuTANG opened this issue Apr 17, 2022 · 3 comments · Fixed by #4902
Closed

Group by not work for negative #4891

BohuTANG opened this issue Apr 17, 2022 · 3 comments · Fixed by #4902
Assignees
Labels
C-bug Category: something isn't working

Comments

@BohuTANG
Copy link
Member

Summary

create table t(tiny TINYINT);
insert into t values(-1);
select sum(tiny) from t group by tiny; -- no result here

This is works:

create table t2(a tinyint);
insert into t2 values(1);
mysql> select sum(a) from t2 group by a;
+--------+
| sum(a) |
+--------+
|      1 |
+--------+
@BohuTANG BohuTANG added the C-bug Category: something isn't working label Apr 17, 2022
@BohuTANG
Copy link
Member Author

I have add a new data type stateless category: #4892

We should do some checks for each data type(4892 is just an outline draft, there is still a lot of work to do, I will first merge it):

  • Bound check
  • Conversion check(Explicit Conversion and Implicit Conversion)
  • Group by check
  • Others?

@sundy-li
Copy link
Member

Bugs to u8/u16 keys in hashmap.

MySQL [(none)]> select b::Int64 as b ,count(1)  from t2 group by b;
+------+---------+
| b    | count() |
+------+---------+
|   -1 |       1 |
|    4 |       1 |
|   -3 |       1 |
|    2 |       1 |
+------+---------+
4 rows in set (0.033 sec)

MySQL [(none)]> select b::Int16 as b ,count(1)  from t2 group by b;
+------+---------+
| b    | count() |
+------+---------+
|    2 |       1 |
|    4 |       1 |
|   -3 |       1 |
+------+---------+
3 rows in set (0.033 sec)

@sundy-li
Copy link
Member

 fn aggregate_state(&self) -> Self::State {
        Self::State::create(u8::MAX as usize)
    }

Seems related to u8::MAX, should be u8::MAX as usize + 1

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