How We Extended Polars with Rust Expression Plugins for fenic
Extending Polars with Rust Expression Plugins
Building fenic, a semantic DataFrame library for AI pipelines, required operations Polars lacked natively. Python UDFs were too slow and broke query composition. We solved this by writing nine Rust expression plugins using pyo3-polars. These plugins run in-engine over Arrow, preserve types, and compose seamlessly with native Polars operations, eliminating Python round-trips for text processing tasks like tokenization and JSON parsing.
The moment one step is an opaque Python callback, the engine can't see through it. It becomes an optimization barrier, forces a materialization, and breaks the single-pass pipeline.