Skip to content

feat!: replace polars dependency with arrow; bump to 0.3.0#5

Merged
cpsievert merged 8 commits into
posit-dev:mainfrom
cpsievert:polars-to-arrow
Apr 30, 2026
Merged

feat!: replace polars dependency with arrow; bump to 0.3.0#5
cpsievert merged 8 commits into
posit-dev:mainfrom
cpsievert:polars-to-arrow

Conversation

@cpsievert
Copy link
Copy Markdown
Collaborator

@cpsievert cpsievert commented Apr 29, 2026

Summary

  • Upgrades to ggsql Rust crate v0.3.0 and bumps the Python package version to 0.3.0
  • Rewrites the Rust↔Python IPC bridge to use Arrow directly instead of Polars, matching the upstream ggsql v0.3.0 change that removed Polars from the crate
  • Rust side uses arrow::ipc::{StreamWriter, StreamReader} and Python side uses pyarrow.ipc
  • Runtime dependency changed from polars to pyarrow
  • Custom readers returning Polars DataFrames still work — py_to_df() accepts anything pyarrow.table() can convert
  • Adds build.rs to link rstrtmgr.lib on Windows (required by DuckDB 1.4+)
  • Updates README, CLAUDE.md, CHANGELOG, and tests to reflect the new Arrow-based API

Public API changes

  • DuckDBReader.execute_sql() returns pyarrow.Table (was polars.DataFrame)
  • DuckDBReader.register() accepts pyarrow.Table (polars/pandas also accepted via automatic conversion)
  • Spec.data() / layer_data() / stat_data() return pyarrow.Table

Test plan

  • All 45 tests pass locally (2 skipped: pandas, ibis not installed)
  • CI passes across platforms (Linux, macOS, Windows) and Python versions (3.10–3.13)

The upstream ggsql crate (v0.3.0) removed polars in favor of a custom
DataFrame built on Arrow RecordBatch. This updates the Python bindings
to match:

Rust side: IPC serialization now uses arrow::ipc::{StreamWriter,StreamReader}
instead of polars IpcWriter/IpcReader. The py_to_df() helper accepts any
object that pyarrow.table() can convert, so custom readers returning polars
DataFrames still work without changes.

Python side: render_altair() calls df.to_arrow() instead of df.to_polars().
Runtime dependency changed from polars to pyarrow.

Public API changes:
- DuckDBReader.execute_sql() returns pyarrow.Table (was polars.DataFrame)
- DuckDBReader.register() accepts pyarrow.Table (polars still works via
  automatic conversion)
- Spec.data()/layer_data()/stat_data() return pyarrow.Table
Update all code examples, API docs, and architecture description to
reflect that the data bridge now uses pyarrow instead of polars.
register() accepts any type that pyarrow.table() can convert (pyarrow,
polars, pandas, etc.).
- Replace all pl.DataFrame/pl.LazyFrame usage in tests with pa.table()
- Make polars optional in tests (skip polars-specific tests when not installed)
- Custom readers now use duckdb .arrow() instead of .pl()
- Fix render_altair() where the LazyFrame collect + DataFrame isinstance
  checks were accidentally collapsed into a single inverted check
DuckDB 1.4+ uses the Windows Restart Manager API (RmStartSession, etc.)
which requires linking against rstrtmgr.lib. Without this, Windows
builds fail with LNK2019 unresolved externals.

This comment was marked as resolved.

Addresses PR feedback: instead of a generic "Expected a pyarrow.Table
or compatible type" message, include the actual Python type name and
the underlying pyarrow error for easier debugging.
@cpsievert cpsievert requested a review from Copilot April 29, 2026 16:31
@cpsievert cpsievert changed the title Replace polars with arrow for data bridge feat!: replace polars dependency with arrow; bump to 0.3.0 Apr 29, 2026

This comment was marked as resolved.

@cpsievert cpsievert requested a review from thomasp85 April 29, 2026 16:54
Copy link
Copy Markdown
Collaborator

@thomasp85 thomasp85 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@cpsievert cpsievert merged commit d1b2b64 into posit-dev:main Apr 30, 2026
18 checks passed
@cpsievert cpsievert deleted the polars-to-arrow branch April 30, 2026 13:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants