Skip to content

[Python] Dataset PartitioningFactory cannot be serialized in Python #34884

Closed

Description

@rjzamora

Describe the bug, including details regarding any error messages, version, and platform.

I would like to be able to serialize a dictionary of pyarrow.dataset.dataset key-word arguments (for parallel processing in Dask). However, it is not possible to do this when one of those arguments contains a Partitioning/PartitioningFactory object, because those objects cannot be serialized in Python.

Reproducer:

In [1]: import pyarrow.dataset as ds
   ...: import pickle
   ...: 
   ...: partitioning = ds.partitioning(flavor="hive")
   ...: pickle.dumps(partitioning)
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
Cell In[1], line 5
      2 import pickle
      4 partitioning = ds.partitioning(flavor="hive")
----> 5 pickle.dumps(partitioning)

File stringsource:2, in pyarrow._dataset.PartitioningFactory.__reduce_cython__()

TypeError: self.factory,self.wrapped cannot be converted to a Python object for pickling

Component(s)

Python

Activity

  1. changed the title [-]Dataset PartitioningFactory cannot be serialized in Python[/-] [+][Python ]Dataset PartitioningFactory cannot be serialized in Python[/+] on Apr 4, 2023
  2. changed the title [-][Python ]Dataset PartitioningFactory cannot be serialized in Python[/-] [+][Python] Dataset PartitioningFactory cannot be serialized in Python[/+] on Apr 4, 2023
  3. westonpace commented on Apr 10, 2023

    @westonpace
    Member

    All the partitioning objects we have today can boil down to a schema (which can be saved as an empty parquet/arrow file) and a string denoting the type (e.g. "dictionary" or "hive" or "filename"). I'm not sure if this is helpful or not since I suspect the goal is automatic serialization.

  4. rjzamora commented on Apr 10, 2023

    @rjzamora
    ContributorAuthor

    Thanks @westonpace ! The current workaround in Dask is indeed to allow the user to specify a dictionary like {"flavor": "hive", "schema": ...}. This works fine, but the Dask UX would certainly be cleaner if the user could pass in something like an initialized HivePartitioning object.

  5. added this to the 13.0.0 milestone on May 10, 2023
  6. added 3 commits that reference this issue on Jul 4, 2023
  7. added a commit that references this issue on Jul 10, 2023
  8. rjzamora commented on Jul 10, 2023

    @rjzamora
    ContributorAuthor
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions