tidyverse / dbplyr

Database (DBI) backend for dplyr
https://dbplyr.tidyverse.org
Other
469 stars 169 forks source link

Issue with translation of `is.na` #1518

Open andreassoteriadesmoj opened 2 weeks ago

andreassoteriadesmoj commented 2 weeks ago

There seems to be a problem with the translation of function is.na to SQL:

library(magrittr)

irisdb <- dbplyr::memdb_frame(iris)

irisdb %>% 
  dplyr::filter(!is.na(Species))

# Error: near ")": syntax error

Note that NULL is missing from the translation:

irisdb %>% 
  dplyr::filter(!is.na(Species)) %>% 
  dbplyr::sql_render()

# <SQL> SELECT *
# FROM `dbplyr_001`
# WHERE (NOT((`Species` IS )))

Session info:

R version 4.4.0 (2024-04-24)
Platform: x86_64-pc-linux-gnu
Running under: Ubuntu 22.04.4 LTS

Matrix products: default
BLAS:   /usr/lib/x86_64-linux-gnu/openblas-pthread/libblas.so.3 
LAPACK: /usr/lib/x86_64-linux-gnu/openblas-pthread/libopenblasp-r0.3.20.so;  LAPACK version 3.10.0

locale:
 [1] LC_CTYPE=en_GB.UTF-8       LC_NUMERIC=C              
 [3] LC_TIME=en_GB.UTF-8        LC_COLLATE=en_GB.UTF-8    
 [5] LC_MONETARY=en_GB.UTF-8    LC_MESSAGES=en_GB.UTF-8   
 [7] LC_PAPER=en_GB.UTF-8       LC_NAME=C                 
 [9] LC_ADDRESS=C               LC_TELEPHONE=C            
[11] LC_MEASUREMENT=en_GB.UTF-8 LC_IDENTIFICATION=C       

time zone: Etc/UTC
tzcode source: system (glibc)

attached base packages:
[1] stats     graphics  grDevices datasets  utils     methods   base     

other attached packages:
[1] magrittr_2.0.3   offendeR_1.2.2   testthat_3.2.1.1

loaded via a namespace (and not attached):
 [1] xfun_0.45                    htmlwidgets_1.6.4           
 [3] devtools_2.4.5               remotes_2.5.0               
 [5] noctua_2.6.2                 tzdb_0.4.0                  
 [7] vctrs_0.6.5                  tools_4.4.0                 
 [9] generics_0.1.3               curl_5.2.1                  
[11] RSQLite_2.3.7                tibble_3.1.7                
[13] fansi_1.0.6                  paws.security.identity_0.6.1
[15] blob_1.2.4                   paws.common_0.7.3           
[17] pkgconfig_2.0.3              data.table_1.15.4           
[19] dbplyr_2.1.1.9000            desc_1.4.3                  
[21] assertthat_0.2.1             uuid_1.2-0                  
[23] lifecycle_1.0.4              compiler_4.4.0              
[25] stringr_1.5.1                paws.analytics_0.6.0        
[27] brio_1.1.5                   httpuv_1.6.15               
[29] htmltools_0.5.8.1            usethis_2.2.3               
[31] yaml_2.3.8                   later_1.3.2                 
[33] pillar_1.9.0                 crayon_1.5.2                
[35] urlchecker_1.0.1             ellipsis_0.3.2              
[37] cachem_1.1.0                 Rdbtools_0.4.0              
[39] sessioninfo_1.2.2            mime_0.12                   
[41] paws_0.6.0                   tidyselect_1.2.1            
[43] digest_0.6.35                paws.storage_0.6.0          
[45] stringi_1.8.4                dplyr_1.0.9                 
[47] purrr_1.0.2                  rprojroot_2.0.4             
[49] fastmap_1.2.0                cli_3.6.2                   
[51] pkgbuild_1.4.4               utf8_1.2.4                  
[53] readr_2.1.5                  withr_3.0.0                 
[55] promises_1.3.0               bit64_4.0.5                 
[57] rmarkdown_2.27               httr_1.4.7                  
[59] bit_4.0.5                    hms_1.1.3                   
[61] evaluate_0.24.0              memoise_2.0.1               
[63] shiny_1.8.1.1                knitr_1.47                  
[65] miniUI_0.1.1.1               profvis_0.3.8               
[67] rlang_1.1.4                  Rcpp_1.0.12                 
[69] xtable_1.8-4                 glue_1.7.0                  
[71] DBI_1.2.3                    xml2_1.3.6                  
[73] renv_0.15.4                  pkgload_1.3.4               
[75] rstudioapi_0.16.0            jsonlite_1.8.8              
[77] R6_2.5.1                     fs_1.6.4 
andreassoteriadesmoj commented 2 weeks ago

Don't know if this helps, but note that both @sjdshapiro in #1509 and I use R version 4.4.0. I tried with R version 4.4.1. and didn't get the bug.

andreassoteriadesmoj commented 1 week ago

Further info: upgrading to R 4.4.1 and dbplyr 2.5.0 has solved my problem.