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

[0.9.6] Query with where filter by field value and tag output incorrect results #5152

Closed
spamik opened this issue Dec 17, 2015 · 2 comments
Closed
Assignees
Milestone

Comments

@spamik
Copy link

spamik commented Dec 17, 2015

Simple example, I push these values to measurement (two fields, one tag with two values):

bugtest,varname=a vala=1000
bugtest,varname=a vala=2000
bugtest,varname=a vala=200000
bugtest,varname=b valb=500
bugtest,varname=b valb=600
bugtest,varname=b valb=700

Now, these queries runs OK:
select * from bugtest where varname <> 'a' (results only 3 rows with varname=b)
select * from bugtest where vala < 10000 (results only 2 rows with varname=a)

Now I want to combine it to get all varname=b and varname=a where vala < 10000:
select * from bugtest where vala < 10000 or varname <> 'a'

I believe that this should work (returns 5 rows) but i gets me all 6 rows in measurement. I believe that this is bug because I think, that row varname=a vala=200000 shouldn't pass this condition. Tested on v0.9.6.

@jackzampolin jackzampolin changed the title Query with where filter by field value and tag output incorrect results [0.9.6] Query with where filter by field value and tag output incorrect results Dec 18, 2015
@jackzampolin
Copy link
Contributor

Reproduced:

> create database mydb
> use mydb
Using database mydb
> insert bugtest,varname=a vala=1000
> insert bugtest,varname=a vala=2000
> insert bugtest,varname=a vala=200000
> insert bugtest,varname=b vala=500
> insert bugtest,varname=b vala=600
> insert bugtest,varname=b vala=700
> select * from bugtest where varname <> 'a'
name: bugtest
-------------
time            vala    varname
1450476630737016697 500 b
1450476635641078835 600 b
1450476638321128276 700 b

> select * from bugtest where vala < 10000
name: bugtest
-------------
time            vala    varname
1450476599190718038 1000    a
1450476605648166045 2000    a
1450476630737016697 500 b
1450476635641078835 600 b
1450476638321128276 700 b

> select * from bugtest where vala < 10000 or varname <> 'a'
name: bugtest
-------------
time            vala    varname
1450476599190718038 1000    a
1450476605648166045 2000    a
1450476622072554912 200000  a
1450476630737016697 500 b
1450476635641078835 600 b
1450476638321128276 700 b

@beckettsean
Copy link
Contributor

Possibly related to #4917, although not an exact duplicate, since the vala=200000 varname=a point shouldn't match either OR clause.

@jsternberg jsternberg self-assigned this Mar 15, 2016
@jsternberg jsternberg added this to the 0.12.0 milestone Mar 15, 2016
jsternberg added a commit that referenced this issue Mar 15, 2016
If an OR was used, merging filters between different expressions would
not work correctly. If one of the sides had a set of series ids with a
condition and the other side had no series ids associated with the
expression, all of the series from the side with a condition would have
the condition ignored. Instead of defaulting a non-existant series
filter to true, it should just be false and the evaluation of the one
side that does exist should take care of determining if the series id
should be included or not. The AND condition used false correctly so did
not have to be changed.

If a tag did not exist and `!=` or `!~` were used, it would return false
even though the neither a field or a tag equaled those values. This has
now been modified to correctly return the correct series ids and the
correct condition.

Also fixed a panic that would occur when a tag caused a field access to
become unnecessary. The filter using the field access still got created
and used even though it was unnecessary, resulting in an attempted
access to a non-initialized map.

Fixes #5152 and a bunch of other miscellaneous issues.
jsternberg added a commit that referenced this issue Mar 15, 2016
If an OR was used, merging filters between different expressions would
not work correctly. If one of the sides had a set of series ids with a
condition and the other side had no series ids associated with the
expression, all of the series from the side with a condition would have
the condition ignored. Instead of defaulting a non-existant series
filter to true, it should just be false and the evaluation of the one
side that does exist should take care of determining if the series id
should be included or not. The AND condition used false correctly so did
not have to be changed.

If a tag did not exist and `!=` or `!~` were used, it would return false
even though the neither a field or a tag equaled those values. This has
now been modified to correctly return the correct series ids and the
correct condition.

Also fixed a panic that would occur when a tag caused a field access to
become unnecessary. The filter using the field access still got created
and used even though it was unnecessary, resulting in an attempted
access to a non-initialized map.

Fixes #5152 and a bunch of other miscellaneous issues.
jsternberg added a commit that referenced this issue Mar 22, 2016
If an OR was used, merging filters between different expressions would
not work correctly. If one of the sides had a set of series ids with a
condition and the other side had no series ids associated with the
expression, all of the series from the side with a condition would have
the condition ignored. Instead of defaulting a non-existant series
filter to true, it should just be false and the evaluation of the one
side that does exist should take care of determining if the series id
should be included or not. The AND condition used false correctly so did
not have to be changed.

If a tag did not exist and `!=` or `!~` were used, it would return false
even though the neither a field or a tag equaled those values. This has
now been modified to correctly return the correct series ids and the
correct condition.

Also fixed a panic that would occur when a tag caused a field access to
become unnecessary. The filter using the field access still got created
and used even though it was unnecessary, resulting in an attempted
access to a non-initialized map.

Fixes #5152 and a bunch of other miscellaneous issues.
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