Skip to content

[Python] UnicodeDecodeError when printing schema with binary metadata #26217

@asfimport

Description

@asfimport

The following small example raises a UnicodeDecodeError error, since PyArrow version 0.17.0:

import pyarrow as pa

bdata = b"\xff\xff\xff\xff8\x02\x00\x00\x10\x00\x00\x00\x00\x00\n\x00\x0c\x00\x06\x00\x05\x00\x08\x00\n\x00\x00\x00\x00\x01\x04\x00\x0c\x00\x00\x00\x08\x00\x08\x00\x00\x00\x04\x00\x08\x00\x00\x00\x04\x00\x00\x00\x02\x00\x00\x00\x00\x01\x00\x00\x04\x00\x00\x00\x1a\xff\xff\xff\x00\x00\x00\x0c\xd0\x00\x00\x00\x9c\x00\x00\x00\x90\x00\x00\x00\x04\x00\x00\x00\x02\x00\x00\x00P\x00\x00\x00\x04\x00\x00\x00\xc0\xfe\xff\xff\x08\x00\x00\x00 \x00\x00\x00\x14\x00\x00\x00ARROW:extension:name\x00\x00\x00\x00\x1b"

t = pa.table({"data": pa.array([1, 2])}, metadata={b"k": bdata})
print(t.schema)

In our case, the binary data is coming from the serialization of another PyArrow schema. But I guess the error can appear with any binary metadata in the schema.

The print used to work fine with PyArrow 0.16, getting this output:

data: int64
metadata
--------
OrderedDict([(b'k',
              b'\xff\xff\xff\xff8\x02\x00\x00\x10\x00\x00\x00\x00\x00\n\x00'
              b'\x0c\x00\x06\x00\x05\x00\x08\x00\n\x00\x00\x00\x00\x01\x04\x00'
              b'\x0c\x00\x00\x00\x08\x00\x08\x00\x00\x00\x04\x00'
              b'\x08\x00\x00\x00\x04\x00\x00\x00\x02\x00\x00\x00'
              b'\x00\x01\x00\x00\x04\x00\x00\x00\x1a\xff\xff\xff'
              b'\x00\x00\x00\x0c\xd0\x00\x00\x00\x9c\x00\x00\x00'
              b'\x90\x00\x00\x00\x04\x00\x00\x00\x02\x00\x00\x00P\x00\x00\x00'
              b'\x04\x00\x00\x00\xc0\xfe\xff\xff\x08\x00\x00\x00 \x00\x00\x00'
              b'\x14\x00\x00\x00ARROW:extension:name\x00\x00\x00\x00\x1b')])

I can work on a patch to reverse the behaviour back to PyArrow 0.16?

Environment: Python 3.6 - 3.8
Reporter: Paul Balanca / @balancap
Assignee: Antoine Pitrou / @pitrou

PRs and other links:

Note: This issue was originally created as ARROW-10214. Please see the migration documentation for further details.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions