-
Notifications
You must be signed in to change notification settings - Fork 24.4k
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: selecting a literal from grouped by query generates error #41964
Conversation
@codebird thank you for raising the PR. We'll be looking at it, but there may be some time until then. There are several issues in flight related to literals in different scenarios and definitely this one is similar. |
Pinging @elastic/es-search |
@astefan now all 3 issues are solved. 35483 is a bit hacky solution. I'll keep on looking into it... But well if you guys check it before I find anything... |
@astefan is this pull request dead? Shall I close it? |
# Conflicts: # x-pack/plugin/sql/src/main/java/org/elasticsearch/xpack/sql/optimizer/Optimizer.java # x-pack/plugin/sql/src/main/java/org/elasticsearch/xpack/sql/planner/QueryFolder.java
# Conflicts: # x-pack/plugin/sql/src/main/java/org/elasticsearch/xpack/sql/analysis/analyzer/Analyzer.java # x-pack/plugin/sql/src/main/java/org/elasticsearch/xpack/sql/execution/search/Querier.java # x-pack/plugin/sql/src/main/java/org/elasticsearch/xpack/sql/optimizer/Optimizer.java # x-pack/plugin/sql/src/main/java/org/elasticsearch/xpack/sql/planner/QueryFolder.java
# Conflicts: # x-pack/plugin/sql/src/main/java/org/elasticsearch/xpack/sql/optimizer/Optimizer.java # x-pack/plugin/sql/src/main/java/org/elasticsearch/xpack/sql/planner/QueryFolder.java
Could you please add some unit tests ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Left a couple of comments
x-pack/plugin/sql/src/main/java/org/elasticsearch/xpack/sql/planner/QueryFolder.java
Outdated
Show resolved
Hide resolved
x-pack/plugin/sql/src/main/java/org/elasticsearch/xpack/sql/analysis/analyzer/Analyzer.java
Outdated
Show resolved
Hide resolved
Don't know what I was thinking to write integrity at the place of integration in my commit message |
x-pack/plugin/sql/src/main/java/org/elasticsearch/xpack/sql/planner/QueryFolder.java
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This LGTM. Thank you for doing all of this and being so patient.
I hate to be the "party" breaker here, but I would like to see one more test, that @matriv also suggested in one of his reviews, but from what I can see, it's missing: #41964 (comment)
I tested the following query and it works, but I would also like to have it in the tests: SELECT 144 / 12 AS division, 1, 2 AS x, 1 + 2 FROM test_emp GROUP BY gender, salary
.
Thanks again.
@astefan the test fails because of the column name of 1 + 2 H2 names it 3, ES names it 1 + 2 that's why I added an alias to the addition. Shall we open another issue concerning this, or this is acceptable? |
@codebird an alias is fine, thank you. No need for another issue, as I believe we are doing the right thing by keeping the column name as |
@elasticmachine run elasticsearch-ci/2 |
@codebird I'd like to ask you for one more change please.
|
much more elegant indeed. |
x-pack/plugin/sql/src/main/java/org/elasticsearch/xpack/sql/analysis/analyzer/Analyzer.java
Outdated
Show resolved
Hide resolved
x-pack/plugin/sql/src/main/java/org/elasticsearch/xpack/sql/analysis/analyzer/Analyzer.java
Outdated
Show resolved
Hide resolved
x-pack/plugin/sql/src/main/java/org/elasticsearch/xpack/sql/analysis/analyzer/Analyzer.java
Outdated
Show resolved
Hide resolved
x-pack/plugin/sql/src/main/java/org/elasticsearch/xpack/sql/optimizer/Optimizer.java
Show resolved
Hide resolved
Thanks a lot once again @codebird for your patience and your overall effort on this contribution! |
Np.thanks for the good mentoring @matriv |
Translate to an agg query even if only literals are selected, so that the correct number of rows is returned (number of buckets). Fix issue with key only in GROUP BY (not in select) and WHERE clause: Resolve aggregates and groupings based on the child plan which holds the info info for all the fields of the underlying table. Fixes: #41951 Fixes: #41413 (cherry picked from commit 45b8580)
Translate to an agg query even if only literals are selected, so that the correct number of rows is returned (number of buckets). Fix issue with key only in GROUP BY (not in select) and WHERE clause: Resolve aggregates and groupings based on the child plan which holds the info info for all the fields of the underlying table. Fixes: #41951 Fixes: #41413 (cherry picked from commit 45b8580)
related to #41951 and #41413