Uploaded image for project: 'Apache Arrow'
  1. Apache Arrow
  2. ARROW-11371

[Python] Serializing deeply nested structures raises recursion error

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Minor
    • Resolution: Won't Fix
    • 1.0.1
    • None
    • Python
    • $ python --version
      Python 3.6.12
      $ pip list | grep pyarrow
      pyarrow 1.0.1

    Description

      When serializing deeply nested python structures such as:

      data = [[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[None]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]

      orĀ 

      data = OrderedDict([('a', OrderedDict([('a', OrderedDict([('a', OrderedDict([('a', OrderedDict([('a', OrderedDict([('a', OrderedDict([('a', OrderedDict([('a', OrderedDict([('a', None)]))]))]))]))]))]))]))]))])

      pyarrow raises the following exception:

      >>> buffer = pyarrow.serialize(data).to_buffer()
      Traceback (most recent call last):
        File "pyarrow_recursion.py", line 11, in try_recursion
          buffer = pyarrow.serialize(data).to_buffer()
        File "pyarrow/serialization.pxi", line 285, in pyarrow.lib.SerializedPyObject.to_buffer
        File "pyarrow/serialization.pxi", line 248, in pyarrow.lib.SerializedPyObject.total_bytes.__get__
        File "pyarrow/error.pxi", line 84, in pyarrow.lib.check_status
      pyarrow.lib.ArrowInvalid: Max recursion depth reached
      

      While this not the prime use case of pyarrow.serialize, it would be nice to have a much larger recursion limit here, to not run into this issue with auto-generated structures quite so often.

      An example script for reproducing the error can be found in the attachments.

      Attachments

        1. pyarrow_recursion.py
          0.6 kB
          Alexander Dmitriev

        Activity

          People

            Unassigned Unassigned
            alexd2580 Alexander Dmitriev
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: