Skip to content

Core: Export tables and scans as Arrow C streams - #4484

Open
Anurag-S1ngh wants to merge 1 commit into
apache:mainfrom
Anurag-S1ngh:fix/1655-arrow-capsule-export
Open

Anurag-S1ngh wants to merge 1 commit into
apache:mainfrom
Anurag-S1ngh:fix/1655-arrow-capsule-export

Conversation

@Anurag-S1ngh

Copy link
Copy Markdown
Contributor

Rationale for this change

PyIceberg can read Arrow data through to_arrow() and to_arrow_batch_reader(), but its own table and scan objects cannot be consumed by other Arrow-native libraries without an explicit PyArrow conversion.

This implements the producer side of the Arrow PyCapsule interface from #1655. Table, DataScan, and IncrementalAppendScan now expose __arrow_c_stream__, which delegates to to_arrow_batch_reader() so scans keep streaming and keep their existing filter, projection, and limit behavior.

The base scan classes are unchanged, so third-party scan subclasses do not need to implement a new abstract method.

The write side is tracked separately in #2680.

Closes #1655.

Are these changes tested?

Yes. Added tests/table/test_arrow_capsule.py covering:

  • consuming a Table directly with pa.table(...)

  • consuming a filtered and projected scan

  • consuming an incremental append scan

  • pytest tests/ -m unit --ignore=tests/integration: 4885 passed, 6 skipped

  • ruff check and ruff format --check pass

  • ty check reports nothing for the new methods

Are there any user-facing changes?

Yes. Table, DataScan, and IncrementalAppendScan now support the Arrow PyCapsule stream interface. Existing to_arrow() and to_arrow_batch_reader() APIs are unchanged.

Implement __arrow_c_stream__ on Table, DataScan, and IncrementalAppendScan so Arrow consumers can read them without calling to_arrow(). Part of apache#1655; the write side is tracked in apache#2680.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[feature] Investigate integrations leveraging the PyCapsule protocol

1 participant