Skip to content

GH-55394: [C++][Compute] Check overflow when negating duration - #55395

Closed
DiadkoShmek wants to merge 1 commit into
apache:mainfrom
DiadkoShmek:lezo50-duration-negate-checked-20261104
Closed

DiadkoShmek wants to merge 1 commit into
apache:mainfrom
DiadkoShmek:lezo50-duration-negate-checked-20261104

Conversation

@DiadkoShmek

@DiadkoShmek DiadkoShmek commented Nov 4, 2026 •

Copy link
Copy Markdown

Rationale for this change

Fixes GH-55394.

negate_checked registers duration kernels using unchecked Negate, so a valid INT64_MIN duration silently wraps to the same negative value. Its mathematical negation is outside signed64 storage, and the documented checked behavior requires an overflow error.

What changes are included in this PR?

Register duration kernels with the existing NegateChecked implementation. Add regression coverage for all four duration units, scalar/array overflow, representable extrema and nulls, while keeping unchecked negation's wrap behavior.

Are these changes tested?

The exact base and candidate production translation units were compiled separately and run in fresh private registries against the same pinned official PyArrow26.0.1 support libraries. An independent arbitrary precision integer oracle checks 90 input shapes/types and 5,265 outputs per build. The base fails 36 checked-duration overflow checks; the candidate passes all checks.

Coverage includes actual bitmap-valid duration minima, masked minimum payloads, four units, int64 controls, scalar/array/chunked/sliced/empty/all-null inputs, neighboring extrema and ordinary values. Checked absolute value and unchecked negation serve as controls.

A separate review oracle also checked 320 input representations and 26,925 native rows per build: the base has 456 mismatches, all checked-duration overflow, and the candidate has none.

The actual submitted native test translation unit passes syntax-only compilation. The added C++ test range also has zero replacements with the repository-pinned clang-format 18.1.8. These focused checks are not a full current-main build or an execution of the upstream gtest suite; full integration tests remain for CI.

Are there any user-facing changes?

negate_checked now returns the promised overflow error for a valid minimum duration. Representable values, nulls, output duration units and unchecked negation remain unchanged.

Was AI used for this PR?

I directed this work and take responsibility for the contribution and its follow-up. AI assistance was used in producing the change.

PR code and description written by:

  • Human
  • AI

Reviewed before submission by:

  • Human
  • AI
  • Not reviewed

Signed-off-by: DiadkoShmek <207617272+DiadkoShmek@users.noreply.github.com>
@github-actions

github-actions Bot commented Nov 4, 2026

Copy link
Copy Markdown

⚠️ GitHub issue #55394 has been automatically assigned in GitHub to PR creator.

@Reranko05

Copy link
Copy Markdown
Collaborator

We don't need AI only contribution.

@Reranko05 Reranko05 closed this Nov 4, 2026
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.

[C++][Compute] negate_checked silently wraps duration overflow

2 participants