You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Define a numeric index on a Redis State Store (i.e. an index with a Timestamp attribute), then search with criteria that involve it.
The criteria should be correctly evaluated and applied.
Actual Behavior
When the numeric is larger than https://pkg.go.dev/fmt configured threshold, scientific notation is used to represent the number and comparisons do not work anymore in the generated Redis Query.
Steps to Reproduce the Problem
Create a Redis State Store with an index on a numeric attribute, as described here.
Then invoke the Query API on it with this template curl command:
curl -v --location 'http://localhost:3500/v1.0-alpha1/state/redis-state-store/query?metadata.contentType=application/json&metadata.queryIndexName=myRedisIndexName' \ --header 'Content-Type: application/json' \ --data '{ "filter": { "GT": { "header.timestamp": NUMBER_HERE } }, "page":{ "limit": 2 }, "sort":[ { "key":"header.timestamp", "order":"DESC" } ] }'
Connect to Redis with RedisCLI and launch the "MONITOR" command.
When NUMBER_HERE is 1.2 or 100000 you'll see the following outputs:
Expected Behavior
Define a numeric index on a Redis State Store (i.e. an index with a Timestamp attribute), then search with criteria that involve it.
The criteria should be correctly evaluated and applied.
Actual Behavior
When the numeric is larger than https://pkg.go.dev/fmt configured threshold, scientific notation is used to represent the number and comparisons do not work anymore in the generated Redis Query.
Steps to Reproduce the Problem
Create a Redis State Store with an index on a numeric attribute, as described here.
Then invoke the Query API on it with this template curl command:
curl -v --location 'http://localhost:3500/v1.0-alpha1/state/redis-state-store/query?metadata.contentType=application/json&metadata.queryIndexName=myRedisIndexName' \ --header 'Content-Type: application/json' \ --data '{ "filter": { "GT": { "header.timestamp": NUMBER_HERE } }, "page":{ "limit": 2 }, "sort":[ { "key":"header.timestamp", "order":"DESC" } ] }'
Connect to Redis with RedisCLI and launch the "MONITOR" command.
When NUMBER_HERE is 1.2 or 100000 you'll see the following outputs:
"FT.SEARCH" "rawEventsIndx" "@var1:[(1.2 +inf]" "SORTBY" "var1" "DESC" "LIMIT" "0" "2" "RETURN" "2" "$.data" "$.version"
"FT.SEARCH" "rawEventsIndx" "@var1:[(100000 +inf]" "SORTBY" "var1" "DESC" "LIMIT" "0" "2" "RETURN" "2" "$.data" "$.version"
and you get the correct results, but when NUMBER_HERE is 1000000, you get
"FT.SEARCH" "rawEventsIndx" "@var1:[(1e+06 +inf]" "SORTBY" "var1" "DESC" "LIMIT" "0" "2" "RETURN" "2" "$.data" "$.version"
and no result.
The solution might be (I do not know GoLang at all) in all occurrences of these lines:
https://github.com/dapr/components-contrib/blob/main/state/redis/redis_query.go#L107-L112
use "%d" as format specifier in the default branch and add a branch for float64, float32 types
that uses "%f" as format specifier.
Release Note
RELEASE NOTE: FIX Numeric operators on Redis State Store query API.
The text was updated successfully, but these errors were encountered: