Skip to content

Replace duplicated scalar/array broadcast match in math_funcs with a shared helper #6982

Open

Description

@andygrove

What is the problem the feature request solves?

The same match that turns a (ColumnarValue, ColumnarValue) pair into two equal-length ArrayRefs is pasted into several math functions in native/spark-expr/src/math_funcs/:

The copies are identical apart from variable names, so there is no drift today, but they all need to change together if scalar broadcasting behaviour changes.

Describe the potential solution

Replace the copies with ColumnarValue::values_to_arrays(&[left, right]) from DataFusion, or, if the scalar-scalar length-1 behaviour needs to stay explicit, a single broadcast_pair(l, r) -> Result<(ArrayRef, ArrayRef)> helper in math_funcs, and call it from each site.

Additional context

This is small and a good first issue. Line references are pinned to commit 7d8d9b1.

Activity

  1. med9110 commented on Oct 15, 2026

    @med9110

    Hi @andygrove, I'd be interested in contributing to #6982.

    I verified the duplicated scalar/array broadcasting logic and would like to consolidate it using ColumnarValue::values_to_arrays, provided it preserves the existing scalar-scalar and error behavior.

    I'll add focused regression coverage and run the relevant expression tests.

    I noticed the issue still has requires-triage. Is it ready for an external contributor to pick up?

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions