AtlasOfLivingAustralia / galah-R

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

`galah_identify()` triggers multiple errors when there are no matched taxa in a query #219

Closed daxkellie closed 6 months ago

daxkellie commented 7 months ago

When a galah query containing galah_identify() returns no matched taxa, the query triggers multiple other warnings/errors.

galah_call() |>
  identify("scarabidae") |>
  atlas_counts()
#> Matched 0 of 1 taxonomic search terms in selected atlas (Australia).
#> 1 unmatched search term:
#> • "scarabidae"
#> 
#> Warning: Unknown or uninitialised column: `taxon_concept_id`.
#> Error in order(ids): argument 1 is not a vector

Created on 2023-12-05 with reprex v2.0.2

galah appears to be trying to run the query with an empty identify argument for the rest of the query, triggering these other errors.

When there are no taxonomic matches, galah_identify() should either abort, or remove the presence of the identify argument so that the query is run as if there was no galah_identify() in the query (along with a message that this has happened). In this case, this would return the complete ALA counts, e.g.

galah_call() |>
  # identify("scarabidae") |>
  atlas_counts()
#> # A tibble: 1 × 1
#>       count
#>       <int>
#> 1 132322753

Created on 2023-12-05 with reprex v2.0.2

daxkellie commented 6 months ago

After discussion, we decided that ending the query early was a more transparent solution than ignoring the argument and therefore returning results for a query that wasn't intended by the user.