pointblank icon indicating copy to clipboard operation
pointblank copied to clipboard

`get_sundered_data()` fails on DB tables when `type = "combined" `

Open petrbouchal opened this issue 5 months ago • 1 comments

Description

When get_sundered_data() is called on an agent interrogating data in a DB table and the type param is "combined", this results in

Error in `.transformer()`:
! `value` must be a string or scalar SQL, not the number 1.

It works fine on local data frames; the error appears with DuckDB and SQLite tables.

Reproducible example

library(pointblank)
library(duckdb)
#> Loading required package: DBI
library(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

con <- dbConnect(RSQLite::SQLite(), "test.sqlite")
tbl_db <- copy_to(con, airquality |> tibble::rowid_to_column("idcol"), 
  "airquality_cp", temporary = TRUE, overwrite = TRUE)

ag <- create_agent(tbl_db) |> 
  col_vals_between(Wind, 1, 2) |>
  col_vals_gt(Ozone, 200) |> 
  interrogate()

ag |> get_sundered_data(id_cols = "idcol", type = "combined")
#> Error in `.transformer()`:
#> ! `value` must be a string or scalar SQL, not the number 1.

dbDisconnect(con)

Created on 2025-07-12 with reprex v2.1.1

Session info

sessioninfo::session_info()
#> ─ Session info ───────────────────────────────────────────────────────────────
#>  setting  value
#>  version  R version 4.4.1 (2024-06-14)
#>  os       macOS 15.5
#>  system   aarch64, darwin20
#>  ui       X11
#>  language (EN)
#>  collate  en_US.UTF-8
#>  ctype    UTF-8
#>  tz       Europe/Prague
#>  date     2025-07-12
#>  pandoc   3.6.3 @ /Applications/Positron.app/Contents/Resources/app/quarto/bin/tools/aarch64/ (via rmarkdown)
#> 
#> ─ Packages ───────────────────────────────────────────────────────────────────
#>  package     * version     date (UTC) lib source
#>  bit           4.0.5       2022-11-15 [1] CRAN (R 4.4.0)
#>  bit64         4.0.5       2020-08-30 [1] CRAN (R 4.4.0)
#>  blastula      0.3.6       2025-04-03 [1] CRAN (R 4.4.1)
#>  blob          1.2.4       2023-03-17 [1] CRAN (R 4.4.0)
#>  cachem        1.1.0       2024-05-16 [1] CRAN (R 4.4.0)
#>  cli           3.6.5.9000  2025-07-12 [1] Github (r-lib/cli@cbb3424)
#>  DBI         * 1.2.3       2024-06-02 [1] CRAN (R 4.4.0)
#>  dbplyr        2.5.0       2024-03-19 [1] CRAN (R 4.4.0)
#>  digest        0.6.37      2024-08-19 [1] CRAN (R 4.4.1)
#>  dplyr       * 1.1.4       2023-11-17 [1] CRAN (R 4.4.0)
#>  duckdb      * 1.3.0       2025-06-02 [1] CRAN (R 4.4.1)
#>  evaluate      1.0.4       2025-06-18 [1] CRAN (R 4.4.1)
#>  fastmap       1.2.0       2024-05-15 [1] CRAN (R 4.4.0)
#>  fs            1.6.6       2025-04-12 [1] CRAN (R 4.4.1)
#>  generics      0.1.4       2025-05-09 [1] CRAN (R 4.4.1)
#>  glue          1.8.0       2024-09-30 [1] CRAN (R 4.4.1)
#>  htmltools     0.5.8.1     2024-04-04 [1] CRAN (R 4.4.0)
#>  knitr         1.50        2025-03-16 [1] CRAN (R 4.4.1)
#>  lifecycle     1.0.4       2023-11-07 [1] CRAN (R 4.4.0)
#>  magrittr      2.0.3       2022-03-30 [1] CRAN (R 4.4.0)
#>  memoise       2.0.1       2021-11-26 [1] CRAN (R 4.4.0)
#>  pillar        1.11.0      2025-07-04 [1] CRAN (R 4.4.1)
#>  pkgconfig     2.0.3       2019-09-22 [1] CRAN (R 4.4.0)
#>  pointblank  * 0.12.2.9000 2025-07-12 [1] Github (rstudio/pointblank@8371ca0)
#>  purrr         1.1.0       2025-07-10 [1] RSPM (R 4.4.0)
#>  R6            2.6.1       2025-02-15 [1] CRAN (R 4.4.1)
#>  reprex        2.1.1       2024-07-06 [1] CRAN (R 4.4.0)
#>  rlang         1.1.6       2025-04-11 [1] CRAN (R 4.4.1)
#>  rmarkdown     2.29        2024-11-04 [1] CRAN (R 4.4.1)
#>  RSQLite       2.4.1       2025-06-08 [1] CRAN (R 4.4.1)
#>  sessioninfo   1.2.2       2021-12-06 [1] CRAN (R 4.4.0)
#>  tibble        3.3.0       2025-06-08 [1] CRAN (R 4.4.1)
#>  tidyselect    1.2.1       2024-03-11 [1] CRAN (R 4.4.0)
#>  vctrs         0.6.5       2023-12-01 [1] CRAN (R 4.4.0)
#>  withr         3.0.2       2024-10-28 [1] CRAN (R 4.4.1)
#>  xfun          0.52        2025-04-02 [1] CRAN (R 4.4.1)
#>  yaml          2.3.10      2024-07-26 [1] CRAN (R 4.4.1)
#> 
#>  [1] /Users/petr/Library/R/4.4/library
#>  [2] /Library/Frameworks/R.framework/Versions/4.4-arm64/Resources/library
#> 
#> ──────────────────────────────────────────────────────────────────────────────

Expected result

This should work the same for DBs and local data frames.

Session info

see reprex

petrbouchal avatar Jul 12 '25 15:07 petrbouchal

I just added a fix in the same style of the MSSQL contributions I made a while back.

I tested the example above and it works with this change: https://github.com/rstudio/pointblank/pull/649

pachadotdev avatar Aug 27 '25 14:08 pachadotdev