Skip to content

GH-34824: [C++][Python] Construct month-day-nanosecond intervals from parts - #53689

Open
michaelbawuah wants to merge 1 commit into
apache:mainfrom
michaelbawuah:gh-34824-interval-from-parts
Open

michaelbawuah wants to merge 1 commit into
apache:mainfrom
michaelbawuah:gh-34824-interval-from-parts

Conversation

@michaelbawuah

@michaelbawuah michaelbawuah commented Oct 13, 2026 •

Copy link
Copy Markdown

Rationale for this change

Existing Arrow integer columns cannot directly be assembled into a
month-day-nanosecond interval array through the compute API. This adds the
constructor proposed in GH-34824, allowing callers to work with Arrow columns
and broadcast scalar components without assembling Python tuples.

What changes are included in this PR?

  • Add month_day_nano_interval_from_parts(months, days, nanoseconds) and the
    C++ eager API MonthDayNanoIntervalFromParts.
  • Accept integer and null inputs, with safe casts to int32 months/days and
    int64 nanoseconds, standard scalar broadcasting and null intersection.
  • Write interval components directly into the preallocated output buffer,
    preserving the supplied values without normalization.
  • Register the kernel, update CMake and Meson source lists, and document the
    function in the C++ compute reference and Python API index.
  • Add C++/Python contract tests and paired native-builder benchmarks.

Are these changes tested?

The seven new C++ cases and 14 new Python cases pass. Coverage includes every
array/scalar combination, nulls, sliced validity offsets, empty/chunked inputs,
dictionary inputs, integer limits, checked overflow, rejected types, invalid
arity/lengths, and the C++ eager API.

The full native temporal, compute-internals and cast selections report 242
passed and one existing locale-dependent skip. Related Python registry and
temporal tests report 25 passed and two optional-cloudpickle skips. The Release
benchmark target builds and runs; it compares against a pre-reserved native
builder with five repeats across sizes, null densities, and broadcasting modes.

Are there any user-facing changes?

There is a new C++ eager API and automatically exposed Python compute function:

days = pa.array([1, 32, None], type=pa.int32())
pc.month_day_nano_interval_from_parts(0, days, 0)
# [(0, 1, 0), (0, 32, 0), None]

Integer components outside their physical widths raise an error. If any
component is null, the interval is null. Values such as 32 days are preserved
without being converted to months.

Was AI used for this PR?

In accordance to the AI generation guidelines, please disclose below whether and how AI was used in this PR.

PR code and description written by:

  • Human
  • AI

Reviewed before submission by:

  • Human
  • AI
  • Not reviewed

@github-actions

Copy link
Copy Markdown

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

@github-actions

Copy link
Copy Markdown

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

1 similar comment
@github-actions

Copy link
Copy Markdown

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

@michaelbawuah

Copy link
Copy Markdown
Author

Rationale for this change

Existing Arrow integer columns cannot directly be assembled into a
month-day-nanosecond interval array through the compute API. This adds the
constructor proposed in GH-34824, allowing callers to work with Arrow columns
and broadcast scalar components without assembling Python tuples.

What changes are included in this PR?

  • Add month_day_nano_interval_from_parts(months, days, nanoseconds) and the
    C++ eager API MonthDayNanoIntervalFromParts.
  • Accept integer and null inputs, with safe casts to int32 months/days and
    int64 nanoseconds, standard scalar broadcasting and null intersection.
  • Write interval components directly into the preallocated output buffer,
    preserving the supplied values without normalization.
  • Register the kernel, update CMake and Meson source lists, and document the
    function in the C++ compute reference and Python API index.
  • Add C++/Python contract tests and paired native-builder benchmarks.

Are these changes tested?

The seven new C++ cases and 14 new Python cases pass. Coverage includes every
array/scalar combination, nulls, sliced validity offsets, empty/chunked inputs,
dictionary inputs, integer limits, checked overflow, rejected types, invalid
arity/lengths, and the C++ eager API.

The full native temporal, compute-internals and cast selections report 242
passed and one existing locale-dependent skip. Related Python registry and
temporal tests report 25 passed and two optional-cloudpickle skips. The Release
benchmark target builds and runs; it compares against a pre-reserved native
builder with five repeats across sizes, null densities, and broadcasting modes.

Are there any user-facing changes?

There is a new C++ eager API and automatically exposed Python compute function:

days = pa.array([1, 32, None], type=pa.int32())
pc.month_day_nano_interval_from_parts(0, days, 0)
# [(0, 1, 0), (0, 32, 0), None]

Integer components outside their physical widths raise an error. If any
component is null, the interval is null. Values such as 32 days are preserved
without being converted to months.

Was AI used for this PR?

In accordance to the AI generation guidelines, please disclose below whether and how AI was used in this PR.

PR code and description written by:

  • [ #] Human
  • AI

Reviewed before submission by:

  • [ #] Human
  • AI
  • Not reviewed

@michaelbawuah michaelbawuah changed the title GH-34824: [C++][Python] Construct month-day-nanosecond intervals from… GH-34824: [C++][Python] Construct month-day-nanosecond intervals from parts Oct 13, 2026
@github-actions

Copy link
Copy Markdown

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

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.

1 participant