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

SQL: wrong number of values for columns #42122

Merged
merged 5 commits into from
Sep 30, 2019

Conversation

emasab
Copy link
Contributor

@emasab emasab commented May 13, 2019

No description provided.

@emasab
Copy link
Contributor Author

emasab commented May 13, 2019

Closes #41811

@emasab
Copy link
Contributor Author

emasab commented May 13, 2019

Hi I've done three bugfixes, done some test locally and added two unit tests.

Cheers

@tvernum tvernum added the :Analytics/SQL SQL querying label May 15, 2019
@elasticmachine
Copy link
Collaborator

Pinging @elastic/es-search

@tvernum
Copy link
Contributor

tvernum commented May 15, 2019

@elasticmachine test this please

@emasab emasab changed the title bugfix for https://github.com/elastic/elasticsearch/issues/41811 SQL: wrong number of values for columns Jun 10, 2019
@emasab emasab changed the title SQL: wrong number of values for columns PR for SQL: wrong number of values for columns Jun 11, 2019
@emasab emasab changed the title PR for SQL: wrong number of values for columns SQL: wrong number of values for columns Jun 11, 2019
@tvernum
Copy link
Contributor

tvernum commented Jun 11, 2019

@elasticmachine test this please

@emasab emasab force-pushed the bugfix/41811-wrong-number-of-values branch from f3117c0 to 46d7793 Compare June 12, 2019 15:58
Copy link
Contributor

@astefan astefan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In general it looks good. I left some comments mostly cosmetic.
Also, I would like to see some integration tests, as well. For example, x-pack\plugin\sql\qa\src\main\resources\select.sql-spec with actual queries involving duplicated columns being returned. An example query: SELECT salary, first_name, salary AS x FROM test_emp ORDER BY x LIMIT 3.

Also, in elasticsearch\x-pack\plugin\sql\qa\src\main\resources\agg.sql-spec I would add more queries. One example: SELECT gender AS g, gender, SUM(salary) AS s3, SUM(salary), SUM(salary) AS s5 FROM test_emp GROUP BY 2

@astefan astefan requested review from costin and matriv September 5, 2019 14:59
@matriv
Copy link
Contributor

matriv commented Sep 8, 2019

@emasab It would be great to also add tests to check if something breaks for the ordering on aggregates: https://github.com/elastic/elasticsearch/blob/master/x-pack/plugin/sql/qa/src/main/resources/agg-ordering.sql-spec when there is a duplicate column.

@astefan
Copy link
Contributor

astefan commented Sep 10, 2019

@emasab did you get the chance to review our feedback?

@emasab
Copy link
Contributor Author

emasab commented Sep 11, 2019

@astefan yes, it's almost ready. I was working on the other PR before

@emasab
Copy link
Contributor Author

emasab commented Sep 11, 2019

made the changes and added some integration tests but these three are failing, although they produce correct results when called manually through the rest api.

aggSumWithColumnRepeated
SELECT gender AS g, gender, SUM(salary) AS s3, SUM(salary), SUM(salary) AS s5 FROM test_emp GROUP BY gender;

aggSumWithAliasWithColumnRepeated
SELECT gender AS g, gender, SUM(salary) AS s3, SUM(salary), SUM(salary) AS s5 FROM test_emp GROUP BY g;

aggSumWithNumericRefWithColumnRepeated
SELECT gender AS g, gender, SUM(salary) AS s3, SUM(salary), SUM(salary) AS s5 FROM test_emp GROUP BY 2;

@astefan
Copy link
Contributor

astefan commented Sep 12, 2019

@elasticmachine test this please

@astefan
Copy link
Contributor

astefan commented Sep 12, 2019

@emasab I see why those are failing and it's ok.

Please, move those three to agg.csv-spec where you should also add the expected output. Follow the other queries examples in that file to add those three. If you need help, just ask. Thanks.

@astefan
Copy link
Contributor

astefan commented Sep 12, 2019

@emasab also, don't forget to add some tests following @matriv 's comment, as well. Thanks.

@emasab emasab force-pushed the bugfix/41811-wrong-number-of-values branch from 6a6e587 to 9b1dfea Compare September 12, 2019 22:27
@emasab emasab force-pushed the bugfix/41811-wrong-number-of-values branch from 9b1dfea to f650599 Compare September 20, 2019 22:17
@emasab
Copy link
Contributor Author

emasab commented Sep 20, 2019

rebased to current master

@emasab emasab force-pushed the bugfix/41811-wrong-number-of-values branch from f650599 to a305938 Compare September 25, 2019 18:41
Copy link
Contributor

@matriv matriv left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

Thank you for the contribution!
Thanks a lot for your patience and for addressing our comments.

@emasab
Copy link
Contributor Author

emasab commented Sep 26, 2019

@matriv I was happy to contribute! There is always to learn from such important projects.

@matriv
Copy link
Contributor

matriv commented Sep 30, 2019

@elasticmachine test this please

@matriv
Copy link
Contributor

matriv commented Sep 30, 2019

@elasticmachin run elasticsearch-ci/bwc

@matriv
Copy link
Contributor

matriv commented Sep 30, 2019

@elasticmachine update branch

@matriv
Copy link
Contributor

matriv commented Sep 30, 2019

@elasticmachine test this please

Copy link
Contributor

@astefan astefan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@matriv matriv merged commit 097ea36 into elastic:master Sep 30, 2019
matriv pushed a commit that referenced this pull request Sep 30, 2019
Previously, if a column (field, scalar, alias) appeared more than once in the
SELECT list, the value was returned only once (1st appearance) in each row.

Fixes: #41811

(cherry picked from commit 097ea36)
matriv pushed a commit that referenced this pull request Sep 30, 2019
Previously, if a column (field, scalar, alias) appeared more than once in the
SELECT list, the value was returned only once (1st appearance) in each row.

Fixes: #41811

(cherry picked from commit 097ea36)
matriv added a commit that referenced this pull request Sep 30, 2019
Previously, if a column (field, scalar, alias) appeared more than once in the
SELECT list, the value was returned only once (1st appearance) in each row.

Fixes: #41811

(cherry picked from commit 097ea36)
matriv pushed a commit that referenced this pull request Sep 30, 2019
Previously, if a column (field, scalar, alias) appeared more than once in the
SELECT list, the value was returned only once (1st appearance) in each row.

Fixes: #41811

(cherry picked from commit 097ea36)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants