Skip to main content

VGI logo   +   Polars logo

vgi-polars

PyPI Python License CI

A Polars client for VGI (Vector Gateway Interface). Lets a polars.LazyFrame/polars.DataFrame scan a VGI catalog's tables and call its scalar, table-in-out, and aggregate functions — the same role the VGI DuckDB extension plays for DuckDB, but for Polars, with no DuckDB dependency at all.

This is not a new VGI protocol implementation. It's a thin adapter over vgi-python's existing pure-Python, Arrow-native reference client (vgi.client.Client) — the same wire-protocol code the DuckDB extension speaks — combined with Polars' polars.io.plugins.register_io_source extension point, which was purpose-built for exactly this "external source with pushdown" shape.

Installation

pip install vgi-polars

HTTP-transport support (talking to a VGI worker over http:///https://, and the Orchard remote-secret-provider path) needs an extra:

pip install "vgi-polars[http]"

Subprocess and TCP transports need no extra.

Quick start

import polars as pl
import vgi_polars as vp

with vp.attach("path/to/my-vgi-worker", name="my_catalog") as cat:
    print(cat.schemas())
    print(cat.tables("main"))

    t = cat.table("main", "events")
    print(t.schema)                # polars.Schema, no scan performed
    print(t.scan().filter(pl.col("value") > 90).collect())

    my_fn = cat.scalar_function("main", "my_function")
    df = pl.DataFrame({"a": [1, 2, 3], "b": [10, 20, 30]})
    print(df.with_columns(my_fn(pl.col("a"), pl.col("b")).alias("result")))

attach() auto-detects transport from the location string's scheme — a bare command is a subprocess worker, http:///https:// is HTTP, tcp://host:port is raw Arrow-IPC framing over TCP:

cat = vp.attach("http://localhost:8080", name="my_catalog")

Any VGI worker — written in Python, Rust, Go, Java, or TypeScript — speaks to vgi-polars unchanged; VGI is a cross-language protocol, not a Python-specific one. See vgi-python for reference worker implementations and the protocol documentation.

Design principle: pushdown is an optimization, never a correctness delegation

Polars does not re-verify a predicate/projection an io_source claims to have applied — confirmed empirically (see CLAUDE.md). VGI worker implementations, meanwhile, are written and tested against the DuckDB extension, which does always re-verify, so a worker may declare filter_pushdown/projection_pushdown and still apply either only approximately. Since neither side can be trusted alone, vgi-polars always applies the complete, original filter/projection/limit locally after scanning, regardless of what was pushed down. Pushdown here only ever affects performance, never correctness.

Status

Implemented:

  • Catalog attach/detach with versioning introspection
  • Schema and table discovery, incl. per-column statistics
  • Table scan (eager + lazy) with best-effort projection/filter pushdown, incl. is_in
  • required_filters cost-safety enforcement
  • Sequential split-scan redemption
  • Transparent multi-branch-table scanning (pl.concat under the hood)
  • A minimal in-memory/TTL result cache
  • Time-travel scans (AT clauses)
  • Scalar function calls with scoped secrets and per-chunk input dedup
  • Streaming and buffered table-in-out functions
  • Aggregate functions
  • Subprocess, HTTP, and TCP transports

Not implemented:

  • Writes
  • Companion-catalog federation
  • Per-table time-travel discovery
  • The container:///github:///launch: transport schemes (a substantially larger effort — a from-scratch Python transport layer, not an extension of the existing scheme table)

See CLAUDE.md for the full architecture, every non-obvious behavior discovered while building this, and an evidence-backed breakdown of every scoped-out item above.

Development

git clone https://github.com/Query-farm/vgi-polars.git
git clone https://github.com/Query-farm/vgi-python.git   # sibling checkout, see CLAUDE.md
cd vgi-polars
uv sync
uv run pytest -v

vgi-polars tracks vgi-python's client-side surface as both develop together — see CLAUDE.md's "Build / Test" section for why a sibling vgi-python checkout is used locally and in CI rather than the published package, and for the full test-running/fixture-worker setup.

License

Apache License, Version 2.0 — see LICENSE.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

vgi_polars-0.2.0.tar.gz (1.2 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

vgi_polars-0.2.0-py3-none-any.whl (55.2 kB view details)

Uploaded Python 3

File details

Details for the file vgi_polars-0.2.0.tar.gz.

File metadata

  • Download URL: vgi_polars-0.2.0.tar.gz
  • Upload date:
  • Size: 1.2 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for vgi_polars-0.2.0.tar.gz
Algorithm Hash digest
SHA256 e2dba5528876ec16fcf84de3170411667ee66f909ce33ce7bb4c7abbcb2b4184
MD5 06b07230fdb513550cb45c46f3000ed4
BLAKE2b-256 49df9977f41492e7f8a2bd2fa63b474a28d24c21a2fde9eb591be3cbbc7b1eb2

See more details on using hashes here.

Provenance

The following attestation bundles were made for vgi_polars-0.2.0.tar.gz:

Publisher: release.yml on Query-farm/vgi-polars

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file vgi_polars-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: vgi_polars-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 55.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for vgi_polars-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 955aa8de4320eaef0e1f174a3d2f739d60236febe8b535024bcec28766422d72
MD5 89a58d56fa546d2a8a17674283fd9e88
BLAKE2b-256 10b50f584bdfc4cc5beefe64298b73cde376a675bf0d15401138d3471ae334b2

See more details on using hashes here.

Provenance

The following attestation bundles were made for vgi_polars-0.2.0-py3-none-any.whl:

Publisher: release.yml on Query-farm/vgi-polars

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

0.8.0

2 files

0.7.0

2 files

0.6.0

2 files

0.5.1

2 files

0.5.0

2 files

0.4.1

2 files

0.4.0

2 files

0.3.3

2 files

0.3.2

2 files

0.3.1

2 files

0.3.0

2 files

This release

0.2.0 This release

2 files

0.1.0

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page