Skip to content

GH-51231: [C++][Acero] Keep input nullability information for direct field projections - #51691

Open
FadyYosry77 wants to merge 1 commit into
apache:mainfrom
FadyYosry77:gh-51231-preserve-nullability
Open

FadyYosry77 wants to merge 1 commit into
apache:mainfrom
FadyYosry77:gh-51231-preserve-nullability

Conversation

@FadyYosry77

@FadyYosry77 FadyYosry77 commented Oct 2, 2026 •

Copy link
Copy Markdown

Rationale for this change

ProjectNode creates output column definitions with the requested output name and the type of the bound expression for that column. Nullability information is available from the input schema but is not copied during output column creation; thus, output columns are nullable by default.

As a result, projecting a nonnullable column from the input schema produces a nullable column in the output schema, even when only that column is projected. An identity projection may therefore produce a schema incompatible with its input.

GH-51231 restricts this change to top-level input fields.

What changes does this PR contain?

For direct projections of top-level fields, the ProjectNode class now uses the nullability of the input field to determine the nullability of the output field.

The projected field name and type of the bound expression remain unchanged.

Computed fields and nested field references continue to have their current nullable behavior. This pull request does not include full expression nullability inference.

A regression test covers:

  • direct nonnullable-nullable field correspondence
  • reordered projections
  • renaming a required field
  • a calculated control with nonnullable input and nullable output as before

Are these changes tested?

Yes.

The regression test checks the schemas created. It failed with the old implementation and passed with the new implementation.

Local validation included:

The targeted regression analysis was conducted with:

./cpp/build-gh51231/debug/arrow-acero-plan-test \
  --gtest_filter=ExecPlanExecution.ProjectPreservesDirectFieldNullability

The larger Acero test set was evaluated with:

PYTHON=python3 ctest --test-dir cpp/build-gh51231 \
  -L arrow_acero \
  --output-on-failure \
  -j2

Substrait integration was not built locally. The regression test is defined at the native Acero ProjectNode level.

Are there any visible user impacts?

Yes. Top-level field projections copy the nullable attribute from input fields to output fields.

This change only alters the projected schema. Projected values remain the same.

There are no changes to public API or ABI signatures.

Was AI involved in this PR?

Yes. AI tools were used to assist with the investigation, implementation and test drafting, review, and preparation of this description.

I reproduced the issue locally and reviewed the patch, verifying that the test case failed without the patch and passed with the patch, and ran the listed C++ tests and style checks.

PR code and description by:

  • Human
  • AI

Reviewed before submission by:

  • Human
  • AI
  • Not reviewed

@github-actions

github-actions Bot commented Oct 2, 2026

Copy link
Copy Markdown

⚠️ GitHub issue #51231 has no components, please add labels for components.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant