apache / apache/datafusion

Optimize CASE expression to produce dictionary-encoded arrays in some cases

Open
#11,605 1 comment 0 reactions 0 assignees View on GitHub
enhancement performance
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?

Here is an example `CASE` expression that produces an array containing exactly two distinct values:

```sql
CASE WHEN expr THEN 1 ELSE 0 END
```

We currently produce an array containing ones and zeros (and nulls). It seems like it would be beneficial to produce a dictionary-encoded array in this case to reduce memory pressure. This could also make subsequent operations more efficient in some cases.

Contributor guide

Open the contributing guide

Research direction

No implementation file, test, or entry point is identified in the issue. Start by locating CASE expression execution and existing dictionary-encoding support, then verify that the example produces a dictionary-encoded array while preserving ones, zeros, and nulls and improving subsequent operations where applicable.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust, sql
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.