stoneatom / stonedb

StoneDB is an Open-Source MySQL HTAP and MySQL-Native DataBase for OLTP, Real-Time Analytics, a counterpart of MySQLHeatWave. (https://stonedb.io)
https://stonedb.io/
GNU General Public License v2.0
866 stars 141 forks source link

bug: the column that has not been aggregated, return value is wrong #1892

Open davidshiz opened 1 year ago

davidshiz commented 1 year ago

Have you read the Contributing Guidelines on issues?

Please confirm if bug report does NOT exists already ?

Describe the problem

mysql> CREATE TABLE t1 (a CHAR(1), b INT);
Query OK, 0 rows affected (0.00 sec)

mysql> INSERT INTO t1 VALUES (NULL, NULL),('a', 12),('a', 13),('b', 14),('b', 15),('b', 16),('b', 17),('b', 18),('a', 19);
Query OK, 9 rows affected (0.00 sec)
Records: 9  Duplicates: 0  Warnings: 0

mysql> SELECT a, b, sum(b) FROM t1;
+------+------+--------+
| a    | b    | sum(b) |
+------+------+--------+
| NULL |   12 |    124 |
+------+------+--------+
1 row in set (0.00 sec)

Expected behavior

mysql> SELECT a, b, sum(b) FROM t1;
+------+------+--------+
| a    | b    | sum(b) |
+------+------+--------+
| NULL | NULL |    124 |
+------+------+--------+
1 row in set (0.00 sec)

How To Reproduce

No response

Environment

[root@stonedb-test mysql-test]# /stonedb57/install/bin/mysqld --version
/stonedb57/install/bin/mysqld  Ver 5.7.36-StoneDB-v1.0.1 for Linux on x86_64 (bu
build information as follow:
        Repository address: https://github.com/stoneatom/stonedb.git:stonedb-5.7
        Branch name: stonedb-5.7-dev
        Last commit ID: f180323
        Last commit time: Date:   Wed Jun 14 15:44:47 2023 +0800
        Build time: Date: Thu Jun 15 07:27:24 UTC 2023

Are you interested in submitting a PR to solve the problem?