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

attrs are not preserved in serializations through Arrow or Parquet #3278

Open
jpivarski opened this issue Oct 8, 2024 · 0 comments
Open
Labels
bug The problem described is something that must be fixed

Comments

@jpivarski
Copy link
Member

Version of Awkward Array

HEAD

Description and code to reproduce

>>> array = ak.Array([1, 2, 3], attrs={"one": 1})
>>> array.attrs
{'one': 1}

but

>>> ak.from_arrow(ak.to_arrow(array)).attrs
{}

and

>>> ak.to_parquet(array, "/tmp/array.parquet")
<pyarrow._parquet.FileMetaData object at 0x6ffe4b371350>
  created_by: parquet-cpp-arrow version 14.0.2
  num_columns: 1
  num_rows: 3
  num_row_groups: 1
  format_version: 2.6
  serialized_size: 0
>>> ak.from_parquet("/tmp/array.parquet").attrs
{}

Did this work at one point and stop working? If so, weren't there tests?

Pickle works:

>>> pickle.loads(pickle.dumps(array)).attrs
{'one': 1}

Metadata handling changed considerably in #3127; did it work before that? (#3127 would have changed ak.to_parquet via ak.to_arrow_table, but not ak.to_arrow.) This relies on the metadata-handling mechanisms, but extensionarray=True is on by default:

>>> ak.from_arrow(ak.to_arrow(array, extensionarray=True)).attrs
{}

>>> ak.to_parquet(array, "/tmp/array.parquet", extensionarray=True)
<pyarrow._parquet.FileMetaData object at 0x6ffe495bad90>
  created_by: parquet-cpp-arrow version 14.0.2
  num_columns: 1
  num_rows: 3
  num_row_groups: 1
  format_version: 2.6
  serialized_size: 0
>>> ak.from_parquet("/tmp/array.parquet").attrs
{}
@jpivarski jpivarski added the bug The problem described is something that must be fixed label Oct 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug The problem described is something that must be fixed
Projects
None yet
Development

No branches or pull requests

1 participant