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

JOIN: wrong count(*) #2201

Closed
8 tasks done
sanikolaev opened this issue May 17, 2024 · 1 comment
Closed
8 tasks done

JOIN: wrong count(*) #2201

sanikolaev opened this issue May 17, 2024 · 1 comment

Comments

@sanikolaev
Copy link
Collaborator

sanikolaev commented May 17, 2024

Bug Description:

How to reproduce:

DROP TABLE IF EXISTS customers;
CREATE TABLE customers (name text, email string attribute, address text );

INSERT INTO customers (id, name, email, address) VALUES
(1, 'Alice Johnson', 'alice@example.com', '123 Maple St'),
(2, 'Bob Smith', 'bob@example.com', '456 Oak St'),
(3, 'Carol White', 'carol@example.com', '789 Pine St');

DROP TABLE IF EXISTS orders;
CREATE TABLE orders (customer_id bigint, product text, quantity integer, order_date string, tags multi, details json );

INSERT INTO orders (id, customer_id, product, quantity, order_date, tags, details) VALUES 
(1, 1, 'Laptop', 1, '2023-01-01', (101, 102), '{"price":1200, "warranty":"2 years"}'),
(2, 2, 'Phone', 2, '2023-01-02', (103), '{"price":800, "warranty":"1 year"}'),
(3, 1, 'Tablet', 1, '2023-01-03', (101, 104), '{"price":450, "warranty":"1 year"}'),
(4, 3, 'Monitor', 1, '2023-01-04', (105), '{"price":300, "warranty":"1 year"}');

SELECT name, COUNT(*) FROM customers INNER JOIN orders ON customers.id = orders.customer_id GROUP BY name;

returns

+---------------+----------+
| name          | count(*) |
+---------------+----------+
| Alice Johnson |        6 |
+---------------+----------+

Expected: some warning since we attempt grouping by a full-text field.

W/o grouping it returns 4 entries:

mysql> SELECT name FROM customers INNER JOIN orders ON customers.id = orders.customer_id ORDER BY name ASC;
+---------------+
| name          |
+---------------+
| Alice Johnson |
| Alice Johnson |
| Bob Smith     |
| Carol White   |
+---------------+
4 rows in set (0.00 sec)
--- 4 out of 4 results in 0ms ---

Manticore Search Version:

Manticore 6.2.13 cc9294cd6@24051604 dev (columnar 2.2.5 0c18998@240424) (secondary 2.2.5 0c18998@240424) (knn 2.2.5 0c18998@240424)

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
@glookka
Copy link
Contributor

glookka commented May 28, 2024

Fixed in 997bab9

@glookka glookka closed this as completed May 28, 2024
@sanikolaev sanikolaev added the rel::upcoming Upcoming release label Jun 1, 2024
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