Skip to content

feat: Lightweight table wrapper around existing dataframes (polars, pandas) #11169

@vspinu

Description

@vspinu

What is the motivation behind your request?

I write data manipulation backend agnostic functions which take a table input and do the computation. The problem is that there is no lightweight way to wrap an existing object (ex. polars) into ibis.Table object.

Currently the only way seems to be the memtable which has two "issues":

  • it relies on the global backend declaration and
  • seems to be performing coercions (data duplication) under the hood even when the backend is the same (I am not completely sure about this one)
import polars as pl
import ibis

df = pl.DataFrame({
    "column1": [1, 2, 3],
    "column2": ["a", "b", "c"]
})

ibis.memtable(df).get_backend()
##  <ibis.backends.duckdb.Backend at 0x13e7ece90>


ibis.set_backend("polars")
tt = ibis.memtable(df)
df is tt.to_polars()
## False

Describe the solution you'd like

I would like to have a lightweight ibis.wrap function which would take an object of the supported backend (ex. polars, pyarrow etc) and automatically wrap it into the corresponding backend in the most lightweight way possible, ideally without any conversions by keeping track of the reference of the original object.

What version of ibis are you running?

10.5.0

What backend(s) are you using, if any?

polars 1.27.1

Code of Conduct

  • I agree to follow this project's Code of Conduct

Metadata

Metadata

Assignees

No one assigned

    Labels

    featureFeatures or general enhancements

    Type

    No type

    Projects

    Status

    backlog

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions