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

fix(rust, python): deal with empty structs #6039

Merged
merged 1 commit into from
Jan 4, 2023
Merged

Conversation

ritchie46
Copy link
Member

closes #6001

@github-actions github-actions bot added fix Bug fix python Related to Python Polars rust Related to Rust Polars labels Jan 4, 2023
@ritchie46 ritchie46 merged commit 977c552 into master Jan 4, 2023
@ritchie46 ritchie46 deleted the empty_struct branch January 4, 2023 13:46
KivalM pushed a commit to rohit-ptl/polars that referenced this pull request Jan 4, 2023
@pebble2050
Copy link

@ritchie46
This bug not fixed yet. When have have two items, got error:
Could not create a new DataFrame from Series. The Series have different lengths. Got [shape: (2,)


import polars as pl
from dataclasses import dataclass

@dataclass
class TestClass:
    int_field: int
    dict_field: dict

t = TestClass(int_field=10, dict_field={})

df = pl.DataFrame([t,t])

zundertj pushed a commit to zundertj/polars that referenced this pull request Jan 7, 2023
@mikeam565
Copy link

@ritchie46 Hello. This bug has not been totally fixed. If a field is empty in all json entries, then polars will still throw OutOfSpec("A StructArray must contain at least one field"). Eg.
[ {"a":"A", "test":"Y"}, {"a":"A", "test":"N", "anObject":{}}, {"a":"A", "test":"N", "anObject":{}} ]
The above json if parsed with JsonReader will throw an error.

@avimallu
Copy link
Contributor

You might need to raise another bug report. This is a very old PR, might get missed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
fix Bug fix python Related to Python Polars rust Related to Rust Polars
Projects
None yet
Development

Successfully merging this pull request may close these issues.

OutOfSpec("A StructArray must contain at least one field") error when passing dataclass with empty dict field
4 participants