LocustDB
LocustDB copied to clipboard
Order by string column fails with `top_n_asc not supported for type ScalarStr`
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
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.
- [x] Add new test case that triggers the parse error
- [x] Find and fix bug that prevents the query from getting parsed
- [ ] Figure out and implement the semantics of ordering by constant expression or reject such queries with meaningful error messages
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.
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.
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).