apache / apache/datafusion

Enhance Interval arithmetic to support String type.

Open
#7,098 7 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 DataFusion does not support Interval arithmetic on string type, and the stats `analyze` process will be failed during CBO stats estimation process.

I think maybe we can normalize the string intervals to numeric intervals first and leverage the numeric intervals to estimate the `selectivity`.

Init input Bound:
["aaa", "xyz123"] => [0, 1]

Estimated Bound (example)
["ccc", "ddd"] => [0.2, 0.3]

estimated selectivity:
0.1

The Normalization of the string intervals can be based on ascil code ordering, for any non-ascil char, we can just return early.

### Describe the solution you'd like

_No response_

### Describe alternatives you've considered

_No response_

### Additional context

_No response_

Contributor guide

Open the contributing guide

Research direction

The issue points to the stats analyze process and CBO stats estimation; start by tracing the interval selectivity path and existing numeric interval handling there. Define how ASCII string bounds normalize, including the non-ASCII early-return case, then verify that analyze no longer fails and selectivity is estimated for string intervals.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.