apache / apache/datafusion

Use specialized dictionary compute kernels for binary PhysicalExpr evaluation

Open
#1,178 0 comments 0 reactions 0 assignees View on GitHub
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? Please describe what you are trying to do.**
Today, DataFusion's expression evaluation does not work natively on DictionaryArrays; Instead what happens is that the DictionaryArrays are unpacked into their base type (e.g. a string dictionary gets unpacked into a StringArray)

This is very inefficient, especially for expressions like `col != 'foo'` -- if `col` is a `DictionaryArray` this filter could be applied by finding `'foo'` in the dictionary and then checking for values with that dictionary index, and the dictionary could be reused at the output.

**Describe the solution you'd like**
When

That probably looks something like:
- [x] implement the arrow compute kernels https://github.com/apache/arrow-rs/issues/869
- [ ] change coercion rules for binary expressions to avoid casting (unpacking) dictionaries into the base arrays
- [ ] Call appropriate arrow compute kernels in [binary.rs](https://github.com/apache/arrow-datafusion/blob/master/datafusion/src/physical_plan/expressions/binary.rs)

**Describe alternatives you've considered**

**Additional context**
See https://github.com/apache/arrow-datafusion/issues/87 for more detail

There are several other operation where dictionary calculation could be much better (e.g. hash aggregate, join, etc)

Contributor guide

Open the contributing guide

Research direction

Start by reading datafusion/src/physical_plan/expressions/binary.rs and the linked Arrow compute-kernel work. Trace the binary-expression coercion rules to identify where DictionaryArrays are unpacked, then determine which specialized kernels apply. Done means dictionary inputs avoid unnecessary unpacking for supported binary expressions and the existing behavior remains correct.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
databases
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.