tidwall / tile38

Real-time Geospatial and Geofencing
https://tile38.com
MIT License
8.96k stars 561 forks source link

WHEREIN is not returning the correct count when field key is mixed case #704

Open erik66778899 opened 10 months ago

erik66778899 commented 10 months ago

Describe the bug WHEREIN is not returning the expected count when I use a field whose key is mixed case. The WHERE command returns the expected count. Both WHEREIN and WHERE return the expected count when I use a field whose key is lowercase.

To Reproduce Steps to reproduce the behavior:

drop test1234
set test1234 id1 field loadId 100 point 42.51 -71.41
set test1234 id2 field loadId 100 point 42.52 -71.42
set test1234 id3 field loadId 100 point 42.53 -71.43
set test1234 id4 field loadId 101 point 42.54 -71.44

SCAN test1234 WHEREIN loadId 1 100.0 COUNT
SCAN test1234 WHEREIN loadId 1 101.0 COUNT

SCAN test1234 WHERE loadId == 100.0 COUNT
SCAN test1234 WHERE loadId == 101.0 COUNT

Expected behavior I'd expect the returned counts for WHEREIN and WHERE to match. I've got 3 points with loadId==100 and 1 point with loadId==101. The counts for WHERE and WHEREIN with loadId 100 should return 3 and the counts for loadId 101 should return 1.

Logs Here's the tile38-cli output where I reproduce on 1.32.0

127.0.0.1:19851> info
{"ok":true,"info":{"aof_current_rewrite_time_sec":0,"aof_enabled":1,"aof_last_rewrite_time_sec":0,"aof_rewrite_in_progress":0,"cluster_enabled":0,"connected_clients":1,"connected_slaves":0,"expired_keys":0,"redis_version":"1.32.0","role":"master","tile38_version":"1.32.0","total_commands_processed":118,"total_connections_received":35,"total_messages_sent":0,"uptime_in_seconds":465568,"used_cpu_sys":4405,"used_cpu_sys_children":0,"used_cpu_user":2803,"used_cpu_user_children":0,"used_memory":3541216},"elapsed":"28.12ms"}
127.0.0.1:19851> 
127.0.0.1:19851> 
127.0.0.1:19851> 
127.0.0.1:19851> drop test1234
{"ok":true,"elapsed":"1.714292ms"}
127.0.0.1:19851> set test1234 id1 field loadId 100 point 42.51 -71.41
{"ok":true,"elapsed":"1.195917ms"}
127.0.0.1:19851> set test1234 id2 field loadId 100 point 42.52 -71.42
{"ok":true,"elapsed":"98.75µs"}
127.0.0.1:19851> set test1234 id3 field loadId 100 point 42.53 -71.43
{"ok":true,"elapsed":"6.209µs"}
127.0.0.1:19851> set test1234 id4 field loadId 101 point 42.54 -71.44
{"ok":true,"elapsed":"6.375µs"}
127.0.0.1:19851> 
127.0.0.1:19851> 
127.0.0.1:19851> SCAN test1234 WHEREIN loadId 1 100.0 COUNT
{"ok":true,"count":0,"cursor":0,"elapsed":"6.263625ms"}
127.0.0.1:19851> SCAN test1234 WHEREIN loadId 1 101.0 COUNT
{"ok":true,"count":0,"cursor":0,"elapsed":"26.084µs"}
127.0.0.1:19851> 
127.0.0.1:19851> SCAN test1234 WHERE loadId == 100.0 COUNT
{"ok":true,"count":3,"cursor":0,"elapsed":"122.084µs"}
127.0.0.1:19851> SCAN test1234 WHERE loadId == 101.0 COUNT
{"ok":true,"count":1,"cursor":0,"elapsed":"9.625µs"}
127.0.0.1:19851> 

Here's the cli output when I use a lowercase key

127.0.0.1:19851> drop test1234
{"ok":true,"elapsed":"52.458µs"}
127.0.0.1:19851> set test1234 id1 field loadid 100 point 42.51 -71.41
{"ok":true,"elapsed":"303.375µs"}
127.0.0.1:19851> set test1234 id2 field loadid 100 point 42.52 -71.42
{"ok":true,"elapsed":"20.375µs"}
127.0.0.1:19851> set test1234 id3 field loadid 100 point 42.53 -71.43
{"ok":true,"elapsed":"9µs"}
127.0.0.1:19851> set test1234 id4 field loadid 101 point 42.54 -71.44
{"ok":true,"elapsed":"11.042µs"}
127.0.0.1:19851> 
127.0.0.1:19851> 
127.0.0.1:19851> 
127.0.0.1:19851> 
127.0.0.1:19851> SCAN test1234 WHEREIN loadid 1 100.0 COUNT
{"ok":true,"count":3,"cursor":0,"elapsed":"479.959µs"}
127.0.0.1:19851> SCAN test1234 WHEREIN loadid 1 101.0 COUNT
{"ok":true,"count":1,"cursor":0,"elapsed":"424.5µs"}
127.0.0.1:19851> 
127.0.0.1:19851> SCAN test1234 WHERE loadid == 100.0 COUNT
{"ok":true,"count":3,"cursor":0,"elapsed":"150.666µs"}
127.0.0.1:19851> SCAN test1234 WHERE loadid == 101.0 COUNT
{"ok":true,"count":1,"cursor":0,"elapsed":"34.125µs"}
127.0.0.1:19851>

Operating System (please complete the following information):

Additional context This doesn't seem to be limited to COUNT. IDS doesn't work as expected in the same way. This is a small problem (assuming it's a bug). I can lowercase all my fields and move on with life.
WHEREIN was working as expected in 1.30.0. We were running 1.30.0 for a while and noticed this potential bug after upgrading to 1.31.0 WHEREIN does not work as expected in 1.30.1 - I believe this coincides with some field case changes. Maybe introduced here? I tested all the released versions from 1.30.0.

Also, this is a super cool project. Love it. Much appreciated!