apache / apache/datafusion

support: Date +/plus Int or date_add function

Open
#6,876 11 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?

we have requirements related to the date operation, such as `date_add`, `date_sub`.

In the spark and mysql, the `date_add(start_date, value_expr)` function has been supported.
But in the datafusion, we only use the `expr + interval 'value' day` to support them.

In the mysql or the spark, the second args can be the expr, but the datafusion has no method to get the same target.

### Describe the solution you'd like

In the PG document, PG support `date +/plus integer`.

We can try to support this feature in the datafusion or in the kernel of arrow-rs.

### Describe alternatives you've considered

_No response_

### Additional context

cc @waitingkuo @alamb

Contributor guide

Open the contributing guide

Research direction

Start by tracing DataFusion's handling of date expressions and interval arithmetic, then compare the requested date_add/date_sub behavior with PostgreSQL, Spark, and MySQL semantics. Determine whether support belongs in DataFusion or arrow-rs. Done means expression-valued date operations and date + integer behavior work consistently, with tests covering the requested forms.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust, sql
Domain
backend, databases
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.