-
Notifications
You must be signed in to change notification settings - Fork 13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Converting date to string in andromeda object #27
Comments
Ofcourse it can be overcome by bringing full data into R using dplyr::collect() but that would defeat the purpose of Andromeda
|
Yea. All these issues with Andromeda dates are due to the lack of a date type in SQLite. RSQLite tries to make it look like SQLite has dates. I have a pretty unsatisfactory solution but I think it does convert the date to a character string in the database. (I think 2440588 is the Julian date of Jan 1, 1970) library(Andromeda)
anAndromedaObject <- Andromeda::andromeda()
anAndromedaObject$dataFrameWithDate <- dplyr::tibble(todayDate = Sys.Date())
anAndromedaObject$dataFrameWithDate
#> # Source: table<dataFrameWithDate> [?? x 1]
#> # Database: sqlite 3.36.0
#> todayDate
#> <date>
#> 1 2021-10-13
anAndromedaObject$dataFrameWithDate <-
anAndromedaObject$dataFrameWithDate %>%
mutate(todayDate = date(todayDate, "+2440588 days"))
anAndromedaObject$dataFrameWithDate
#> # Source: table<dataFrameWithDate> [?? x 1]
#> # Database: sqlite 3.36.0
#> todayDate
#> <chr>
#> 1 2021-10-13
close(anAndromedaObject) Created on 2021-10-13 by the reprex package (v2.0.1) |
This will be addressed in the next release (arrow_S4 branch) library(Andromeda)
#> Loading required package: dplyr
#>
#> Attaching package: 'dplyr'
#> The following objects are masked from 'package:stats':
#>
#> filter, lag
#> The following objects are masked from 'package:base':
#>
#> intersect, setdiff, setequal, union
anAndromedaObject <- Andromeda::andromeda()
anAndromedaObject$dataFrameWithDate <- dplyr::tibble(todayDate = Sys.Date())
anAndromedaObject$dataFrameWithDate <- anAndromedaObject$dataFrameWithDate %>%
dplyr::mutate(todayDate = as.character(.data$todayDate))
collect(anAndromedaObject$dataFrameWithDate)
#> # A tibble: 1 × 1
#> todayDate
#> <chr>
#> 1 2022-11-20 Created on 2022-11-20 with reprex v2.0.2 |
I think as.character() on date in Andromeda object - still converts date to integer and then string
oserved behavior
expected behavior
maybe related to
#11
The text was updated successfully, but these errors were encountered: