Skip to content

Conversation

@timsaucer
Copy link
Member

Which issue does this PR close?

Rationale for this change

Metadata on a schema for a record batch is lost during FFI conversion. This is not always obvious because our other integrations like ExecutionPlan and TableProvider have their own ways to provide the schema.

This is currently an issue because we have FFI table providers who say they have a specific schema but the schema of the actual record batches does not match. The metadata is dropped.

What changes are included in this PR?

We already have the schema in the FFI object, so use it both when converting to and from FFI.

Are these changes tested?

Unit test added.

Are there any user-facing changes?

No

@github-actions github-actions bot added the ffi Changes to the ffi crate label Dec 12, 2025
Copy link
Contributor

@ethan-tyler ethan-tyler left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR @timsaucer!

This LGTM. Reviewed the changes and ran cargo test -p datafusion-ffi round_trip_record_batch_with_metadata -- --nocapture locally.

Unrelated to your changes, but I noticed the existing test_round_trip_record_batch_stream doesn't have schema metadata on its test batch. Might be worth adding metadata there too at some point so the streaming path has explicit coverage.

Copy link
Contributor

@kosiew kosiew left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@timsaucer timsaucer force-pushed the bugfix/ffi-rb-schema branch from 72cebe5 to 1f18a4d Compare December 30, 2025 13:38
@timsaucer
Copy link
Member Author

Thank you for the reviews!

@timsaucer timsaucer added this pull request to the merge queue Dec 30, 2025
Merged via the queue into apache:main with commit 34addca Dec 30, 2025
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ffi Changes to the ffi crate

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Preserve record batch schema metadata in FFI

4 participants