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

Group by not working when columns not returned directly in select #8625

Closed
josalmi opened this issue Oct 26, 2018 · 2 comments
Closed

Group by not working when columns not returned directly in select #8625

josalmi opened this issue Oct 26, 2018 · 2 comments
Assignees
Labels
Milestone

Comments

@josalmi
Copy link

josalmi commented Oct 26, 2018

OrientDB Version: 3.0.9

Java Version: openjdk version "1.8.0_171"

OS: alpine 3.8.1 (I'm using the official Docker image)

Given table such as:

@Rid @Version @Class last_name first_name
41:0 1 Test Francescone Onida
41:1 1 Test Springham Lauree
41:2 1 Test Whal Cory
42:0 1 Test Ryan Onida
42:1 1 Test Ranking Abran
42:2 1 Test Schoales Cory
43:0 1 Test Ryan Maximilien
43:1 1 Test Stannas Abran
43:2 1 Test Schoales Augusta
44:0 1 Test Henzley Dot
44:1 1 Test Stannas Gypsy
44:2 1 Test Garrard Walliw

Then running a query with GROUP BY such as:

SELECT first_name + ' ' + last_name, COUNT(@rid) FROM Test GROUP BY last_name, first_name

Expected behavior

Should group specified columns like in SQL:

first_name + ' ' + last_name COUNT(@Rid)
Onida Francescone 1
Lauree Springham 1
Cory Whal 1
Onida Ryan 1
Abran Ranking 1
Cory Schoales 1
Maximilien Ryan 1
Abran Stannas 1
Augusta Schoales 1
Dot Henzley 1
Gypsy Stannas 1
Walliw Garrard 1

Actual behavior

Actually groups people with same last_name to same bucket

first_name + ' ' + last_name COUNT(@Rid)
Onida Francescone 1
Lauree Springham 1
Cory Whal 1
Maximilien Ryan 2
Abran Ranking 1
Augusta Schoales 2
Gypsy Stannas 2
Dot Henzley 1
Walliw Garrard 1

Steps to reproduce

Prepare table with data:

CREATE CLASS TEST EXTENDS V;
INSERT INTO Test (first_name, last_name) VALUES ('Onida', 'Francescone'),
('Onida', 'Ryan'),
('Maximilien', 'Ryan'),
('Dot', 'Henzley'),
('Lauree', 'Springham'),
('Abran', 'Ranking'),
('Abran', 'Stannas'),
('Gypsy', 'Stannas'),
('Cory', 'Whal'),
('Cory', 'Schoales'),
('Augusta', 'Schoales'),
('Walliw', 'Garrard');

Query:

SELECT first_name + ' ' + last_name, COUNT(@rid) FROM Test GROUP BY first_name, last_name

Workaround:

The query seems to give expected results when using GROUP BY first_name + ' ' + last_name syntax:

SELECT first_name + ' ' + last_name, COUNT(@rid) FROM Test GROUP BY first_name + ' ' + last_name

Also when selecting first_name and last_name fields directly in SELECT the query returns results as expected.

SELECT first_name, last_name, COUNT(@rid) FROM Test GROUP BY first_name, last_name
@luigidellaquila luigidellaquila self-assigned this Nov 7, 2018
@luigidellaquila
Copy link
Member

Hi @josalmi

I'm working on it now

Thanks

Luigi

@luigidellaquila
Copy link
Member

Hi @josalmi

I just pushed a fix, it will be released with v 3.0.11

Thanks

Luigi

@luigidellaquila luigidellaquila added this to the 3.0.11 milestone Nov 7, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

No branches or pull requests

2 participants