AtlasOfLivingAustralia / galah-R

Query living atlases from R
https://galah.ala.org.au
40 stars 2 forks source link

`galah_filter()` checks wrong field when using `is.na` #230

Closed daxkellie closed 7 months ago

daxkellie commented 8 months ago

When trying to use is.na within galah_filter(), an error occurs because it accidentally thinks that * is a field. This is likely a parsing problem.

library(galah)

galah_call() |>
  identify("Gekkonidae") |>
  filter(is.na(decimalLongitude)) |>
  atlas_counts()
#> Error in `check_fields()`:
#> ! Can't use fields that don't exist.
#> ℹ Use `search_all(fields)` to find a valid field ID.
#> ✖ Can't find field(s) in
#>   • `galah_filter()`: *
#> Backtrace:
#>      ▆
#>   1. └─galah::atlas_counts(...)
#>   2.   ├─dplyr::collect(slice_head(count(dr), n = limit))
#>   3.   └─galah:::collect.data_request(slice_head(count(dr), n = limit))
#>   4.     ├─dplyr::collect(compute(collapse(x, ...)), wait = wait, file = file)
#>   5.     ├─dplyr::compute(collapse(x, ...))
#>   6.     ├─dplyr::collapse(x, ...)
#>   7.     └─galah:::collapse.data_request(x, ...)
#>   8.       ├─galah:::parse_query(parse_checks(build_checks(query_set)))
#>   9.       └─galah:::parse_checks(build_checks(query_set))
#>  10.         ├─galah:::check_profiles(check_fields(check_reason(check_login(.query))))
#>  11.         └─galah:::check_fields(check_reason(check_login(.query)))
#>  12.           └─rlang::abort(bullets)

Created on 2024-02-07 with reprex v2.0.2

As a temporary workaround, you can set run_checks = FALSE in galah_config(), bypassing the checks.

galah_config(run_checks = FALSE)

galah_call() |>
  identify("Gekkonidae") |>
  filter(is.na(decimalLongitude)) |>
  atlas_counts()
#> # A tibble: 1 × 1
#>   count
#>   <int>
#> 1  4609

Created on 2024-02-07 with reprex v2.0.2