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

[1.2.1~rc4] Subqueries; A function and WHERE tag clause in the main query returns no results #8045

Closed
rkuchan opened this issue Feb 22, 2017 · 1 comment
Assignees
Milestone

Comments

@rkuchan
Copy link
Contributor

rkuchan commented Feb 22, 2017

Bug report

System info:
Ubuntu 16.04, v1.2.1~rc4

Steps to reproduce:

  1. Write some data
> CREATE DATABASE mydb
> USE mydb
Using database mydb
> INSERT pond toads=2
> INSERT pond toads=4
> INSERT pond toads=9

> SELECT * FROM "pond"
name: pond
time                           toads
----                           -----
2017-02-22T17:44:35.234902449Z 2
2017-02-22T17:44:43.444176616Z 4
2017-02-22T17:44:49.651820179Z 9
  1. Run a subquery that includes just a function in the main query
> SELECT MEAN("toads") FROM (SELECT "toads" FROM "pond")
name: pond
time                 mean
----                 ----
1970-01-01T00:00:00Z 5

(This is fine)

  1. Run a subquery that includes just a WHERE clause in the main query
> SELECT "toads" FROM (SELECT "toads" FROM "pond") WHERE "toads" > 3
name: pond
time                           toads
----                           -----
2017-02-22T17:44:43.444176616Z 4
2017-02-22T17:44:49.651820179Z 9

(This is also fine)

  1. Run a subquery that includes both a function and a WHERE clause in the main query
> SELECT MEAN("toads") FROM (SELECT "toads" FROM "pond") WHERE "toads" > 3
>

(Unexpectedly - no results)

Expected behavior:
I'd expect the query in step 4 to return the average value of toads calculated across values of toad that are greater than three:

name: pond
time                 mean
----                 ----
1970-01-01T00:00:00Z 6.5

Actual behavior:
The query in step 4 returns no results.

Additional information:
Queries with a subquery, a function in the main query, and a WHERE time clause in the main query behave as expected:

> SELECT MEAN("toads") FROM (SELECT "toads" FROM "pond") WHERE time >= '2017-02-22T17:44:43.444176616Z' AND time <= '2017-02-22T17:44:49.651820179Z'
name: pond
time                           mean
----                           ----
2017-02-22T17:44:43.444176616Z 6.5

Taken from a Google Groups post: https://groups.google.com/forum/#!topic/influxdb/MOSSMVdFz2g

@rkuchan rkuchan changed the title [1.2.1~rc4] Subqueries; A function and WHERE clause in the main query returns no results [1.2.1~rc4] Subqueries; A function and WHERE tag clause in the main query returns no results Feb 22, 2017
@emmenko
Copy link

emmenko commented Feb 22, 2017

This also relates to this other thread https://groups.google.com/d/msg/influxdb/JSm6cdgeSPE/5cwpWP-qAwAJ

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants