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
862 stars 139 forks source link

bug: COUNT(DISTINCT Multiple Expressions) syntax is not supported #928

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

When more than one expression is provided in the DISTINCT clause, The COUNT(DISTINCT expression) syntax that is not supported by Tianmu engine.

mysql> select * from t1;
+------+------+------+
| idx  | c1   | c2   |
+------+------+------+
|    1 |    2 |    2 |
|    1 |    2 |    3 |
|    1 |    2 |    4 |
|    1 |    3 |    2 |
|    4 |    3 |    4 |
+------+------+------+
5 rows in set (0.00 sec)
mysql> select count(distinct c1,  c2)from t1;
ERROR 6 (HY000): The query includes syntax that is not supported by the storage engine. Either restructure the query with supported syntax, or enable the MySQL core::Query Path in config file to execute the query with reduced performance.

Expected behavior

mysql> select count(distinct c1,  c2)from t1;
+-------------------------+
| count(distinct c1,  c2) |
+-------------------------+
|                       5 |
+-------------------------+
1 row in set (0.00 sec)

How To Reproduce

CREATE TABLE `t1` (
  idx  int(11), 
  c1   int(11),
  c2   int(11)
);
insert into t1 values   (1, 2, 2), 
                        (1, 2, 3),
                        (1, 2, 4), 
                        (1, 3, 2), 
                        (4, 3, 4);
select count(distinct c1,  c2)from t1;

Environment

root@localhost:/# /stonedb57/install/bin/mysqld --version
/stonedb57/install/bin/mysqld  Ver 5.7.36-StoneDB for Linux on x86_64 (build-)
build information as follow:
        Repository address: https://github.com/stoneatom/stonedb.git:stonedb-5.7-dev
        Branch name: stonedb-5.7-dev
        Last commit ID: d0c2e01b6
        Last commit time: Date:   Wed Nov 2 19:58:00 2022 +0800
        Build time: Date: Sun 06 Nov 2022 08:50:06 AM UTC
root@ub01:~# cat /etc/os-release
NAME="Ubuntu"
VERSION="20.04.5 LTS (Focal Fossa)"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 20.04.5 LTS"
VERSION_ID="20.04"

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

adofsauron commented 1 year ago

To demand development: https://github.com/stoneatom/stonedb/issues/954

RingsC commented 1 year ago

We will convert this issue from bug to a feature. @davidshiz

davidshiz commented 1 year ago

We will convert this issue from bug to a feature. @davidshiz

ok