redis-field-engineering / redis-sql-trino

Real-time Indexed SQL Queries for Redis
MIT License
34 stars 4 forks source link

Failing to SELECT from JSON - based table #8

Closed antonum closed 1 year ago

antonum commented 1 year ago

Redis-SQL sees both HASH and JSON-based tables with show tables, but fails to select anything from JSON-based table with Table 'redisearch.default.beersjson' does not exist error.

To reproduce:

1) Adjust docker-compose.yaml to use image: redis/redis-stack for Redis container. Run it.

2) Create HASH and JSON - based RediSearch indices:

docker exec redis redis-cli FT.CREATE beers ON HASH PREFIX 1 beer: SCHEMA id TAG SORTABLE brewery_id TAG SORTABLE name TEXT SORTABLE abv NUMERIC SORTABLE descript TEXT style_name TAG SORTABLE cat_name TAG SORTABLE

docker exec redis redis-cli FT.CREATE beersJSON ON JSON PREFIX 1 beerJSON: SCHEMA id TAG brewery_id TAG  name TEXT SORTABLE abv NUMERIC SORTABLE descript TEXT style_name TAG  cat_name TAG 

3) shell into trino container and try SHOW TABLES; - it would show both tables. Then SELECT * from beers; and select * from beersjson;. Select from HASH-based table would succeed, select from JSON-based would fail.

~ docker exec -it trino trino --catalog redisearch --schema default
trino:default> show tables;
   Table   
-----------
 beers     
 beersjson 
(2 rows)

Query 20230105_144630_00001_9buqf, FINISHED, 1 node
Splits: 5 total, 5 done (100.00%)
12.28 [2 rows, 48B] [0 rows/s, 4B/s]

trino:default> select * from beers;
 id | brewery_id | name | abv | descript | style_name | cat_name 
----+------------+------+-----+----------+------------+----------
(0 rows)

Query 20230105_144654_00002_9buqf, FINISHED, 1 node
Splits: 1 total, 1 done (100.00%)
3.25 [0 rows, 0B] [0 rows/s, 0B/s]

trino:default> select * from beersjson;
Query 20230105_144706_00004_9buqf failed: line 1:15: Table 'redisearch.default.beersjson' does not exist
antonum commented 1 year ago

@jruaux suggested that the issue might be with the case sensitivity of the index name. The same JSON-based index with all lowercase characters in the name worked as expected.

jruaux commented 1 year ago

If you want there is also a setting for case-insensitive matching on table (aka index) names: redisearch.case-insensitive-names

https://redis-field-engineering.github.io/redis-sql/#configuration