apache / apache/datafusion

Specialized / Pre-compiled / Prepared ScalarUDFs

Open
#8,051 19 comments 0 reactions 0 assignees View on GitHub
enhancement
Dominant language
Rust
Stars
9.3k
Forks
2.4k
Avg merge
3d 7h
Merged PRs (30d)
344

Description

### Is your feature request related to a problem or challenge?

Currently, scalar UDF functions can not be "specialized"

```select
SELECT * FROM t where my_matcher(t.column, '[a-z].*');
```

What happens is that the regexp string `'[a-z].*'` gets passed as a literal expression to each invocation of the function, then you have to compile the regex again and again for every batch you process through the UDF.

Since it is expensive to compile these RegExps, it would be nice if there was something that could compile the RegExp once per plan rather than once per batch

### Describe the solution you'd like

_No response_

### Describe alternatives you've considered

See comments below

### Additional context

Suggested by @thinkharderdev on https://github.com/apache/arrow-datafusion/issues/8045#issuecomment-1793267211

Contributor guide

Open the contributing guide

Research direction

Start with the scalar UDF invocation described in the issue and review the alternatives in the comment thread, including the linked issue discussion. Trace how the query plan handles the literal regular-expression argument and identify the relevant planning and execution entry points. Done means a constant pattern can be prepared once per plan rather than recompiled for every batch, with coverage for the example query.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
databases
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.