Skip to content
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

Integers parsed as date times #211

Open
grcatlin opened this issue Jul 19, 2024 · 3 comments
Open

Integers parsed as date times #211

grcatlin opened this issue Jul 19, 2024 · 3 comments
Labels
bug Something isn't working

Comments

@grcatlin
Copy link

Describe the bug
From commit 553e80b onward, integer fields seem to be parsed as date times for some reason. The previous commit (c988b92) parses normally. However, from 553e80b onward, when I hit a integer field it reads as 1969-12-31 17:00:INTEGER.

I.E., I have a temperature field where an observer put in 34, this now reads as 1969-12-31 17:00:34. This is the same whether using argislayers::arc_open() + arcgislayers::arc_select() or just arcgislayers::arc_read().

To Reproduce
Unfortunately, the feature service in question is sensitive and cannot be shared but here is my general workflow:

token <- function() {
    arcgisutils::auth_user(
        username = Sys.getenv("ESRI_USER"),
        password = Sys.getenv("ESRI_PWD")
    )
}

service <- arcgislayers::arc_open(
    "url",
    token = token()
)

arcgislayers::arc_select(service, token = token()) |>
    dplyr::select(males, females, unknown, temp) |>
    sf::st_drop_geometry() |>
    head() |>
    kableExtra::kable()
males females unknown temp
1969-12-31 17:00:18 1969-12-31 17:00:01 1969-12-31 17:00:00 1969-12-31 17:00:50
1969-12-31 17:00:45 1969-12-31 17:00:02 1969-12-31 17:00:00 1969-12-31 17:00:45
1969-12-31 17:00:60 1969-12-31 17:00:04 1969-12-31 17:00:00 1969-12-31 17:00:45
1969-12-31 17:00:18 1969-12-31 17:00:03 1969-12-31 17:00:00 1969-12-31 17:00:45
1969-12-31 17:00:22 1969-12-31 17:00:12 1969-12-31 17:00:00 1969-12-31 17:00:60
1969-12-31 17:00:01 1969-12-31 17:00:01 1969-12-31 17:00:01 1969-12-31 17:00:40

Additional context
Not sure if it would matter but my feature service is from a Survey123 application where the offending fields are specified as:

type name label required
integer males Males: true
integer females Females: true
integer unknown Number Unknown: true
integer temp Temperature (F): true

and so forth in the xlsform.

Additionally, I don't believe I have any integers >= 100 which may change how it would be parsed?

@grcatlin grcatlin changed the title Commit 553e80b508f1d0a72448e86e06858b3eb381c9f7 breaks parsing of integers Integers parsed as date times Jul 19, 2024
@JosiahParry
Copy link
Collaborator

Can you please try installing arcpbf from r-universe?

install.packages("arcpbf", repos = c("https://r-arcgis.r-universe.dev", "https://cloud.r-project.org"))

then restart R and try loading your feature service? I believe I fixed this bug previously this week.

@JosiahParry JosiahParry added bug Something isn't working and removed needs review labels Jul 19, 2024
@grcatlin
Copy link
Author

Hi there, thanks for the quick response!

Install via Remotes

On installing dev version from remotes::

remotes::install_github("r-arcgis/arcgislayers", force = TRUE)
remotes::install_github("r-arcgis/arcpbf", force = TRUE)

# restart R

devtools::package_info(c("arcgislayers", "arcpbf")) |>
    dplyr::filter(stringr::str_starts(package, "arc")) |>
    dplyr::select(package, "ondiskversion", date, source) |>
    data.table::as.data.table() |>
    kableExtra::kable()
package ondiskversion date source
arcgislayers 0.3.0.9000 2024-07-20 Github (754bd2d)
arcgisutils 0.3.0 2024-05-09 CRAN (R 4.4.1)
arcpbf 0.1.3.9000 2024-07-20 Github (R-ArcGIS/arcpbf@5d1a74b)

When trying to arcgislayers::arc_read():

Error in `arc_select()`:
! `as.integer(page_size)` must be a whole number or `NULL`, not an empty integer vector.

Backtrace:
    ▆
 1. └─arcgislayers::arc_read(...)
 2.   └─arcgislayers::arc_select(...)
 3.     └─arcgislayers:::check_number_whole(...)
 4.       └─arcgislayers:::.stop_not_number(...)
 5.         └─arcgislayers:::stop_input_type(...)
 6.           └─rlang::abort(message, ..., call = call, arg = arg)

Install via https://r-arcgis.r-universe.dev

On installing via install.packages():

install.packages("arcpbf", repos = c("https://r-arcgis.r-universe.dev", "https://cloud.r-project.org"))
install.packages("arcgislayers", repos = c("https://r-arcgis.r-universe.dev", "https://cloud.r-project.org"))

# restart R
package ondiskversion date source
arcgislayers 0.3.0.9000 2024-07-20 https://r-arcgis.r-universe.dev (R 4.4.1)
arcgisutils 0.3.0 2024-05-09 CRAN (R 4.4.1)
arcpbf 0.1.3.9000 2024-07-20 https://r-arcgis.r-universe.dev (R 4.4.1)

I get the same

Error in `arc_select()`:
! `as.integer(page_size)` must be a whole number or `NULL`, not an empty integer vector.

Install via CRAN

On installing from CRAN:

install.packages("arcpbf", repos = c("https://cloud.r-project.org"))
install.packages("arcgislayers", repos = c("https://cloud.r-project.org"))

# restart R
package ondiskversion date source
arcgislayers 0.3.0 2024-07-05 CRAN (R 4.4.1)
arcgisutils 0.3.0 2024-05-09 CRAN (R 4.4.1)
arcpbf 0.1.3 2024-07-10 CRAN (R 4.4.1)

arcgislayers::arc_read() works but give the weird 1969-12-31 17:00:INTEGER thing.

Finally, Install dev arcpbf + CRAN arcgislayers

On installing dev version of arcpbf w/ CRAN of arcgislayers:

package ondiskversion date source
arcgislayers 0.3.0 2024-07-05 CRAN (R 4.4.1)
arcgisutils 0.3.0 2024-05-09 CRAN (R 4.4.1)
arcpbf 0.1.3.9000 2024-07-20 https://r-arcgis.r-universe.dev (R 4.4.1)

It parses as expected.

@grcatlin
Copy link
Author

#212 specifically regards the

Error in `arc_select()`:
! `as.integer(page_size)` must be a whole number or `NULL`, not an empty integer vector.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants