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

Polars' rust parquet engine reads/writes files that are unreadable by duckdb/pandas/pyarrow (use_pyarrow=True) #17795

Closed
2 tasks done
theelderbeever opened this issue Jul 22, 2024 · 2 comments · Fixed by #17807
Assignees
Labels
A-io-parquet Area: reading/writing Parquet files accepted Ready for implementation bug Something isn't working python Related to Python Polars

Comments

@theelderbeever
Copy link

theelderbeever commented Jul 22, 2024

Checks

  • I have checked that this issue has not already been reported.
  • I have confirmed this bug exists on the latest version of Polars.

Reproducible example

Write parquet using Rust Arrow

import polars as pl
import pandas as pd
import duckdb

pl.DataFrame([
    {"struct": {"field": None}}
]).write_parquet("null.parquet")

pl.read_parquet("null.parquet") # Successful
pl.read_parquet("null.parquet", use_pyarrow=True) # Fails
pd.read_parquet("null.parquet") # Fails
duckdb.sql("select * from 'null.parquet'") # Fails

Write parquet using pyarrow

import polars as pl
import pandas as pd
import duckdb

pl.DataFrame([
    {"struct": {"field": None}}
]).write_parquet("null.parquet", use_pyarrow=True)

pl.read_parquet("null.parquet") # Successful
pl.read_parquet("null.parquet", use_pyarrow=True) # Successful
pd.read_parquet("null.parquet") # Successful
duckdb.sql("select * from 'null.parquet'") # Successful

Log output

No response

Issue description

Polars' Rust parquet writer writes Dataframes containing a null type struct field Schema([('struct', Struct({'field': Null}))]) in a format unreadable by other parquet readers (pyarrow/duckdb). However, using use_pyarrow=True writes a file readable by the other readers.

Expected behavior

Parquet files written using any engine should be compatible with one another.

Installed versions

df.select(df.select("recurring").unnest("recurring").to_struct()).write_parquet(
    "recurring_unnested.parquet"
)
@theelderbeever theelderbeever added bug Something isn't working needs triage Awaiting prioritization by a maintainer python Related to Python Polars labels Jul 22, 2024
@ritchie46
Copy link
Member

@coastalwhite can you take a look?

@coastalwhite coastalwhite added A-io-parquet Area: reading/writing Parquet files accepted Ready for implementation and removed needs triage Awaiting prioritization by a maintainer labels Jul 23, 2024
@coastalwhite coastalwhite self-assigned this Jul 23, 2024
@coastalwhite
Copy link
Collaborator

coastalwhite commented Jul 23, 2024

It seems a problem with the conversions to Arrow schema's. Adding a schema seems to fix the problem for now.

import polars as pl
import duckdb

pl.DataFrame(
    [ {"struct": {"field": None}} ],
    schema = { 'struct': pl.Struct({ 'field': pl.Int64 }) }
).write_parquet("null.parquet")

print(duckdb.sql("select * from 'null.parquet'")) # Successful

Will investigate what we are doing wrong.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-io-parquet Area: reading/writing Parquet files accepted Ready for implementation bug Something isn't working python Related to Python Polars
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

3 participants