You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jira@arrow.apache.org by "Ian Cook (Jira)" <ji...@apache.org> on 2021/09/17 19:03:00 UTC

[jira] [Updated] (ARROW-14028) [R] Cast of NaN to integer should return NA_integer_

     [ https://issues.apache.org/jira/browse/ARROW-14028?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Ian Cook updated ARROW-14028:
-----------------------------
    Description: 
Casting double {{NaN}} to integer returns a sentinel value:
{code:r}
call_function("cast", Scalar$create(NaN), options = list(to_type = int32(), allow_float_truncate = TRUE))
#> Scalar
#> -2147483648

call_function("cast", Scalar$create(NaN), options = list(to_type = int64(), allow_float_truncate = TRUE))
#> Scalar
#> -9223372036854775808{code}
It would be nice if this would instead return {{NA_integer}}.

N.B. for some reason this doesn't reproduce in dplyr unless you round-trip it back to double:
{code:r}
> Table$create(x = NaN) %>% transmute(as.double(as.integer(x))) %>% pull(1)
#> [1] -2147483648{code}

  was:
Casting double {{NaN}} to integer returns a sentinel value:
{code:r}
call_function("cast", Scalar$create(NaN), options = list(to_type = int32(), allow_float_truncate = TRUE))
#> Scalar
#> -2147483648

call_function("cast", Scalar$create(NaN), options = list(to_type = int64(), allow_float_truncate = TRUE))
#> Scalar
#> -9223372036854775808{code}
It would be nice if this would instead return {{NA_integer}}.


> [R] Cast of NaN to integer should return NA_integer_
> ----------------------------------------------------
>
>                 Key: ARROW-14028
>                 URL: https://issues.apache.org/jira/browse/ARROW-14028
>             Project: Apache Arrow
>          Issue Type: Improvement
>          Components: R
>            Reporter: Ian Cook
>            Priority: Major
>
> Casting double {{NaN}} to integer returns a sentinel value:
> {code:r}
> call_function("cast", Scalar$create(NaN), options = list(to_type = int32(), allow_float_truncate = TRUE))
> #> Scalar
> #> -2147483648
> call_function("cast", Scalar$create(NaN), options = list(to_type = int64(), allow_float_truncate = TRUE))
> #> Scalar
> #> -9223372036854775808{code}
> It would be nice if this would instead return {{NA_integer}}.
> N.B. for some reason this doesn't reproduce in dplyr unless you round-trip it back to double:
> {code:r}
> > Table$create(x = NaN) %>% transmute(as.double(as.integer(x))) %>% pull(1)
> #> [1] -2147483648{code}



--
This message was sent by Atlassian Jira
(v8.3.4#803005)