pola-rs / polars-cli

CLI interface for running SQL queries with Polars as backend

Home Page:https://pola.rs/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Read data from stdin

GuillaumeDesforges opened this issue · comments

Description

The README shows how a SQL command can be passed to the command via stdin.

Would it be possible to pipe data (in my case JSONL) via stdin, and write a query in argument, much like jq?

Something like that maybe?

$ cat data.jsonl
{"id":1,"name":"Guillaume"}
{"id":2,"name":"Sophie"}
$ cat data.jsonl | polars 'SELECT id, name FROM read_json(stdin())'
┌──────┬───────────┐
│ id   ┆ name      │
│ ---  ┆ ---       │
│ i64  ┆ str       │
╞══════╪═══════════╡
│ 1    ┆ Guillaume │
│ 2    ┆ Sophie    │

This looks very useful! Would be nice to have, for sure.