Skip to content

Conversation

@kumarUjjawal
Copy link
Contributor

Which issue does this PR close?

Rationale for this change

  • The current floor and ceil implementations always convert scalar inputs to arrays via values_to_arrays(), which introduces unnecessary overhead when processing single values.

What changes are included in this PR?

  • Add scalar fast path for floor and ceil
  • Add criterion benchmark for floor/ceil to measure performance

Are these changes tested?

  • All sqllogictest pass
  • Addec benchmark
Benchmark Array Time Scalar Time Speedup
floor_f64 (1024) ~396 ns ~147 ns 2.7×
ceil_f64 (1024) ~363 ns ~150 ns 2.4×
floor_f64 (4096) ~681 ns ~144 ns 4.7×
ceil_f64 (4096) ~667 ns ~144 ns 4.6×
floor_f64 (8192) ~1,638 ns ~144 ns 11.4×
ceil_f64 (8192) ~1,634 ns ~144 ns 11.3×

Are there any user-facing changes?

No

@github-actions github-actions bot added the functions Changes to functions implementation label Jan 11, 2026
ScalarValue::Null => {
return Ok(ColumnarValue::Scalar(ScalarValue::Float64(None)));
}
// Decimal types fall through to array path for overflow validation
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For decimals, we could turn the scalars in arrays of size 1, pass through the existing code, then recreate a scalar from the resultant array, to benefit from code reuse and ensure we don't expand the array.

Not the cleanest way to do it but certainly the easiest.

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

Labels

functions Changes to functions implementation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants