You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jira@arrow.apache.org by "Dragoș Moldovan-Grünfeld (Jira)" <ji...@apache.org> on 2022/03/03 09:57:00 UTC

[jira] [Created] (ARROW-15833) [C++] Support casting from duration to string/utf8

Dragoș Moldovan-Grünfeld created ARROW-15833:
------------------------------------------------

             Summary: [C++] Support casting from duration to string/utf8
                 Key: ARROW-15833
                 URL: https://issues.apache.org/jira/browse/ARROW-15833
             Project: Apache Arrow
          Issue Type: Improvement
          Components: C++, R
    Affects Versions: 7.0.0
            Reporter: Dragoș Moldovan-Grünfeld


Cast from {{duration[s]}} to {{utf8}} is not supported. This surfaced in R as an error when trying to write to CSV.

{code:r}
arrow::write_csv_arrow(data.frame(time = as.difftime(1, units="secs")), "test.csv")
#> Error: NotImplemented: Unsupported cast from duration[s] to utf8 using function cast_string
{code}
 
{code:r}
library(arrow, warn.conflicts = FALSE)
#> See arrow_info() for available features
c <- Array$create(as.difftime(32, units = "secs"))
c
#> Array
#> <duration[s]>
#> [
#>   32
#> ]

c$cast(string())
#> Error: NotImplemented: Unsupported cast from duration[s] to utf8 using function cast_string
#> /Users/dragos/Documents/arrow/cpp/src/arrow/compute/function.cc:231  DispatchBest(&inputs)
{code}
I guess the desired output would be to cast to "current" units even if we lose the metadata
{code:r}
c$cast(int64())$cast(string())
#> Array
#> <string>
#> [
#>   "32"
#> ]

c$cast(duration(unit = "ms"))$cast(int64())$cast(string())
#> Array
#> <string>
#> [
#>   "32000"
#> ]
{code}



--
This message was sent by Atlassian Jira
(v8.20.1#820001)