-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
[0.9.2] Query with both raw and aggregates should throw error #3407
Comments
@otoolep not sure this is still an issue. The query that you entered should actually return an error because it's invalid. Can you verify this is still a problem? I think we have it updated to return a query error now. |
In 0.9.2 the behavior is weirder. The aggregate comes back as the only value and is assigned to the first column in the output. The other column is empty.
|
Aggregation functions are not valid with direct value selections. Selector functions (mix, max, etc.) that return a single point are valid for some queries and should be allowed. E.g. |
The following combinations are invalid: select field2, mean(field1) ...
select field2, sum(field1) ...
select field2, count(field1) ...
select field2, percentile(field1, 90) ...
select field2, spread(field1) ...
select field2, stddev(field1) ...
select field2, median(field1) ...
select field2, distinct(field1) ...
select field2, derivative(field1) ... The other aggregates select a single data point, so it's valid to select another field or tag along with those functions. These include |
@pauldix what about TOP and BOTTOM? I would think those can return more than one value so should be invalid. |
Verified partially fixed in 0.9.3 nightly:
|
@beckettsean -- which part is not fixed? |
@pauldix's comment implies that for MIN, MAX, FIRST, and LAST the error should not be thrown, but it is:
|
@otoolep ^^ |
This is not an trivial fix to our code. A query with Supporting the mixed statements is a significant change to our code. This restriction has been in place since 0.9.0. |
@beckettsean TOP and BOTTOM are both valid. There are two different cases: select top(value, 5), host from cpu where time > now() - 1h The reason that is valid is because it will return 5 data points per group by interval (in this case the entire time range we're looking at), and each of those maps to a single point. This query is also valid: select top(mean(value), 5), host from cpu where time > now() -1h What this query should do is compute the mean for each host in the interval, then get the top 5 means and output those. Those features aren't wired up yet, so it's probably best to return an error for all functions that have an aggregate and a single field or tag along with them for now. I'll update the TOP, BOTTOM, and select with aggregate issues to references this one. |
What about this query? select count(amount), type from order where time <= now() and time >= (now() - 2h) and type = 'x' group by time(1h) I would to copy the aggregation of points of type x into another RP. Atm I get: ERR: error parsing query: mixing aggregate and non-aggregate queries is not supported Version: 2016/02/03 09:41:58 InfluxDB starting, version 0.9.6.1, branch 0.9.6, commit 6d3a860, built unknown |
@peterbollen that's invalid since |
This works in the new query engine so I'm going to close it. Please reopen if this is still an issue. |
Verified fixed in 0.11, at least in some cases:
|
@beckettsean it's great to be able to retrieve values and tags associated with a max or min value. Not usually easy to do with a database. However, my question is: Is it possible to do the same with the timestamp? For example:
Is there any way to obtain the timestamp of the measure corresponding to the min value? |
If there is a GROUP BY clause in the query, the returned timestamps will always be a GROUP BY interval boundary, not the actual timestamp of the point. This is the current implementation, and we hope to return the full point even with GROUP BY clauses, but it will require substantial effort and likely won't be a 1.0 feature. |
I get "...mixing aggregate and non-aggregate queries is not supported" |
@michapr that is intended behavior. You should not repeat the |
@beckettsean I try to select the mean on a field value, I used the group by on some tags. how can I get tags information in return query set? I only get the mean column in return query set. |
Not sure if this expected, but a combination raw and aggregate query doesn't work as one might expect. I checked 0.9.1 (pre-DQ work) and it also suffers from the same problem.
Results:
The text was updated successfully, but these errors were encountered: