Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support pl.Array when writing parquet files #14876

Closed
mkleinbort-ic opened this issue Mar 6, 2024 · 2 comments · Fixed by #14943
Closed

Support pl.Array when writing parquet files #14876

mkleinbort-ic opened this issue Mar 6, 2024 · 2 comments · Fixed by #14943
Assignees
Labels
A-dtype-list/array Area: list/array data type A-io-parquet Area: reading/writing Parquet files accepted Ready for implementation bug Something isn't working enhancement New feature or an improvement of an existing feature P-high Priority: high

Comments

@mkleinbort-ic
Copy link

Description

The Array datatype is not yet supported in writing to parquet

import polars as pl 

df = pl.DataFrame({
    'x':[[1,2,3]]
})

df.cast({'x':pl.Array(pl.Int64, width=3)}).write_parquet('test.parquet')

>>> PanicException: not yet implemented: Writing FixedSizeList to parquet not yet implemented
@mkleinbort-ic mkleinbort-ic added the enhancement New feature or an improvement of an existing feature label Mar 6, 2024
@deanm0000 deanm0000 added A-dtype-list/array Area: list/array data type A-io-parquet Area: reading/writing Parquet files P-high Priority: high bug Something isn't working labels Mar 7, 2024
@deanm0000
Copy link
Collaborator

I added "bug" since it shouldn't raise PanicException.

Interesting that if you use pyarrow to write it that polars can then read back the array containing parquet.

@franz101
Copy link

franz101 commented Mar 9, 2024

import polars as pl
import numpy as np
import pyarrow.parquet as pq

df = pl.DataFrame(
    {
        "arr": np.random.rand(100_000, 512),
        "arr2": np.random.rand(100_000, 512),
    },
    schema={
        "arr": pl.Array(inner=pl.Float32, width=512),
        "arr2": pl.Array(inner=pl.Float32, width=512),
    },
)
pt = df.to_arrow()
pq.write_table(pt, 'example_table.parquet')

Simple way using parquet as a workaround

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-dtype-list/array Area: list/array data type A-io-parquet Area: reading/writing Parquet files accepted Ready for implementation bug Something isn't working enhancement New feature or an improvement of an existing feature P-high Priority: high
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

5 participants