cswinter / LocustDB

Blazingly fast analytics database that will rapidly devour all of your data.
Other
1.62k stars 72 forks source link

Order by string column fails with `top_n_asc not supported for type ScalarStr` #132

Open jrmuizel opened 4 years ago

jrmuizel commented 4 years ago

With https://flatteningthecurve.herokuapp.com/data/canadatesting

$ ./repl --load /tmp/canada_testing.csv
locustdb> select * from default where province = 'Ontario' order by 'date'
Some assumption was violated. This is a bug: top_n_asc not supported for type ScalarStr
cswinter commented 4 years ago

This query is asking to order by the constant string 'date'. I'll have to think about what the semantics of that should be, but it's likely not what is intended. A more useful query would be select * from default where province = 'Ontario' order by date but for some reason this fails to parse. I'm not sure why this is yet, the tests cover queries that are all but identical and work just fine.

jrmuizel commented 4 years ago

I actually meant select * from default where province = 'Ontario' order by "date" but that doesn't work either. I guess other databases let you quote column names by LocustDB treats it as a column of null.

select * from default where province = 'Ontario' order by date probably doesn't work because of https://github.com/andygrove/sqlparser-rs/issues/168.

cswinter commented 4 years ago

I think I found the bug, the double quotes are not getting removed by either the parser or LocustDB so they end as part of the column name which is why LocustDB doesn't find the column as assumes it as null. This should be an easy fix, PR incoming.

cswinter commented 4 years ago

The query select * from default where province = 'Ontario' order by "date" now succeeds on master, I'm kicking off a new release that has the fix (v0.3.3).