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

[influxdb/v2] differing influxql results when comparing field to signed vs unsigned integer #25011

Open
jdstrand opened this issue May 15, 2024 · 0 comments

Comments

@jdstrand
Copy link
Contributor

jdstrand commented May 15, 2024

An external reporter sent an issue regarding InfluxQL queries in 2.x. Using 2.7.6, comparing a field to a signed integer works as expected. Eg:

$  export V1AUTH=$(echo -n "anything:$TOKEN" | base64 --wrap 0)

# generate some line protocol 
$ cat > file.lp <<EOM
t0,t0_tag0=initTag t0_f0=0i 1715694000
t0,t0_tag0=initTag t0_f0=1i 1715694001
t0,t0_tag1=initTag t0_f0=0i 1715694000
EOM

# write
$ curl -H "Authorization: Basic $V1AUTH" -X POST "$URL/write?db=test1&precision=s" --data-binary @./file.lp
$

# queries
# ok
$ curl -H "Authorization: Basic $V1AUTH" -H "Accept: application/csv" -X POST "$URL/query?db=test1&rp=autogen" --data-urlencode "q=select * from t0"
name,tags,time,t0_f0,t0_tag0,t0_tag1
t0,,1715694000000000000,0,initTag,
t0,,1715694000000000000,0,,initTag
t0,,1715694001000000000,1,initTag,

# ok with signed ints
$ curl -H "Authorization: Basic $V1AUTH" -H "Accept: application/csv" -X POST "$URL/query?db=test1&rp=autogen" --data-urlencode "q=select * from t0 where (1) < (17693) ORDER BY ASC LIMIT 2147483647"
name,tags,time,t0_f0,t0_tag0,t0_tag1
t0,,1715694000000000000,0,initTag,
t0,,1715694000000000000,0,,initTag
t0,,1715694001000000000,1,initTag,

$ curl -H "Authorization: Basic $V1AUTH" -H "Accept: application/csv" -X POST "$URL/query?db=test1&rp=autogen" --data-urlencode "q=select * from t0 where (t0_f0) < (17693) ORDER BY  ASC LIMIT 2147483647"
name,tags,time,t0_f0,t0_tag0,t0_tag1
t0,,1715694000000000000,0,initTag,
t0,,1715694000000000000,0,,initTag
t0,,1715694001000000000,1,initTag,

But comparing a field to an unsigned integer does not:

$  export V1AUTH=$(echo -n "anything:$TOKEN" | base64 --wrap 0)

# generate some line protocol 
$ cat > file2.lp <<EOM
t0,t0_tag0=initTag t0_f0=0u 1715694000
t0,t0_tag0=initTag t0_f0=1u 1715694001
t0,t0_tag1=initTag t0_f0=0u 1715694000
EOM

# write
$ curl -H "Authorization: Basic $V1AUTH" -X POST "$URL/write?db=test2&precision=s" --data-binary @./file2.lp
$

# queries
# ok
$ curl -H "Authorization: Basic $V1AUTH" -H "Accept: application/csv" -X POST "$URL/query?db=test2&rp=autogen" --data-urlencode "q=select * from t0"
name,tags,time,t0_f0,t0_tag0,t0_tag1
t0,,1715694000000000000,0,initTag,
t0,,1715694000000000000,0,,initTag
t0,,1715694001000000000,1,initTag,

# this query ok with unsigned int
$ curl -H "Authorization: Basic $V1AUTH" -H "Accept: application/csv" -X POST "$URL/query?db=test2&rp=autogen" --data-urlencode "q=select * from t0 where (1u) < (17693u) ORDER BY ASC LIMIT 2147483647"
name,tags,time,t0_f0,t0_tag0,t0_tag1
t0,,1715694000000000000,0,initTag,
t0,,1715694000000000000,0,,initTag
t0,,1715694001000000000,1,initTag,

# but this one is NOT
$ curl -H "Authorization: Basic $V1AUTH" -H "Accept: application/csv" -X POST "$URL/query?db=test2&rp=autogen" --data-urlencode "q=select * from t0 where (t0_f0) < (17693u) ORDER BY ASC LIMIT 2147483647"
$

# ok if change 17693u to 17693
$ curl -H "Authorization: Basic $V1AUTH" -H "Accept: application/csv" -X POST "$URL/query?db=test2&rp=autogen" --data-urlencode "q=select * from t0 where (t0_f0) < (17693) ORDER BY ASC LIMIT 2147483647"
name,tags,time,t0_f0,t0_tag0,t0_tag1
t0,,1715694000000000000,0,initTag,
t0,,1715694000000000000,0,,initTag
t0,,1715694001000000000,1,initTag,

InfluxDB 1.x does not support unsigned integers (see https://docs.influxdata.com/influxdb/v1/write_protocols/line_protocol_reference/ and https://docs.influxdata.com/enterprise_influxdb/v1/write_protocols/line_protocol_reference/ vs https://docs.influxdata.com/influxdb/v2/reference/syntax/line-protocol/). It operates correctly with signed integers.

cc @davidby-influx

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

1 participant