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

Binary type data disappears when pickled #6515

Closed
2 tasks done
nrlugg opened this issue Jan 28, 2023 · 4 comments · Fixed by #6543
Closed
2 tasks done

Binary type data disappears when pickled #6515

nrlugg opened this issue Jan 28, 2023 · 4 comments · Fixed by #6543
Assignees
Labels
bug Something isn't working good first issue Good for newcomers python Related to Python Polars

Comments

@nrlugg
Copy link

nrlugg commented Jan 28, 2023

Polars version checks

  • I have checked that this issue has not already been reported.

  • I have confirmed this bug exists on the latest version of Polars.

Issue description

When a pl.Binary type Series is pickled and unpickled, the data is lost (all becomes null) and the type is changed to pl.Int32.

This is a particular problem when using multiprocessing (or similar) since when I multiprocess over data with pl.Binary columns, that data is lost when sent to the other processes (via pickle).

This also happens for dill.

Reproducible example

import pickle
import numpy as np
import polars as pl

data = pl.Series(
    "binary_data",
    [np.random.bytes(l) for l in np.random.randint(4, 16, (8,))]
)

print(data)
"""
shape: (8,)
Series: 'binary_data' [binary]
[
	[binary data]
	[binary data]
	[binary data]
	[binary data]
	[binary data]
	[binary data]
	[binary data]
	[binary data]
]
"""

print(pickle.loads(pickle.dumps(data)))
"""
shape: (8,)
Series: 'binary_data' [i32]
[
	null
	null
	null
	null
	null
	null
	null
	null
]
"""

Expected behavior

There Series data should not change.

Installed versions

--Version info---
Polars: 0.15.18
Index type: UInt32
Platform: macOS-13.1-arm64-arm-64bit
Python: 3.10.9 (main, Jan 17 2023, 15:47:44) [Clang 14.0.0 (clang-1400.0.29.202)]
---Optional dependencies---
pyarrow: 7.0.0
pandas: 1.5.2
numpy: 1.23.5
fsspec: 2022.11.0
connectorx: <not installed>
xlsx2csv: <not installed>
deltalake: <not installed>
matplotlib: 3.6.2
@nrlugg nrlugg added bug Something isn't working python Related to Python Polars labels Jan 28, 2023
@ritchie46
Copy link
Member

This requires serde to implemented for dtype-binary. This is a good first issue. One can look at the serde for the other data types for inspiration.

@ritchie46 ritchie46 added good first issue Good for newcomers labels Jan 28, 2023
@papparapa
Copy link
Contributor

May I work on it?

@ritchie46
Copy link
Member

May I work on it?

Please 🙂

@nrlugg
Copy link
Author

nrlugg commented Jan 30, 2023

Omg this is already in the latest release; thank you both!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working good first issue Good for newcomers python Related to Python Polars
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants