apache / apache/datafusion

[BUG] Error when adding Date32 and Int64

Open
#12,342 14 comments 1 reaction 0 assignees View on GitHub
bug good first issue
Dominant language
Rust
Stars
9.3k
Forks
2.4k
Avg merge
3d 7h
Merged PRs (30d)
344

Description

### Describe the bug

DataFusion 41
```
> select to_date('1970-01-01', 'yyyy-mm-dd') + 5;
Error during planning: Cannot coerce arithmetic expression Date32 + Int64 to valid types
```

The same query runs ok in Postgres
Workaround
```
> select to_date('1970-01-01') + interval '5' day;
+-------------------------------------------------------------------------------------------------------------------+
| to_date(Utf8("1970-01-01")) + IntervalMonthDayNano("IntervalMonthDayNano { months: 0, days: 5, nanoseconds: 0 }") |
+-------------------------------------------------------------------------------------------------------------------+
| 1970-01-06 |
+-------------------------------------------------------------------------------------------------------------------+

```

### To Reproduce

```
select to_date('1970-01-01', 'yyyy-mm-dd') + 5;
```

### Expected behavior

Query should work

### Additional context

_No response_

Contributor guide

Open the contributing guide

Research direction

Run the listed DataFusion 41 query and confirm the Date32 + Int64 planning error. Search for the "Cannot coerce arithmetic expression" error and trace the arithmetic type-coercion path. Done means the query succeeds and returns the expected date, without requiring the interval workaround.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust, sql
Domain
backend, databases
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
64/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.