datafusion icon indicating copy to clipboard operation
datafusion copied to clipboard

Allow casting durations to different timeunits

Open simonvandel opened this issue 1 year ago • 1 comments

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

simonvandel avatar Jun 24 '24 13:06 simonvandel

This makes sense -- the easist way would be to add support in the arrow cast kernels

Looks like only Int --> Duration is supported now

https://github.com/apache/arrow-rs/blob/0a4d8a14b58e45ef92e31541f0b51a5b25de5f10/arrow-cast/src/cast/mod.rs#L274-L275

alamb avatar Jun 27 '24 22:06 alamb