apache / apache/datafusion

Allow casting durations to different timeunits

Open
#11,097 1 comment 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?

I would like to be able to cast a duration to a different timeunit.
Current behavior:
```
DataFusion CLI v39.0.0
> SELECT arrow_cast(1, 'Duration(Millisecond)');
+----------------------------------------------------+
| arrow_cast(Int64(1),Utf8("Duration(Millisecond)")) |
+----------------------------------------------------+
| 0 days 0 hours 0 mins 0.001 secs |
+----------------------------------------------------+
1 row(s) fetched.
Elapsed 0.065 seconds.

> SELECT arrow_cast(arrow_cast(1, 'Duration(Millisecond)'), 'Duration(Second)');

This feature is not implemented: Unsupported CAST from Duration(Millisecond) to Duration(Second)
```

### Describe the solution you'd like

The cast works

### Describe alternatives you've considered

_No response_

### Additional context

_No response_

Contributor guide

Open the contributing guide

Research direction

Start by reproducing the nested arrow_cast query in the DataFusion CLI, using the Duration(Millisecond) to Duration(Second) example from the issue. Trace the cast handling for duration values and add coverage for conversions between time units. Done means the query succeeds and returns the correctly converted duration.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
database
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.