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

Cannot select tag when using set functions #7802

Closed
inselbuch opened this issue Jan 7, 2017 · 2 comments
Closed

Cannot select tag when using set functions #7802

inselbuch opened this issue Jan 7, 2017 · 2 comments
Labels
area/influxql Issues related to InfluxQL query language flux/triaged

Comments

@inselbuch
Copy link

Bug report

System info:
InfluxDB 1.0.2
Ubuntu 16.04.1 LTS

Steps to reproduce:

  1. create database sandbox

  2. use sandbox

  3. insert some data
    insert m1,t1=aa f1=6.3,f2=11.34
    insert m1,t1=aa f1=6.2,f2=20.26
    insert m1,t1=aa f1=3.1,f2=51.24
    insert m1,t1=aa f1=2.4,f2=20.36
    insert m1,t1=aa f1=1.5,f2=11.24
    insert m1,t1=aa f1=9.6,f2=0.26
    insert m1,t1=ab f1=8.7,f2=17.25
    insert m1,t1=ab f1=5.8,f2=81.24
    insert m1,t1=ab f1=7.9,f2=11.23
    insert m1,t1=ab f1=5.1,f2=10.22
    insert m1,t1=ab f1=7.2,f2=11.21
    insert m1,t1=ab f1=5.3,f2=10.3

  4. run these queries

a) select t1,max(f1),min(f2) from m1 group by t1
b) select t1,max(f1),min(f2) from m1 where t1='aa'

Expected behavior:

In both cases, t1 should be available to select.

a) The group by clause segments the returned rows into subsets with identical characteristics. In this case each subset must have an identical t1. Hence t1 should be selectable and reported for each subset of rows. This is SQL standard.

b) By restricting all returned rows to a specific tag (in the case of the where clause), t1 has a constant value for the entire set of rows examined. The set functions max and min return results about the set of rows. t1 is also a known fact about the set of rows. This is non-Standard SQL.

Actual behavior: [What actually happened]

ERR: error parsing query: mixing multiple selector functions with tags or fields is not supported

@e-dard e-dard added the area/influxql Issues related to InfluxQL query language label Jan 9, 2017
@jsternberg
Copy link
Contributor

Since you are using two selectors at the same time, you can't select tags or fields with the selector. This is because the query wouldn't be able to figure out if it was supposed to select the field/tag related to the first selector or the second selector.

This is working as expected.

@juvenn
Copy link

juvenn commented Dec 18, 2018

Hi @jsternberg

it was supposed to select the field/tag related to the first selector or the second selector.

While I understand there are implementation details that make this non-trivial, but from a standpoint of sql user, I think we can safely assume it was supposed to select tag related to group by? at least in the case of a) as outlined by @inselbuch .

Or what alternatives would you propose for the query?

select t1,max(f1),min(f2) from m1 group by t1;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/influxql Issues related to InfluxQL query language flux/triaged
Projects
None yet
Development

No branches or pull requests

5 participants