perf: Optimize scalar fast path for nanvl#20205
Open
kumarUjjawal wants to merge 1 commit intoapache:mainfrom
Open
perf: Optimize scalar fast path for nanvl#20205kumarUjjawal wants to merge 1 commit intoapache:mainfrom
kumarUjjawal wants to merge 1 commit intoapache:mainfrom
Conversation
Jefffrey
reviewed
Feb 8, 2026
| match (&x, &y) { | ||
| (ColumnarValue::Scalar(x), ColumnarValue::Scalar(y)) => { | ||
| // NULL propagation | ||
| if x.is_null() || y.is_null() { |
Contributor
There was a problem hiding this comment.
I don't think this is quite right; from Spark:
>>> spark.sql("select nanvl(null, 1)").show()
+--------------+
|nanvl(NULL, 1)|
+--------------+
| NULL|
+--------------+
>>> spark.sql("select nanvl(1, null)").show()
+--------------+
|nanvl(1, NULL)|
+--------------+
| 1.0|
+--------------+
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
nanvlcurrently evaluates scalar inputs viamake_scalar_function(nanvl, vec![]), which converts scalar values intosize‑1 arrays before execution and then converts back. This adds unnecessary overhead for constant folding / scalar
evaluation
What changes are included in this PR?
ColumnarValue::Scalar + ColumnarValue::Scalarnanvl/scalar_f64nanvl/scalar_f32Benchmark | Before | After | Speedup
━━━━━━━━━━━━━━━━━━━━━━━
nanvl/scalar_f64 | ~240.1 ns | 50.104 ns ~4.79x
nanvl/scalar_f32 |~237.1 ns | 49.284 ns ~4.81x
Are these changes tested?
Yes
Are there any user-facing changes?
No