Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

min_rank() triggers fallback to dplyr #204

Open
stefanlinner opened this issue Jul 22, 2024 · 3 comments
Open

min_rank() triggers fallback to dplyr #204

stefanlinner opened this issue Jul 22, 2024 · 3 comments

Comments

@stefanlinner
Copy link
Contributor

stefanlinner commented Jul 22, 2024

Hi,

I noticed that duckplyr::min_rank() and duckplyr::desc() trigger a fallback to dplyr and would like to understand the reason. Are these functions not yet fully supported by duckplyr? The message tells me that the functions don't exist, but they are part of the duckplyr package.

Notably, duckplyr::arrange(var) works fine (without fallback) while duckplyr::arrange(duckplyr::desc(var)) triggers a fallback.

Any explanation/help is greatly appreciated. Keep up the great work!

options(duckdb.materialize_message = TRUE)

library(duckplyr)
#> The duckplyr package is configured to fall back to dplyr when it encounters an
#> incompatibility. Fallback events can be collected and uploaded for analysis to
#> guide future development. By default, no data will be collected or uploaded.
#> → Run `duckplyr::fallback_sitrep()` to review the current settings.
#> ✔ Overwriting dplyr methods with duckplyr methods.
#> ℹ Turn off with `duckplyr::methods_restore()`.
#> 
#> Attache Paket: 'duckplyr'
#> Die folgenden Objekte sind maskiert von 'package:stats':
#> 
#>     filter, lag
#> Die folgenden Objekte sind maskiert von 'package:base':
#> 
#>     intersect, setdiff, setequal, union

row.names(mtcars) <- NULL

mtcars_rank <- 
  mtcars |> 
  duckplyr::as_duckplyr_df() |> 
  duckplyr::mutate(Rank = duckplyr::min_rank(mpg))
#> The duckplyr package is configured to fall back to dplyr when it encounters an
#> incompatibility. Fallback events can be collected and uploaded for analysis to
#> guide future development. By default, no data will be collected or uploaded.
#> ℹ A fallback situation just occurred. The following information would have been
#>   recorded:
#>   {"version":"0.4.1","message":"{\"exception_type\":\"Catalog\",\"exception_message\":\"Scalar
#>   Function with name min_rank does not exist!\\nDid you mean
#>   \\\"isnan\\\"?\",\"type\":\"Scalar
#>   Function\",\"name\":\"min_rank\",\"candidates\":\"isnan\",\"error_subtype\":\"MISSING_ENTRY\"}","name":"mutate","x":{"...1":"numeric","...2":"numeric","...3":"numeric","...4":"numeric","...5":"numeric","...6":"numeric","...7":"numeric","...8":"numeric","...9":"numeric","...10":"numeric","...11":"numeric"},"args":{"dots":{"...12":"...13::...14(...1)"},".by":"NULL",".keep":["all","used","unused","none"]}}
#> → Run `duckplyr::fallback_sitrep()` to review the current settings.
#> → Run `Sys.setenv(DUCKPLYR_FALLBACK_COLLECT = 1)` to enable fallback logging,
#>   and `Sys.setenv(DUCKPLYR_FALLBACK_VERBOSE = TRUE)` in addition to enable
#>   printing of fallback situations to the console.
#> → Run `duckplyr::fallback_review()` to review the available reports, and
#>   `duckplyr::fallback_upload()` to upload them.
#> ℹ See `?duckplyr::fallback()` for details.
#> ℹ This message will be displayed once every eight hours.
#> Error processing with relational.
#> Caused by error:
#> ! {"exception_type":"Catalog","exception_message":"Scalar Function with name min_rank does not exist!\nDid you mean \"isnan\"?","type":"Scalar Function","name":"min_rank","candidates":"isnan","error_subtype":"MISSING_ENTRY"}

mtcars_sorted_desc <- 
  mtcars |> 
  duckplyr::as_duckplyr_df() |> 
  duckplyr::arrange(duckplyr::desc(mpg))
#> Error processing with relational.
#> Caused by error:
#> ! {"exception_type":"Catalog","exception_message":"Scalar Function with name desc does not exist!\nDid you mean \"decade\"?","type":"Scalar Function","name":"desc","candidates":"decade","error_subtype":"MISSING_ENTRY"}

mtcars_sorted <- 
  mtcars |> 
  duckplyr::as_duckplyr_df() |> 
  duckplyr::arrange(mpg)

Created on 2024-07-22 with reprex v2.1.1

Session info
sessionInfo()
#> R version 4.2.3 (2023-03-15 ucrt)
#> Platform: x86_64-w64-mingw32/x64 (64-bit)
#> Running under: Windows 10 x64 (build 22631)
#> 
#> Matrix products: default
#> 
#> locale:
#> [1] LC_COLLATE=German_Germany.utf8  LC_CTYPE=German_Germany.utf8   
#> [3] LC_MONETARY=German_Germany.utf8 LC_NUMERIC=C                   
#> [5] LC_TIME=German_Germany.utf8    
#> 
#> attached base packages:
#> [1] stats     graphics  grDevices utils     datasets  methods   base     
#> 
#> other attached packages:
#> [1] duckplyr_0.4.1.9001
#> 
#> loaded via a namespace (and not attached):
#>  [1] rstudioapi_0.16.0 knitr_1.48        magrittr_2.0.3    tidyselect_1.2.1 
#>  [5] R6_2.5.1          rlang_1.1.4       fastmap_1.2.0     fansi_1.0.6      
#>  [9] dplyr_1.1.4       tools_4.2.3       xfun_0.45         utf8_1.2.4       
#> [13] DBI_1.2.3         cli_3.6.3         withr_3.0.0       htmltools_0.5.8.1
#> [17] yaml_2.3.9        digest_0.6.36     tibble_3.2.1      lifecycle_1.0.4  
#> [21] duckdb_1.0.0      vctrs_0.6.5       fs_1.6.4          glue_1.7.0       
#> [25] evaluate_0.24.0   rmarkdown_2.27    reprex_2.1.1      compiler_4.2.3   
#> [29] pillar_1.9.0      generics_0.1.3    collections_0.3.7 jsonlite_1.8.8   
#> [33] pkgconfig_2.0.3
@krlmlr
Copy link
Member

krlmlr commented Aug 17, 2024

Thanks, good catch! A fix is in the works.

@krlmlr
Copy link
Member

krlmlr commented Aug 20, 2024

#246 handles the duckplyr:: case. More work is needed for min_rank(), need to wrap up the work I have locally.

@hadley hadley added this to the 1.0.0 milestone Sep 25, 2024
@krlmlr
Copy link
Member

krlmlr commented Jan 31, 2025

dplyr::desc() is handled in #550, min_rank() needs more work -- started in #333, but needs to be redone.

@krlmlr krlmlr removed this from the 1.0.0 milestone Jan 31, 2025
@krlmlr krlmlr changed the title min_rank() and desc() trigger fallback to dplyr min_rank() triggers fallback to dplyr Feb 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants