Skip to content

GH-184: Export Arrow arrays through the C Data Interface#605

Draft
samtalki wants to merge 4 commits into
apache:mainfrom
samtalki:agent/cdata-export
Draft

GH-184: Export Arrow arrays through the C Data Interface#605
samtalki wants to merge 4 commits into
apache:mainfrom
samtalki:agent/cdata-export

Conversation

@samtalki

@samtalki samtalki commented Jul 6, 2026

Copy link
Copy Markdown

Summary

This PR builds on #604 and adds Arrow C Data Interface export.

  • Adds Arrow.to_c_data(col::ArrowVector; name="").
  • Adds Arrow.to_c_data(tbl; names=String.(Tables.columnnames(Tables.columns(tbl)))).
  • Adds independent schema and array owners for exported C Data structures.
  • Releases already-built children when a later child fails to build, so partially constructed exports do not leak owner registry entries.
  • Covers primitive and struct round trips, release order, moved child ownership, GC, metadata, malformed layout, unsupported export cases, and exported buffer layout checks for nested, string, and fixed size arrays.

Stack

Base remains main because these cross fork PRs are not represented as true stacked bases on GitHub.

Depends on #604, currently e84c39d.

Incremental review link:

samtalki/arrow-julia@agent/cdata-import-breadth-v2...agent/cdata-export

Size

Incremental over #604: 3 files changed, 1111 insertions, 2 deletions.

Total against main: 5 files changed, 3770 insertions, 4 deletions.

Validation

  • git diff --check agent/cdata-import-breadth-v2...HEAD: passed.
  • Focused C Data tests: import 189/189 passed; export 97/97 passed.

AI Assistance

Co-authored-by: Robert Buessow robert.buessow@relational.ai
Co-authored-by: Olle Martensson olle.martensson@gmail.com
Generated-by: OpenAI Codex

samtalki and others added 4 commits July 12, 2026 15:18
Add immutable ArrowSchema and ArrowArray ABI structs plus C Data import for null and primitive arrays.

Validate pointer layout, child counts, buffer counts, offsets, known flag bits, dictionary pointer consistency, release idempotency, and reads after release. Trust declared null counts like Arrow C++ and arrow-rs, require a validity bitmap for unknown null counts like nanoarrow, and ignore reserved flag bits for forward compatibility.

Move the base ArrowSchema and ArrowArray structures into Julia owned storage at import and mark the sources released without calling their callbacks, following the C Data Interface move semantics used by arrow-rs from_raw and nanoarrow ArrowArrayMove. Callers may free or reuse the passed structures once from_c_data returns; release_c_data or finalization releases the moved copies through the producer callbacks.

Keep imported buffers rooted behind a shared release owner. Copy misaligned fixed width buffers into aligned Julia storage before typed access, and materialize Julia owned data from copy, collect, deepcopy, and serialize so no read path bypasses the release liveness gate.

Co-authored-by: Robert Buessow <robert.buessow@relational.ai>
Co-authored-by: Olle Martensson <olle.martensson@gmail.com>
Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
Generated-by: OpenAI Codex
Add C Data import for struct arrays on top of the null and primitive array importer. Root structs are exposed as Tables.jl column tables with DataAPI metadata; nested structs import as NamedTuple element vectors with parent validity masking and parent offsets applied to the children.

Parse field names and schema metadata from the C schema for the imported table. Validate child pointer layout, child counts against the schema, struct child lengths, name and metadata bounds, and nesting depth, bound validation with a total node budget so aliased or cyclic child pointers cannot make it explode combinatorially, and reject duplicate struct field names, which NamedTuple rows and column lookup cannot represent.

Adjust dictionary encoding offsets for non 1-based reference pools so categorical pools with missing values keep correct dictionary indices.

Co-authored-by: Robert Buessow <robert.buessow@relational.ai>
Co-authored-by: Olle Martensson <olle.martensson@gmail.com>
Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
Generated-by: OpenAI Codex
Add import support for boolean, string, binary, list, fixed size, temporal, timestamp, duration, interval, and decimal C Data formats. Extend malformed input, offset, null count, release, copy, collect, metadata, and GC rooting coverage for the broader importer.

Co-authored-by: Robert Buessow <robert.buessow@relational.ai>
Co-authored-by: Olle Martensson <olle.martensson@gmail.com>
Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
Generated-by: OpenAI Codex
Add array and table export entry points with independent schema and array owners.

Release children that were already exported when a later child fails to build, so partially constructed exports do not leak owner registry entries.

Cover primitive and struct round trips, release order, moved child ownership, GC, metadata, malformed layout, unsupported export cases, and exported buffer layout checks for nested, string, and fixed size arrays.

Co-authored-by: Robert Buessow <robert.buessow@relational.ai>
Co-authored-by: Olle Martensson <olle.martensson@gmail.com>
Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
Generated-by: OpenAI Codex
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.

1 participant