Skip to content

Conversation

@theirix
Copy link
Contributor

@theirix theirix commented Jan 18, 2026

Which issue does this PR close?

Rationale for this change

A helper calculate_binary_math and UDFs relying on it could behave strangely if the scales of inputs and outputs are different. Original logic didn't fully handle it.

So let's introduce calculate_binary_math_decimal and calculate_binary_math_numeric functions with a proper handling of arguments of different scales and type casting for input and output arguments.

They supersede calculate_binary_math and calculate_binary_math_decimal because they have a slightly different functor signature that automatically passes the effective precision and scale (even if rescaled). The rest is compatible.

What changes are included in this PR?

  • New functions
  • Port existing UDFs to new functions

Are these changes tested?

  • Existing unit tests
  • SLTs

Are there any user-facing changes?

Older functions could be deprecated. Since they are a part of the public interface of datafusion-functions, I just placed a comment without a full-fledged deprecate macro. Up to discussion whether it should be used

Introduce calculate_binary_math_decimal and
calculate_binary_math_numeric functions
with a proper handling of arguments of different scales
and type casting.

They supersede calculate_binary_math and calculate_binary_math_decimal
due to having a slightly different functior signature with automatic
passing of effective precision and scale (even if rescaled).
@github-actions github-actions bot added sqllogictest SQL Logic Tests (.slt) functions Changes to functions implementation labels Jan 18, 2026
@theirix theirix marked this pull request as ready for review January 18, 2026 16:40
@theirix
Copy link
Contributor Author

theirix commented Jan 18, 2026

Recent related changes: #18525 and #19384 . Epic #18889

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

Labels

functions Changes to functions implementation sqllogictest SQL Logic Tests (.slt)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Improve scale support for binary decimal operations

1 participant