fix(go): align buffers before C Data export#129
Open
dataders wants to merge 1 commit into
Open
Conversation
692eaf7 to
e31ec4c
Compare
e31ec4c to
3b409ae
Compare
felipecrv
requested changes
May 11, 2026
Collaborator
felipecrv
left a comment
There was a problem hiding this comment.
I think the latest versions of arrow-go already guarantee alignment that satisfies arrow-rs requirements. All the drivers built from this repo are safe already.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changed
This adds an internal Go helper that prepares record batches for Arrow C Data export by copying only buffers whose base pointer is not aligned to 64 bytes.
The c-shared driver template now runs record batches through that helper before calling
cdata.ExportArrowRecordBatch, and the generated c-shared driver packages have been regenerated from the template.Why
Some consumers of Arrow C Data import primitive buffers as typed native buffers and require the pointer to satisfy the scalar type alignment. Decimal128 is backed by 16-byte values, so a Decimal128 value buffer exported through C Data with an 8-byte-aligned pointer can fail in strict consumers.
The Go drivers can receive Arrow IPC-backed buffers whose byte storage is usable inside Go but not suitable to hand out unchanged across the C Data FFI boundary. The c-shared driver owns that boundary, so it should ensure the buffers it exports are aligned.
Validation
go test ./pkg/internal/cdataalign -count=1go test -tags driverlib ./pkg/flightsql ./pkg/panicdummy ./pkg/snowflake ./pkg/bigquery ./pkg/databricks ./pkg/salesforce -count=1