filesql
Running SQL-like queries on files.
Features
Supported:
- REPL
- Basic SQL expressions.
- INSERT clause. (which inserts data into another file)
- WHERE clause.
- ORDER BY clause. (Only in-memory sorting)
- LIMIT clause.
Todo:
- GROUP BY clause. (in-memory)
- GROUP BY clause. (external storage)
- ORDER BY clause. (external storage)
- Optimization.
- ...
Sample
Query countries list top rated by Covid-19 infected cases:
$ target/release/filesql -f testcases/select-top-10-infected-and-calc-death-rate.sql
Outputs:
+---------+--------------+----------------+-----------------+-------------+---------------------+
| country | infected_new | infected_total | recovered_total | death_total | death_rate |
+---------+--------------+----------------+-----------------+-------------+---------------------+
| 美国 | 92226 | 47314139 | 37311667 | 775104 | 1.638207978380416 |
+---------+--------------+----------------+-----------------+-------------+---------------------+
| 印度 | 11210 | 34355184 | 33741010 | 460788 | 1.341247364589868 |
+---------+--------------+----------------+-----------------+-------------+---------------------+
| 巴西 | 13321 | 21874324 | 21062218 | 609417 | 2.785992380838832 |
+---------+--------------+----------------+-----------------+-------------+---------------------+
| 英国 | 33697 | 9272066 | 7560948 | 141743 | 1.5287099983973367 |
+---------+--------------+----------------+-----------------+-------------+---------------------+
| 乌干达 | 85 | 9126570 | 96878 | 3227 | 0.03535829999660332 |
+---------+--------------+----------------+-----------------+-------------+---------------------+
| 俄罗斯 | 41335 | 8795095 | 7561978 | 246814 | 2.806268721372538 |
+---------+--------------+----------------+-----------------+-------------+---------------------+
| 土耳其 | 28193 | 8206375 | 7680152 | 71927 | 0.8764771290612481 |
+---------+--------------+----------------+-----------------+-------------+---------------------+
| 法国 | 8998 | 7208937 | 6971152 | 117900 | 1.6354699728961426 |
+---------+--------------+----------------+-----------------+-------------+---------------------+
| 伊朗 | 6803 | 5987814 | 5601764 | 127299 | 2.1259678406844302 |
+---------+--------------+----------------+-----------------+-------------+---------------------+
| 阿根廷 | 1271 | 5296188 | 5162713 | 116091 | 2.1919727925066104 |
+---------+--------------+----------------+-----------------+-------------+---------------------+
10 rows selected.
Supported file formats
- CSV/TSV