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

last_value for bit type incompatible with mysql #25529

Open
aytrack opened this issue Jun 17, 2021 · 1 comment
Open

last_value for bit type incompatible with mysql #25529

aytrack opened this issue Jun 17, 2021 · 1 comment
Labels
severity/moderate sig/execution SIG execution type/bug The issue is confirmed as a bug.

Comments

@aytrack
Copy link
Contributor

aytrack commented Jun 17, 2021

Bug Report

Please answer these questions before submitting your issue. Thanks!

1. Minimal reproduce step (Required)

drop table if exists t1;
create table t1(a bit(7));
insert into t1 values (126);
select sum(a) over w, last_value(a) over w from t1 window w as (partition by a);
insert into t1 values (127);
select sum(a) over w, last_value(a) over w from t1 window w as (partition by a);

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

mysql> select sum(a) over w, last_value(a) over w from t1 window w as (partition by a);
Field   1:  `sum(a) over w`
Catalog:    `def`
Database:   ``
Table:      ``
Org_table:  ``
Type:       NEWDECIMAL
Collation:  binary (63)
Length:     30
Max_length: 3
Decimals:   0
Flags:      NUM

Field   2:  `last_value(a) over w`
Catalog:    `def`
Database:   ``
Table:      ``
Org_table:  ``
Type:       LONG
Collation:  binary (63)
Length:     7
Max_length: 3
Decimals:   0
Flags:      UNSIGNED NUM


+---------------+----------------------+
| sum(a) over w | last_value(a) over w |
+---------------+----------------------+
|           126 |                  126 |
|           127 |                  127 |
+---------------+----------------------+

3. What did you see instead (Required)

mysql> select sum(a) over w, last_value(a) over w from t1 window w as (partition by a);
Field   1:  `sum(a) over w`
Catalog:    `def`
Database:   ``
Table:      ``
Org_table:  ``
Type:       DOUBLE
Collation:  binary (63)
Length:     23
Max_length: 3
Decimals:   31
Flags:      NOT_NULL BINARY NUM

Field   2:  `last_value(a) over w`
Catalog:    `def`
Database:   ``
Table:      ``
Org_table:  ``
Type:       BIT
Collation:  binary (63)
Length:     7
Max_length: 1
Decimals:   0
Flags:      UNSIGNED


+---------------+----------------------+
| sum(a) over w | last_value(a) over w |
+---------------+----------------------+
|           126 | ~                    |
|           127 |                     |
+---------------+----------------------+
2 rows in set (0.04 sec)

4. What is your TiDB version? (Required)

master: ed52601
release-5.1: befa712

@aytrack aytrack added type/bug The issue is confirmed as a bug. sig/execution SIG execution severity/moderate labels Jun 17, 2021
@aytrack
Copy link
Contributor Author

aytrack commented Jun 21, 2021

nth_value has the same problem

mysql> select sum(a) over w, nth_value(a, 1) over w from t1 window w as (partition by a);
Field   1:  `sum(a) over w`
Catalog:    `def`
Database:   ``
Table:      ``
Org_table:  ``
Type:       DOUBLE
Collation:  binary (63)
Length:     23
Max_length: 3
Decimals:   31
Flags:      NOT_NULL BINARY NUM

Field   2:  `nth_value(a, 1) over w`
Catalog:    `def`
Database:   ``
Table:      ``
Org_table:  ``
Type:       BIT
Collation:  binary (63)
Length:     7
Max_length: 1
Decimals:   0
Flags:      UNSIGNED


+---------------+------------------------+
| sum(a) over w | nth_value(a, 1) over w |
+---------------+------------------------+
|           126 | ~                      |
|           127 |                       |
+---------------+------------------------+
2 rows in set (0.05 sec)

MySQL:

mysql> select sum(a) over w, nth_value(a, 1) over w from t1 window w as (partition by a);
Field   1:  `sum(a) over w`
Catalog:    `def`
Database:   ``
Table:      ``
Org_table:  ``
Type:       NEWDECIMAL
Collation:  binary (63)
Length:     30
Max_length: 3
Decimals:   0
Flags:      NUM

Field   2:  `nth_value(a, 1) over w`
Catalog:    `def`
Database:   ``
Table:      ``
Org_table:  ``
Type:       LONG
Collation:  binary (63)
Length:     7
Max_length: 3
Decimals:   0
Flags:      UNSIGNED NUM


+---------------+------------------------+
| sum(a) over w | nth_value(a, 1) over w |
+---------------+------------------------+
|           126 |                    126 |
|           127 |                    127 |
+---------------+------------------------+
2 rows in set (0.05 sec)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
severity/moderate sig/execution SIG execution type/bug The issue is confirmed as a bug.
Projects
None yet
Development

No branches or pull requests

1 participant