|
| 1 | +# Polars SQL |
| 2 | + |
| 3 | +## CLI |
| 4 | + |
| 5 | +You can build `polars-sql` with cargo. |
| 6 | + |
| 7 | +`$ cargo run --release --features=cli,parquet,csv,ipc` |
| 8 | + |
| 9 | +This will run the CLI loop: |
| 10 | + |
| 11 | +```bash |
| 12 | +Welcome to Polars CLI. Commands end with ; or \n |
| 13 | +Type help or \? for help. |
| 14 | +>> \? |
| 15 | +List of all client commands: |
| 16 | +dataframes \dd Show registered frames. |
| 17 | +help \? Display this help. |
| 18 | +register \rd Register new dataframe: \rd <name> <source> |
| 19 | +quit \q Exit |
| 20 | + |
| 21 | +>> register taxis /home/ritchie46/example/csv-benchmark/yellow_tripdata_2010-01.parquet |
| 22 | +Added dataframe "taxis" from file /home/ritchie46/example/csv-benchmark/yellow_tripdata_2010-01.parquet |
| 23 | +shape: (14863778, 18) |
| 24 | +┌───────────┬─────────────────────┬─────────────────────┬─────────────────┬─────┬─────────┬────────────┬──────────────┬──────────────┐ |
| 25 | +│ vendor_id ┆ pickup_datetime ┆ dropoff_datetime ┆ passenger_count ┆ ... ┆ mta_tax ┆ tip_amount ┆ tolls_amount ┆ total_amount │ |
| 26 | +│ --- ┆ --- ┆ --- ┆ --- ┆ ┆ --- ┆ --- ┆ --- ┆ --- │ |
| 27 | +│ str ┆ str ┆ str ┆ i64 ┆ ┆ f64 ┆ f64 ┆ f64 ┆ f64 │ |
| 28 | +╞═══════════╪═════════════════════╪═════════════════════╪═════════════════╪═════╪═════════╪════════════╪══════════════╪══════════════╡ |
| 29 | +│ VTS ┆ 2010-01-26 07:41:00 ┆ 2010-01-26 07:45:00 ┆ 1 ┆ ... ┆ 0.5 ┆ 0.0 ┆ 0.0 ┆ 5.0 │ |
| 30 | +├╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌┤ |
| 31 | +│ DDS ┆ 2010-01-30 23:31:00 ┆ 2010-01-30 23:46:12 ┆ 1 ┆ ... ┆ 0.5 ┆ 0.0 ┆ 0.0 ┆ 16.3 │ |
| 32 | +├╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌┤ |
| 33 | +│ DDS ┆ 2010-01-18 20:22:20 ┆ 2010-01-18 20:38:12 ┆ 1 ┆ ... ┆ 0.5 ┆ 0.0 ┆ 0.0 ┆ 12.7 │ |
| 34 | +├╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌┤ |
| 35 | +│ VTS ┆ 2010-01-09 01:18:00 ┆ 2010-01-09 01:35:00 ┆ 2 ┆ ... ┆ 0.5 ┆ 0.0 ┆ 0.0 ┆ 14.3 │ |
| 36 | +├╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌┤ |
| 37 | +│ ... ┆ ... ┆ ... ┆ ... ┆ ... ┆ ... ┆ ... ┆ ... ┆ ... │ |
| 38 | +├╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌┤ |
| 39 | +│ VTS ┆ 2010-01-09 12:52:00 ┆ 2010-01-09 13:15:00 ┆ 1 ┆ ... ┆ 0.5 ┆ 0.0 ┆ 0.0 ┆ 45.5 │ |
| 40 | +├╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌┤ |
| 41 | +│ CMT ┆ 2010-01-09 14:00:44 ┆ 2010-01-09 14:14:33 ┆ 1 ┆ ... ┆ 0.5 ┆ 0.0 ┆ 0.0 ┆ 8.6 │ |
| 42 | +├╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌┤ |
| 43 | +│ CMT ┆ 2010-01-09 09:52:23 ┆ 2010-01-09 09:59:41 ┆ 1 ┆ ... ┆ 0.5 ┆ 0.0 ┆ 0.0 ┆ 7.8 │ |
| 44 | +├╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌┤ |
| 45 | +│ CMT ┆ 2010-01-05 15:25:59 ┆ 2010-01-05 15:33:54 ┆ 1 ┆ ... ┆ 0.5 ┆ 0.0 ┆ 0.0 ┆ 6.6 │ |
| 46 | +└───────────┴─────────────────────┴─────────────────────┴─────────────────┴─────┴─────────┴────────────┴──────────────┴──────────────┘ |
| 47 | +14863778 rows in set (1.098 sec) |
| 48 | +``` |
| 49 | + |
| 50 | +Or pipe your SQL command directly inline: |
| 51 | + |
| 52 | +```bash |
| 53 | +$ echo "SELECT MIN(Close) as low, MAX(Close) as high from '/home/ritchie46/example/BTUSD.csv' WHERE Date > '2014' AND Date < '2015'" | ./polars-sql |
| 54 | +``` |
0 commit comments