Skip to content

Commit 9074f48

Browse files
authored
chore: add readme and jemalloc to polar-sql (#5483)
1 parent 62f5def commit 9074f48

File tree

3 files changed

+64
-0
lines changed

3 files changed

+64
-0
lines changed

polars/polars-sql/Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,3 +24,6 @@ rustyline = { version = "10.0.0", optional = true }
2424
serde = "1"
2525
serde_json = { version = "1" }
2626
sqlparser = { version = "0.19" }
27+
28+
[target.'cfg(target_os = "linux")'.dependencies]
29+
jemallocator = { version = "0.5", features = ["disable_initial_exec_tls"] }

polars/polars-sql/README.md

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
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+
```

polars/polars-sql/src/main.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,15 @@
11
#![allow(unused)]
22

3+
#[cfg(target_os = "linux")]
4+
use jemallocator::Jemalloc;
5+
36
#[cfg(feature = "cli")]
47
mod cli;
58

9+
#[global_allocator]
10+
#[cfg(target_os = "linux")]
11+
static ALLOC: Jemalloc = Jemalloc;
12+
613
fn main() -> std::io::Result<()> {
714
#[cfg(feature = "cli")]
815
return cli::run();

0 commit comments

Comments
 (0)