Skip to content

GH-55760: [Python] Preserve scalar fill null inputs - #55791

Open
09Catho wants to merge 1 commit into
apache:mainfrom
09Catho:fix/arrow-fill-null-scalar
Open

09Catho wants to merge 1 commit into
apache:mainfrom
09Catho:fix/arrow-fill-null-scalar

Conversation

@09Catho

@09Catho 09Catho commented Nov 25, 2026

Copy link
Copy Markdown
Contributor

Rationale for this change

fill_null_forward and fill_null_backward accept pyarrow.Scalar inputs through their Python wrappers, but currently return a one-element Array. On current main this path can also materialize the wrong value. A scalar has no null slots to fill, so it should be returned unchanged.

What changes are included in this PR?

The Python wrappers return scalar inputs unchanged and keep the existing C++ path for arrays and chunked arrays. The regression test covers numeric and null scalars for both forward and backward fill.

Are these changes tested?

  • The PyArrow 26.0.1 wheel reproduced the return-type regression: fill_null_forward(pa.scalar(5)) returned Int64Array [5] instead of a scalar.
  • A wrapper harness using the patched source passed for numeric and null scalars in both functions, and for existing array behavior.
  • python -m compileall passed for the changed files.
  • Ruff check passed with the repository's existing PYI024 namedtuple warnings ignored.
  • git diff --check passed.
  • The source pytest module could not be collected because this shallow checkout has no compiled pyarrow.lib extension.

Are there any user-facing changes?

Yes. Scalar inputs now return the unchanged pyarrow.Scalar; array and chunked-array behavior is unchanged.

Was AI used for this PR?

AI was used to prepare the initial patch and regression tests. The change was checked against the issue reproduction and the available local validation before submission.

PR code and description written by:

  • Human
  • AI

Reviewed before submission by:

  • Human
  • AI
  • Not reviewed

Copilot AI balanced review requested due to automatic review settings November 25, 2026 17:18

Copilot AI 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.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants