clickhouse-connect icon indicating copy to clipboard operation
clickhouse-connect copied to clipboard

Polars support

Open axelwas opened this issue 2 years ago • 6 comments

Hello, thank you for this great library! Is it planned to support Polars library at some point ?

axelwas avatar Feb 02 '23 18:02 axelwas

Polars is not currently on the roadmap, but we do look at the community interest in new features on a regular basis and adjust our priorities accordingly. Of course we'd welcome a pull request from someone who is familiar with Polars.

genzgd avatar Feb 02 '23 18:02 genzgd

Yes, I do hope this client will support polars.

qqletter avatar Apr 27 '23 09:04 qqletter

You can query to get pyarrow tables, which can then zero-copy into Polars with something like this:

df = pl.from_arrow(client.query_arrow(query))

NotSimone avatar Mar 24 '24 15:03 NotSimone

Feedback based on @NotSimone's comment would be appreciated -- is using PyArrow enough of a solution or does Polars use some other internal data format?

genzgd avatar Mar 25 '24 17:03 genzgd

Polars does use Pyarrow under the hood so I think this would work.

Since my question, we ended up sticking with Pandas. Would it be possible to optionally make query_df return a Pyarrow backed Pandas DataFrame instead of Numpy backed ? I see use_numpy param is hardcoded to true here.

axelwas avatar Mar 27 '24 15:03 axelwas

Agreed that PyArrow DataFrames would be useful - https://github.com/ClickHouse/clickhouse-connect/issues/326. However I'm not sure when it will it will be prioritized.

genzgd avatar Mar 27 '24 15:03 genzgd