Skip to content

Garbage collector seems to clean up temporary tables created by duckplyr:.as_tbl() #800

@lschneiderbauer

Description

@lschneiderbauer

The garbage collector seems to somehow interfere with the duckplyr::as_tbl() / duckplyr::as_duckdb_tibble() magic. I cannot explain it properly, so it's best to just look at this reprex:

library(dplyr)
#> 
#> Attache Paket: 'dplyr'
#> Die folgenden Objekte sind maskiert von 'package:stats':
#> 
#>     filter, lag
#> Die folgenden Objekte sind maskiert von 'package:base':
#> 
#>     intersect, setdiff, setequal, union
library(duckplyr)
#> ✔ Overwriting dplyr methods with duckplyr methods.
#> ℹ Turn off with `duckplyr::methods_restore()`.

df <-
  as_duckdb_tibble(data.frame(x=1)) |> 
  duckplyr::as_tbl() |> 
  mutate(
    y = 1
  ) |> 
  as_duckdb_tibble()

df
#> # A duckplyr data frame: 2 variables
#>       x     y
#>   <dbl> <dbl>
#> 1     1     1

gc()
#>           used (Mb) gc trigger  (Mb) max used (Mb)
#> Ncells 1107374 59.2    2261542 120.8  1444180 77.2
#> Vcells 2039468 15.6    8388608  64.0  2609380 20.0

df
#> # A duckplyr data frame: 2 variables
#> Error:
#> ! Error evaluating duckdb query: Catalog Error: Table with name as_tbl_duckplyr_TUULZ5jay4 does not exist!
#> Did you mean "duckdb_types"?
#> ℹ Context: GetQueryResult

Created on 2025-10-16 with reprex v2.1.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    duckdb 🦆Issues where work in the duckb package is needed

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions