perf: Optimize scalar fast path of atan2#20336
Open
kumarUjjawal wants to merge 1 commit intoapache:mainfrom
Open
perf: Optimize scalar fast path of atan2#20336kumarUjjawal wants to merge 1 commit intoapache:mainfrom
kumarUjjawal wants to merge 1 commit intoapache:mainfrom
Conversation
Jefffrey
approved these changes
Feb 13, 2026
Contributor
Jefffrey
left a comment
There was a problem hiding this comment.
I think it's worth adding a note in the PR title/body for what other math UDFs this change would impact
neilconway
approved these changes
Feb 14, 2026
| ColumnarValue::Scalar(y_scalar), | ||
| ColumnarValue::Scalar(x_scalar), | ||
| ) => { | ||
| if y_scalar.is_null() || x_scalar.is_null() { |
Contributor
There was a problem hiding this comment.
Might be a bit cleaner to move this into the match below, since we're already matching on (y_scalar, x_scalar).
| |y, x| f64::$BINARY_FUNC(y, x), | ||
| )?; | ||
| Arc::new(result) as _ | ||
| let return_type = args.return_type().clone(); |
Contributor
There was a problem hiding this comment.
Can we refactor this to avoid doing the clone() unconditionally, even for non-NULL inputs?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Which issue does this PR close?
Rationale for this change
atan2 scalar calls were still going through array conversion in the math binary UDF macro, adding unnecessary overhead for constant folding and scalar evaluation. This PR adds a direct scalar fast path so scalar inputs no longer pay that cost
What changes are included in this PR?
Note: This change targets the make_math_binary_udf macro, which is currently only used by atan2, so the impact in this PR is limited to atan2 only.
Are these changes tested?
Yes
Are there any user-facing changes?
No