Skip to content

[Python] Support schema-like objects through the Arrow PyCapule protocol as type or schema argument in the constructors #41065

Description

@jorisvandenbossche

See #40818 (comment) for context.

Our constructor functions like pa.array(..), pa.chunked_array(..), pa.record_batch(..) and pa.table(..) accept a type or schema argument.
Those constructors can all be used to consume data that support the Arrow PyCapsule protocol, and to convert those objects to the equivalent pyarrow object. For those cases, it would make sense to also accept the type or schema keyword argument as any object supporting the capsule protocol for schemas, i.e. having a __arro_c_schema__, while right now we require an actual pyarrow object.

One question is whether we would always support schema-like objects with the ArrowSchema protocol as input wherever specifying a type or schema, or whether we only allow this when actually consuming data through the protocol (i.e. if the data object itself has the __arrow_c_array/stream__)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions