Skip to content

Error in db_write_table(): #> ! table must be a <table_path>, not a string. #1613

@s-elsheikh

Description

@s-elsheikh

Please briefly describe your problem and what output you expect. If you have a question, please don't use this form. Instead, ask on https://stackoverflow.com/ or https://community.rstudio.com/.

I was working with duckdb to summarize data then wanted to write the summarized table back to duckdb without collect().

include a minimal reproducible example (AKA a reprex). If you've never heard of a reprex before, start by reading https://www.tidyverse.org/help/#reprex. You can use the examples in Reprexes for dbplyr as a starting point for your reprex.

Brief description of the problem

library(tidyverse)
library(dbplyr)
#> 
#> Attaching package: 'dbplyr'
#> The following objects are masked from 'package:dplyr':
#> 
#>     ident, sql
library(duckdb)
#> Loading required package: DBI
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, data will be collected but no data will
#> be uploaded.
#> ℹ Automatic fallback uploading is not controlled and therefore disabled, see
#>   `?duckplyr::fallback()`.
#> ✔ Number of reports ready for upload: 54.
#> → Review with `duckplyr::fallback_review()`, upload with
#>   `duckplyr::fallback_upload()`.
#> ℹ Configure automatic uploading with `duckplyr::fallback_config()`.
#> ✔ Overwriting dplyr methods with duckplyr methods.
#> ℹ Turn off with `duckplyr::methods_restore()`.
#> 
#> Attaching package: 'duckplyr'
#> The following object is masked from 'package:duckdb':
#> 
#>     read_csv_duckdb
library(dd)
library(here)
#> here() starts at /tmp/Rtmpi4i6fY/reprex-aadb7abd3ebe-rude-stud


temp_db <- tempfile(fileext = ".db")
con <-
  dbConnect(duckdb(),
            dbdir = temp_db)


dbWriteTable(con, "db_mtcars", mtcars)

from_db <- tbl(con, "db_mtcars")

test_tbl <- from_db %>%  
  summarise(
    test = mean(drat)
  )
db_write_table(con, "test_tbl", test_tbl)
#> Error in `db_write_table()`:
#> ! `table` must be a <table_path>, not a string.
#> ℹ This is an internal error that was detected in the dbplyr package.
#>   Please report it at <https://github.com/tidyverse/dbplyr/issues> with a
#>   reprex (<https://tidyverse.org/help/>) and the full backtrace.

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