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

count(distinct) returns wrong count when there's FACET #2238

Open
3 of 8 tasks
sanikolaev opened this issue May 28, 2024 · 0 comments
Open
3 of 8 tasks

count(distinct) returns wrong count when there's FACET #2238

sanikolaev opened this issue May 28, 2024 · 0 comments

Comments

@sanikolaev
Copy link
Collaborator

sanikolaev commented May 28, 2024

Bug Description:

select count(distinct) ... FACET against a distributed table returns a wrong value.

MRE:

mysql> drop table if exists t; drop table if exists t2; create table t(a int); insert into t values (1,1),(2,2); create table t2 like t; insert into t2 values (4,2); select * from t,t2; select count(distinct a) from t,t2 facet 1;
--------------
drop table if exists t
--------------

Query OK, 0 rows affected (0.02 sec)

--------------
drop table if exists t2
--------------

Query OK, 0 rows affected (0.00 sec)

--------------
create table t(a int)
--------------

Query OK, 0 rows affected (0.00 sec)

--------------
insert into t values (1,1),(2,2)
--------------

Query OK, 2 rows affected (0.00 sec)

--------------
create table t2 like t
--------------

Query OK, 0 rows affected (0.00 sec)

--------------
insert into t2 values (4,2)
--------------

Query OK, 1 row affected (0.00 sec)

--------------
select * from t,t2
--------------

+------+------+
| id   | a    |
+------+------+
|    1 |    1 |
|    4 |    2 |
|    2 |    2 |
+------+------+
3 rows in set (0.00 sec)
--- 3 out of 3 results in 0ms ---

--------------
select count(distinct a) from t,t2 facet 1
--------------

+-------------------+
| count(distinct a) |
+-------------------+
|                 3 |
+-------------------+
1 row in set (0.00 sec)
--- 1 out of 1 results in 0ms ---

+------+----------+
| 1    | count(*) |
+------+----------+
|    1 |        3 |
+------+----------+
1 row in set (0.00 sec)
--- 1 out of 1 results in 0ms ---

Expected:

select count(distinct a) from t,t2 facet 1
--------------

+-------------------+
| count(distinct a) |
+-------------------+
|                 2 |
+-------------------+

+------+----------+
| 1    | count(*) |
+------+----------+
|    1 |        3 |
+------+----------+

Removing FACET solves the issue:

mysql> select count(distinct a) from t,t2;
--------------
select count(distinct a) from t,t2
--------------

+-------------------+
| count(distinct a) |
+-------------------+
|                 2 |
+-------------------+
1 row in set (0.00 sec)
--- 1 out of 1 results in 0ms ---

Manticore Search Version:

Manticore 6.3.1 bc8b773e5@24052416 dev (columnar 2.3.1 4383a90@24052309) (secondary 2.3.1 4383a90@24052309) (knn 2.3.1 4383a90@24052309)

Operating System Version:

Ubuntu Jammy (dev2)

Have you tried the latest development version?

  • Yes

Internal Checklist:

To be completed by the assignee. Check off tasks that have been completed or are not applicable.

  • Task estimated
  • Specification created, reviewed, and approved
  • Implementation completed
  • Tests developed
  • Documentation updated
  • Documentation proofread
  • Changelog updated
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants