Skip to content

min_rank() triggers fallback to dplyr #204

@stefanlinner

Description

@stefanlinner

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions