regex_match_dyn (array-array path) does not support Dictionary-encoded needle arrays (SIMILAR TO / ~ operators)
- Dominant language
- Rust
- Stars
- 9.3k
- Forks
- 2.4k
- Avg merge
- 3d 7h
- Merged PRs (30d)
- 344
Description
### Describe the bug
The regex kernels' array-array path (regex_match_dyn) does not support Dictionary(_, Utf8)-encoded needle arrays, so SIMILAR TO (and the ~ regex operators) fail with an internal error when the value side is dictionary-encoded and the pattern is a non-scalar array:
```sql
CREATE TABLE t AS SELECT * FROM (VALUES ('user auth failed')) v(s);
CREATE TABLE p AS SELECT * FROM (VALUES ('(auth|login)')) v(pat);
SELECT arrow_cast(t.s, 'Dictionary(Int32, Utf8)') SIMILAR TO p.pat FROM t CROSS JOIN p;
```
```
Internal error: Data type Dictionary(Int32, Utf8) not supported for regex_match_dyn on string array.
```
### Expected behavior
The query should evaluate successfully (return true for this data), like the equivalent LIKE query already does:
```sql
SELECT arrow_cast(t.s, 'Dictionary(Int32, Utf8)') LIKE p.pat FROM t CROSS JOIN p;
-- returns true
```
### Additional context
- The scalar fast path (regex_match_dyn_scalar) already handles Dictionary arrays (see datafusion/physical-expr/src/expressions/binary/kernels.rs), and the LIKE kernels handle dictionary needles in the array-array path, so this is a gap specific to the regex kernels' array-array dispatch.
- Suggested fix: add a DataType::Dictionary arm to regex_match_dyn that matches over the dictionary value type (mirroring the scalar path / like kernels).
- Surfaced during review of #23704 (which fixed the missing type coercion for SIMILAR TO and turned the former panic paths into this proper error). Not a regression from that PR — the limitation is pre-existing.
Contributor guide
Research direction
Start in datafusion/physical-expr/src/expressions/binary/kernels.rs at regex_match_dyn, then compare its array-array dispatch with regex_match_dyn_scalar and the LIKE kernels' dictionary handling. Reproduce the provided SIMILAR TO query and verify that the dictionary-encoded value and non-scalar pattern evaluate successfully, returning true for the example.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- databases
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Quiet
- Clarity
- Clearly specified
- Newbie friendliness
- 76/100