Skip to content

docs(arrow-convert): add a compile-checked doctest for reading ArrowData back into Rust - #2899

Closed
phil-opp wants to merge 1 commit into
mainfrom
claude/dreamy-bardeen-ljpfa3-arrowdata-doctest
Closed

docs(arrow-convert): add a compile-checked doctest for reading ArrowData back into Rust#2899
phil-opp wants to merge 1 commit into
mainfrom
claude/dreamy-bardeen-ljpfa3-arrowdata-doctest

Conversation

@phil-opp

Copy link
Copy Markdown
Collaborator

🤖 Machine-generated PR. Opened by Claude (Anthropic) during an automated code-review pass of the repository. Please review carefully before merging.

Issue

ArrowData (libraries/arrow-convert/src/lib.rs) is the type every dora node receives its inputs as, and the TryFrom<&ArrowData> impls are the read counterpart to IntoArrow. But ArrowData carried only a single-line doc comment, and the conversions were exercised only by #[cfg(test)] unit tests — there was no compile-checked example documenting the intended read pattern or its null/type contract.

IntoArrow (the Rust→Arrow direction) already has a good runnable doctest; the inverse direction had none.

Fix

Expand the ArrowData doc comment with a runnable # Example that:

  • round-trips a Vec<f32> through IntoArrowArrowDatatry_into (both Vec<f32> and borrowed &[f32]);
  • converts a single-element array to a scalar (u8);
  • shows that a type mismatch is a recoverable Err, not a panic.

Pure documentation addition — no code behavior changes.

Validation

  • cargo test -p dora-arrow-convert --doc — the new doctest (and the existing IntoArrow one) pass.
  • cargo fmt --all -- --check — clean.

Generated by Claude Code

…ata back into Rust

ArrowData is the type every node receives its inputs as, and the
TryFrom<&ArrowData> impls are the read counterpart to IntoArrow, but the
type carried only a one-line doc and the conversions were exercised only
by cfg(test) unit tests. Add a runnable doctest that round-trips a
Vec<f32> and a scalar through IntoArrow -> ArrowData -> try_into, and
shows that a type mismatch is a recoverable error rather than a panic, so
the read contract is both documented and pinned.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01CCyEn8YqaYQYwh3RLjEZ7B
@trunk-io

trunk-io Bot commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

Merging to main in this repository is managed by Trunk.

  • To merge this pull request, check the box to the left or comment /trunk merge below.

After your PR is submitted to the merge queue, this comment will be automatically updated with its status. If the PR fails, failure details will also be posted here

Copy link
Copy Markdown
Collaborator Author

Automated review by Claude — fully automated, no human in the loop.

No issues found. The doctest exercises the real TryFrom<&ArrowData> impls for Vec<f32>, &[f32], and scalar u8 (generated via impl_try_from_arrow_data!), round-trips through IntoArrow -> ArrowData -> try_into, and correctly demonstrates the recoverable-error path: a Vec<i64> from a Float32Array resolves through as_primitive_opt::<Int64Type>() returning None -> Err, i.e. an eyre::Report, not a panic. arrow and eyre are non-dev dependencies, so the doctest builds under default features. Meaningful, non-trivially-passing assertions.


Generated by Claude Code

@phil-opp

phil-opp commented Aug 9, 2026

Copy link
Copy Markdown
Collaborator Author

Closing as a duplicate of #3084, which documents the same API more completely: it states the contract of both conversion shapes (scalar conversions require exactly one element and no nulls; slice/Vec conversions accept any length but reject nulls) rather than only demonstrating calls. The borrowed &[f32] example from this PR is worth grafting onto it.

@phil-opp phil-opp closed this Aug 9, 2026
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.

2 participants