apache / apache/datafusion

Support multiply and divide on intervals

Open
#13,850 4 comments 0 reactions 1 assignee Claimed by @peterxcli View on GitHub
enhancement waiting-on-upstream
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?

Copied directly from https://github.com/apache/arrow-rs/issues/6335 from @samuelcolvin

In Postgres I can do:

```sql
select 3 * interval '1 day';
select interval '1 day' * 3; -- same
select 1.23 * interval '1 day';
-- and divide
select interval '1 day' / 3;
```

I started trying to add support for this to datafusion but discovered that the operations aren't supported in arrow-rs and adding them (with support for all numeric types) is far from trivial.

### Describe the solution you'd like

The idea is to support the syntax above in DataFusion

High level steps are:
- [ ] Arrow-rs support: https://github.com/apache/arrow-rs/pull/6906
- [ ] PR in DataFusion to allow the operations and add appropriate tests

### Describe alternatives you've considered

_No response_

### Additional context

I believe @milevin is already working on this (so perhaps you would like to assign this ticket to yourself via `take`)

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.