Skip to content

[Arrow] Move parquet-variant-compute StructArrayAssembler to arrow-array - #10636

Merged
alamb merged 9 commits into
apache:mainfrom
cakeni:feat/struct-array-builder
Oct 5, 2026
Merged

alamb merged 9 commits into
apache:mainfrom
cakeni:feat/struct-array-builder

Conversation

@cakeni

@cakeni cakeni commented Aug 11, 2026 •

Copy link
Copy Markdown
Contributor

Which issue does this PR close?

Rationale for this change

parquet-variant-compute contains a local helper for assembling a StructArray from completed child arrays. The helper is generally useful Arrow functionality and should live in arrow-array instead of being duplicated in a Variant-specific crate.

What changes are included in this PR?

  • Add a public StructArrayAssembler for completed child arrays to arrow-array.
  • Support synthesized fields, caller-provided FieldRef values that retain metadata, and an optional top-level null buffer.
  • Replace the local parquet-variant-compute implementation with the shared assembler.
  • Add API documentation, an example, and unit coverage.

Are these changes tested?

Yes.

  • cargo test -p arrow-array struct_array_assembler (16 tests passed)
  • cargo test -p parquet-variant-compute (347 unit tests and 13 doctests passed)

Are there any user-facing changes?

Yes. arrow-array exposes a new assembler API for assembling StructArray values from completed children. Existing APIs are unchanged.

AI assistance

I investigated the existing builder design, determined the scope of the API extraction, and reviewed and refined the resulting API and implementation. OpenAI Codex assisted with code exploration, drafting, and test preparation.

@github-actions github-actions Bot added arrow Changes to the arrow crate parquet-variant parquet-variant* crates arrow-array labels Aug 11, 2026
@cakeni
cakeni marked this pull request as ready for review August 11, 2026 13:30

@Rich-T-kid Rich-T-kid left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This PR make sense to me.A big plus is we aren't introducing another dependency to parquet-variant-compute since it already used arrow-array. thanks @cakeni

@Jefffrey Jefffrey left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

i do wonder if we should be adding this to our public api 🤔

it is simple enough, but could be slightly confusing as it doesnt follow our other builder patterns

@cakeni

cakeni commented Aug 28, 2026

Copy link
Copy Markdown
Contributor Author

I kept this separate from StructBuilder since it assembles already-built child arrays rather than building them incrementally.

@cakeni
cakeni force-pushed the feat/struct-array-builder branch from c1581e8 to b288c5e Compare August 28, 2026 07:18
@cakeni
cakeni force-pushed the feat/struct-array-builder branch from b288c5e to 3f3dba9 Compare August 28, 2026 07:21
@sdf-jkl

sdf-jkl commented Sep 28, 2026 •

Copy link
Copy Markdown
Member

i do wonder if we should be adding this to our public api 🤔

The new API:

let array = StructArrayBuilder::new()
    .with_field("name", names, false)
    .with_field("value", values, false)
    .with_nulls(nulls)
    .build()?;

is just syntactic sugar and lets us create Field inline vs:

let name_field = Arc::new(Field::new(
    "name",
    names.data_type().clone(),
    false,
));
let value_field = Arc::new(Field::new(
    "value",
    values.data_type().clone(),
    false,
));

let array = StructArray::from(vec![
    (name_field, names),
    (value_field, values),
]);

It's more functional/idiomatic and would be nice to have.

it is simple enough, but could be slightly confusing as it doesnt follow our other builder patterns

I suggest using a different name to disambiguate it -- StructArrayAssembler 🤷

@alamb @Jefffrey WYT

@Rich-T-kid

Copy link
Copy Markdown
Contributor

It's more functional/idiomatic and would be nice to have.

+1 in my opinion

@alamb alamb left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Looks great to me -- thanks @sdf-jkl and @Rich-T-kid

Since this struct appears not to be part of the public API

pub(crate) struct StructArrayBuilder {

I don't think we have to worry about backwards compatibility / wait for the next major release.

@alamb

alamb commented Sep 30, 2026

Copy link
Copy Markdown
Contributor

Where did we land on this API -- should we call it something different (maybe "Assembler") ?

@sdf-jkl

sdf-jkl commented Sep 30, 2026

Copy link
Copy Markdown
Member

If everyone's good with StructArrayAssembler, I'd proceed with that.

@cakeni please LMK if you have the bandwidth to work on this

@alamb

alamb commented Sep 30, 2026

Copy link
Copy Markdown
Contributor

If everyone's good with StructArrayAssembler, I'd proceed with that.

This sounds good to me, but we should confirm with @Jefffrey

@Jefffrey

Jefffrey commented Oct 1, 2026

Copy link
Copy Markdown
Contributor

this sounds reasonable

@cakeni cakeni changed the title [Arrow] Move parquet-variant-compute StructArrayBuilder to arrow-array [Arrow] Move parquet-variant-compute StructArrayAssembler to arrow-array Oct 2, 2026
@Jefffrey Jefffrey added the enhancement New feature/addition label Oct 2, 2026
@sdf-jkl

sdf-jkl commented Oct 2, 2026

Copy link
Copy Markdown
Member

@cakeni could you please also address @alamb comments about docs 🙏

@cakeni

cakeni commented Oct 3, 2026

Copy link
Copy Markdown
Contributor Author

Updated the remaining docs comments.

@alamb alamb left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thank you so much @cakeni for following through and bearing with us

@alamb
alamb enabled auto-merge October 5, 2026 15:33
@alamb
alamb added this pull request to the merge queue Oct 5, 2026
Merged via the queue into apache:main with commit a1daa4a Oct 5, 2026
33 checks passed
@sdf-jkl

sdf-jkl commented Oct 5, 2026

Copy link
Copy Markdown
Member

Thanks @cakeni 🙏

sdf-jkl added a commit to peterxcli/arrow-rs that referenced this pull request Nov 20, 2026
…-metadata

Resolve the conflict with apache#12092, which removed `TopLevelRowSink`, and
switch the tests from `StructArrayBuilder` to `StructArrayAssembler`,
which moved to arrow-array in apache#10636.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

arrow Changes to the arrow crate arrow-array enhancement New feature/addition parquet-variant parquet-variant* crates

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Arrow] Move parquet-variant-compute StructArrayBuilder to arrow-array

5 participants