Skip to content

Polars Support #735

Closed
Closed

Description

@firmai

It would be great to offer Polars support, it is currently half as popular as Pandas, and generally work better for large datasets. Polars is bound to replace most data-scientist day to day operations within the next five years.

Thanks for developing bigframes, it very useful.

Activity

  1. TrevorBergeron commented on May 30, 2024

    @TrevorBergeron
    Contributor

    What kind of polars support would you find useful? Would you want BigQuery DataFrames to have an polars-like DataFrame API (as an alternative to the current pandas-like one) or simply interop with polars objects more easily?

  2. added
    type: feature request‘Nice-to-have’ improvement, new feature or different behavior or design.
    on Jun 3, 2024
  3. lmmx commented on Jun 13, 2024

    @lmmx

    I would like automatic schema supply, this is currently the limiting step in automatically uploading Polars DataFrames: write_ndjson seems to be the only way I can upload list dtypes (Parquet seems to not be viable, see this issue), but NDJSON requires the schema to be passed. I'm really looking for something that will just let me put my Polars DataFrame in a BQ table without fiddling with schemas: there should be enough info already here to do that for me.

  4. tswast commented on Jun 26, 2024

    @tswast
    Collaborator

    For going from BigQuery DataFrames to polars, I'm adding a to_arrow method in #807 as well as an example for how to create a polars DataFrame from the results.

  5. tswast commented on Jan 3, 2025

    @tswast
    Collaborator

    For uploading to BigQuery, I have updated the polars docs to indicate how to get BigQuery to correctly handle list types pola-rs/polars#20292

    I think that read_polars and to_polars methods would be reasonable requests for bigframes. I have done some refactoring recently to our I/O that might make it a bit easier, but would probably require a little more refactoring to have pyarrow tables/recordbatches as the intermediate format instead of pandas dataframes. The other thing to be careful about is that polars would be an optional "extra" dependency in setup.py to avoid a hard dependency on the polars package.

    Edit: Or at the very least, a read_arrow(...) method to correspond to the to_arrow() I implemented in #807. There are fewer concerns with depending on pyarrow in bigframes because we already have that as a required dependency.

  6. lmmx commented on Feb 13, 2025

    @lmmx

    Amazing! Should this issue be closed now?

  7. tswast commented on Jun 26, 2025

    @tswast
    Collaborator

    I just mailed #1855 with bpd.read_arrow(pyarrow.Table) to round out the other side of this conversion.

    Technically I think this was possible before by going through the DataFrame constructor, but that ended up translating to pandas as an in-between layer. Now we can just go from polars -> Arrow -> BigFrames without pandas in the middle.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

api: bigqueryIssues related to the googleapis/python-bigquery-dataframes API.type: feature request‘Nice-to-have’ improvement, new feature or different behavior or design.

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions