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

Suggest clarifying that GROUP BY and SELECT's fields should be non-overlapping #2654

Closed
jlebar opened this issue Feb 14, 2020 · 3 comments
Closed
Assignees

Comments

@jlebar
Copy link

jlebar commented Feb 14, 2020

In most SQL dialects that I have used, the fields in GROUP BY's must be a subset of those in SELECT'. For example SELECT foo, sum(bar) GROUP BY foo is legal, but SELECT sum(bar), GROUP BY foo is not legal.

In InfluxQL, I am understanding that it's the opposite. The sets of fields in SELECT and GROUP BY must be non-overlapping, otherwise I get err: mixing aggregate and non-aggregate queries is not supported.

I wonder if

a) The documentation could be explicit about this difference between InfluxQL and most other SQLs.

b) The error message could be improved?

URL for relevant page?

https://docs.influxdata.com/influxdb/v1.7/query_language/data_exploration/#the-group-by-clause

What products and version are you using?

InfluxDB 1.7

Where did you look before opening the issue?

I eventually found it in the docs, but it took me a while to figure it out...

@kelseiv kelseiv self-assigned this Feb 18, 2020
kelseiv pushed a commit that referenced this issue Feb 26, 2020
@kelseiv
Copy link
Contributor

kelseiv commented Feb 26, 2020

Thank you, @jlebar!

Updated docs to be more explicit about the following:

  • cannot GROUP BY fields
  • SELECT cannot include an aggregate function with any of the following:
    • non-aggregate/selector function
    • tag key
    • field key

In your example, including both an aggregate and non-aggregate value in the SELECT clause was the issue—you can overlap SELECT tags and GROUP BY tags.

I agree, the error message could be more explicit:
SELECT clause cannot include an aggregate function and a non-aggregate function, field key, or tag key.

PS. Error messages are updated in another repo—I’ll create an associated issue and link here so you know where it lands.

@kelseiv
Copy link
Contributor

kelseiv commented Feb 26, 2020

https://github.com/influxdata/docs.influxdata.com/pull/2672/files

@kelseiv
Copy link
Contributor

kelseiv commented Jun 27, 2020

@jlebar associated issue can be tracked here: influxdata/influxdb#18764

Thank you for reporting!

@kelseiv kelseiv closed this as completed Jun 27, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants