Open bobhy opened 1 year ago
Problem still repros in 0.79. Here's a slightly different repro, where the question is what dataframe is being created? Error says 'error creating dataframe'.
〉let d1 = (((date now | dfr into-df)) | inspect)
╭─────────────┬───────────╮
│ description │ dataframe │
├─────────────┴───────────┤
│ │
├─────────────────────────┤
│ dataframe │
╰─────────────────────────╯
|v| ----------------------------------------------------/home/bobhy ----------------------------------------------------
〉let d2 = (((date now) - 10sec) | dfr into-df | inspect)
╭─────────────┬───────────╮
│ description │ dataframe │
├─────────────┴───────────┤
│ │
├─────────────────────────┤
│ dataframe │
╰─────────────────────────╯
|v| ----------------------------------------------------/home/bobhy ----------------------------------------------------
〉$d1 - $d2
Error:
× Error creating Dataframe
help: Value not supported in nushell: duration[ms]
reconfirmed with same repro in: key | value |
---|---|
version | 0.79.1 |
branch | test |
commit_hash | 738e1211332a9cb4fe83f6a6419906444eb08803 |
Describe the bug
Can't calculate duration between 2 datetime columns in a dataframe. Also cannot calculate other_date from datetime and duration columns.
How to reproduce
Problem trying to calculate a duration:
Here, it looks like dataframe wants to truncate NuShell datetime values (nanosec resolution) to a datatype with millisecond resolution, and likewise (wants to) truncate a NuShell duration to milliseconds.
But in
10sec | dfr into-df
, something breaks down across the pipe operator and the column gets vanillai64
(Python-speak forusize
?). I guess it should be duration[ms], per the error messageOK, so what is the duration actually stored in the dataframe?
The raw value for duration appears to be nanoseconds while the raw datetime is seconds (since linux epoch)
So if I calculate a duration as difference between raw timestamps, I get a number of seconds, which makes sense.
But that's not consistent with whatever is going on when a Nushell duration is stored in a df column directly -- it seems the conversion botch is just on the duration type.
Some similar error happens when calculating an offset date from a date and a duration, though the error is different, and dependent on the order of operations as well.
Expected behavior
I'd like to be able to do both duration and offset date calculations between columns in a dataframe using minus and plus operations.
At a minimum, dataframes should support 32 bit timestamps and durations (1 second resolution).
Ideally, dataframes would do 64bit NuShell-style datetime and duration (nanosec resolution bits)
Screenshots
No response
Configuration
Additional context
No response