Last months we have made a large leaps in SQL support in Polars. As we recognize that agentic workloads are becoming more dominant, we want to expose our engine to those workloads. LLM’s are great at SQL and we have a great engine that agents should benefit from. As SQL doesn’t require a host language (as opposed to DataFrames), it is perfectly suited for a CLI. So today we are releasing the polars command-line tool that runs SQL on files with the Polars query engine. No Python required, no server, just fast answers.
Polars CLI and design for agentic workloads #
Besides humans, CLI’s have become the defacto interface for agents. The polars CLI is designed with this purpose in mind. We want to reduce iterations, startup time and tokens. For this a few things are important:
- Model iterations/ turns; Every iteration costs model time and execution time of Polars often dwarfs that, especially for local files.
- Informative error messages (inspired by Rust); Errors point at the mistake and add a hint, such that the next iteration will lead to a correct query without needing to defer to documentation. And exa
- Documentation is available in the CLI itself, under
--helpyou can find working examples and function lists. - Successful queries are indicated immediately with an exit code 0. This means the agent doesn’t have to verify success.
- No Python required on boot. The
polarsCLI is a compiled rust binary that has super fast boot times. Most queries we can execute without any Python callbacks and thus no Python interpreter penalty.
Examples #
Let’s go through a few examples. For query exploration we have discovery operations lile `“DESCRIBE”.
$ polars --format csv -c "DESCRIBE 'foods.csv'"
column_name,column_type
category,VARCHAR
calories,BIGINT
fats_g,DOUBLE PRECISION
sugars_g,BIGINT
After the schema of a file is known, we can immediately compute the summaries we are interested in.
$ polars --format csv -c "SELECT category, count(*) AS n, avg(calories) AS avg_calories FROM 'foods.csv' GROUP BY category ORDER BY n DESC, category"
category,n,avg_calories
seafood,8,156.25
fruit,7,58.57142857142857
vegetables,7,27.428571428571427
meat,5,108.0
And if a query fails due to a syntax error, we give informative errors, so the agent can correct without deferring to documentation.
$ polars --format csv -c "SELECT LEN(category) FROM 'foods.csv'"
SQLInterfaceError: unsupported function 'len'
--> <command>:1:8
|
1 | SELECT LEN(category) FROM 'foods.csv'
| ^^^^^^^^^^^^^
= hint: use LENGTH instead
$ echo $?
1
Installation #
To get started, you can download the polars-cli from pypi with uv tool install polars-cli or use one of our github releases
Last words #
The initial release supports the native local and remote files that are supported by Python Polars. Next releases will include Delta Lake and Iceberg support as well as excel and scanning from databases. If you find any issue or want a feature, please contact us on github: https://github.com/pola-rs/polars/.