Skip to content

SQL: selecting a literal and an aggregate generates an error #41411

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

Closed
astefan opened this issue Apr 22, 2019 · 3 comments
Closed

SQL: selecting a literal and an aggregate generates an error #41411

astefan opened this issue Apr 22, 2019 · 3 comments
Assignees
Labels

Comments

@astefan
Copy link
Contributor

astefan commented Apr 22, 2019

sql> **select 123, max(salary) from test_emp group by gender;**
Server error [Server encountered an error [Cannot find group [123]]. [SqlIllegalArgumentException[Cannot find group [123]]
        at org.elasticsearch.xpack.sql.util.Check.notNull(Check.java:36)
        at org.elasticsearch.xpack.sql.planner.QueryFolder$FoldAggregate.rule(QueryFolder.java:371)
        at org.elasticsearch.xpack.sql.planner.QueryFolder$FoldAggregate.rule(QueryFolder.java:205)
        at org.elasticsearch.xpack.sql.tree.Node.lambda$transformUp$11(Node.java:196)
        at org.elasticsearch.xpack.sql.tree.Node.transformUp(Node.java:190)
        at org.elasticsearch.xpack.sql.tree.Node.transformUp(Node.java:196)
        at org.elasticsearch.xpack.sql.planner.QueryFolder$FoldingRule.apply(QueryFolder.java:593)
@astefan astefan self-assigned this Apr 22, 2019
@elasticmachine
Copy link
Collaborator

Pinging @elastic/es-search

@PhaedrusTheGreek
Copy link
Contributor

PhaedrusTheGreek commented Jul 24, 2019

I'm hitting this too using date functions with aggregates:

SELECT CURRENT_TIMESTAMP as result, stream, start_event, end_event, (end_event-start_event)  as duration from (SELECT stream, min(time) AS start_event, max(time) AS end_event FROM test group by stream)

fails with :

[essql] > Unexpected error from Elasticsearch: [sql_illegal_argument_exception] Cannot find group [result]

The INTERVAL function is also failing with a similar error

SELECT stream, start_event, end_event, (end_event-start_event)  as duration_numeric,  INTERVAL 1 DAY AS duration from (SELECT stream, min(time) AS start_event, max(time) AS end_event FROM test group by stream)
[essql] > Unexpected error from Elasticsearch: [sql_illegal_argument_exception] Cannot find group [duration]

@matriv
Copy link
Contributor

matriv commented Feb 4, 2020

This is resolved probably as part of #49570

@matriv matriv closed this as completed Feb 4, 2020
matriv added a commit to matriv/elasticsearch that referenced this issue Feb 4, 2020
Add unit and integration tests where literals are SELECTed
in combination with GROUP BY and possibly aggregate functions.

Relates to elastic#41411 and elastic#34583
which have been fixed.
matriv added a commit that referenced this issue Feb 5, 2020
Add unit and integration tests where literals are SELECTed
in combination with GROUP BY and possibly aggregate functions.

Relates to #41411 and #34583
which have been fixed.
matriv added a commit that referenced this issue Feb 5, 2020
Add unit and integration tests where literals are SELECTed
in combination with GROUP BY and possibly aggregate functions.

Relates to #41411 and #34583
which have been fixed.

(cherry picked from commit b97f1ca)
matriv added a commit that referenced this issue Feb 5, 2020
Add unit and integration tests where literals are SELECTed
in combination with GROUP BY and possibly aggregate functions.

Relates to #41411 and #34583
which have been fixed.

(cherry picked from commit b97f1ca)
matriv pushed a commit that referenced this issue Feb 7, 2020
…#42121)

The related issue regarding aggregation queries where some literals
are also selected together with aggregate function has been fixed
with #49570. Add integration tests to verify the behavior.

Relates to: #41411
matriv pushed a commit that referenced this issue Feb 7, 2020
…#42121)

The related issue regarding aggregation queries where some literals
are also selected together with aggregate function has been fixed
with #49570. Add integration tests to verify the behavior.

Relates to: #41411

(cherry picked from commit 9f414a8)
matriv pushed a commit that referenced this issue Feb 7, 2020
…#42121)

The related issue regarding aggregation queries where some literals
are also selected together with aggregate function has been fixed
with #49570. Add integration tests to verify the behavior.

Relates to: #41411

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

No branches or pull requests

4 participants