Skip to content

fix(data.remote): collapse multiple machine_ids in NLCD queries - #4297

Draft
madhavzanwar wants to merge 1 commit into
PecanProject:developfrom
madhavzanwar:GH-4295-nlcd-collapse-machine-query
Draft

madhavzanwar wants to merge 1 commit into
PecanProject:developfrom
madhavzanwar:GH-4295-nlcd-collapse-machine-query

Conversation

@madhavzanwar

Copy link
Copy Markdown
Contributor

Description

In modules/data.remote/R/NLCD.R, download.NLCD() and extract_NLCD() queried matching machines using paste(chk$machine_id, sep = ",") inside SELECT * from machines where id in (...). Because paste() with sep does not collapse vectors, having multiple matching machine entries produced a vector of multiple SQL query strings (c("SELECT * from machines where id in ( 11 )", "SELECT * from machines where id in ( 22 )")) instead of a single SQL query string ("SELECT * from machines where id in ( 11,22 )").

Changed to paste(chk$machine_id, collapse = ",") in both functions, added regression tests in modules/data.remote/tests/testthat/test-NLCD.R, and updated modules/data.remote/NEWS.md and CHANGELOG.md.

Fixes #4295

Verification

  • Before fix (develop): devtools::test("/work/modules/data.remote", filter = "NLCD") failed ([ FAIL 3 | WARN 0 | SKIP 0 | PASS 0 ]), failing length and regex assertions due to vector query splitting.
  • After fix (pecan/base:develop Docker): all modules/data.remote tests passed ([ FAIL 0 | WARN 0 | SKIP 1 | PASS 18 ]).

Use collapse = "," instead of sep = "," when querying the machines table in download.NLCD() and extract_NLCD() so multiple machine records produce a single SQL query string rather than a vector of queries.

Fixes PecanProject#4295
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

download.NLCD() and extract_NLCD() use paste() with sep instead of collapse for machine query

1 participant