Skip to content

perf: Optimize scalar fast path for regexp_like#20354

Open
kumarUjjawal wants to merge 2 commits intoapache:mainfrom
kumarUjjawal:perf/rlike_scalar_path
Open

perf: Optimize scalar fast path for regexp_like#20354
kumarUjjawal wants to merge 2 commits intoapache:mainfrom
kumarUjjawal:perf/rlike_scalar_path

Conversation

@kumarUjjawal
Copy link
Contributor

Which issue does this PR close?

Rationale for this change

regexp_like was converting scalar inputs into single‑element arrays, adding avoidable overhead for constant folding and scalar‑only evaluations.

What changes are included in this PR?

  • Add a scalar fast path in RegexpLikeFunc::invoke_with_args that evaluates regexp_like directly for scalar inputs
  • Add benchmark
Type Before After Speedup
regexp_like_scalar_utf8 12.092 µs 10.943 µs 1.10x

Are these changes tested?

Yes

Are there any user-facing changes?

NO

@github-actions github-actions bot added the functions Changes to functions implementation label Feb 14, 2026
ColumnarValue::Array(a) => Some(a.len()),
});

let is_scalar = len.is_none();
Copy link
Contributor

Choose a reason for hiding this comment

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

We should take the chance here to do further refactors; for example we can use ColumnarValue::values_to_arrays here

.iter()
.all(|arg| matches!(arg, ColumnarValue::Scalar(_)));

if is_scalar {
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we should think in terms of how people may use this function; while this is a fast path for pure scalar inputs, it could be likely that users would have the first argument as an array but the 2nd/3rd arguments as scalar inputs, so would be worth considering a fast path for that too?

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