GH-29309: [C++] Preserve BinaryBuilder data type#50049
Conversation
|
|
|
|
1 similar comment
|
|
|
|
There was a problem hiding this comment.
Pull request overview
This PR fixes BinaryBuilder / LargeBinaryBuilder so that when they’re constructed with an explicit DataType (notably binary-backed extension types), the finished array preserves that type instead of always producing a plain (large) binary array.
Changes:
- Store the provided
DataTypeinsideBaseBinaryBuilderand return it fromtype(). - Remove
BinaryBuilder/LargeBinaryBuilder’s hardcodedtype()overrides soFinishInternal()uses the stored type. - Add a regression test ensuring a binary-backed
ExtensionTypeis preserved throughBinaryBuilder::Finish().
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| cpp/src/arrow/array/builder_binary.h | Persist builder DataType in BaseBinaryBuilder and use it for finished array type. |
| cpp/src/arrow/array/array_binary_test.cc | Adds a regression test covering preservation of a binary-backed extension type. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
Addressed the Copilot review comments in 6ad9de9:
Local verification:
|
Rationale for this change
BinaryBuilder accepted a DataType in its constructor but discarded it, so finishing through ArrayBuilder::Finish() always produced a plain binary array instead of preserving the supplied type, such as an extension type backed by binary storage.
What changes are included in this PR?
Are these changes tested?
Yes.