-
Notifications
You must be signed in to change notification settings - Fork 24
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
Cannot read CSV or Parquet with dplyr::tbl #133
Comments
Thanks. Can you please try |
@krlmlr I did try with absolute paths. It still didn't work. However, I found out that duckdb was expecting single quote around the file paths. If I do
Created on 2024-04-03 with reprex v2.1.0 |
Thanks, good catch! Do we want to add this to the documentation? |
Wouldn't it make more sense to update/add function to handle these file paths? This seems like a package design decision. What I'm understanding is the package handles files in the same directory differently than other directories. If a file in the same directory is provided, However, for other absolute file paths, the user needs to manually add single quotes. |
duckdb 0.10.1 has No quotes should be needed with that function. |
I was just writing to let you know that I didn't know about the |
|
I ended up here as I was going to report a bug but realised my issue is a duplicate of this one (i.e. I should be using library(duckdb)
#> Loading required package: DBI
library(dplyr)
#>
#> Attaching package: 'dplyr'
#> The following objects are masked from 'package:stats':
#>
#> filter, lag
#> The following objects are masked from 'package:base':
#>
#> intersect, setdiff, setequal, union
tf <- tempfile(fileext = ".csv")
readr::write_csv(mtcars, tf)
con <- dbConnect(duckdb())
# filter without duckdb
readr::read_csv(tf) |>
filter(hp > 250)
#> Rows: 32 Columns: 11
#> ── Column specification ────────────────────────────────────────────────────────
#> Delimiter: ","
#> dbl (11): mpg, cyl, disp, hp, drat, wt, qsec, vs, am, gear, carb
#>
#> ℹ Use `spec()` to retrieve the full column specification for this data.
#> ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
#> # A tibble: 2 × 11
#> mpg cyl disp hp drat wt qsec vs am gear carb
#> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
#> 1 15.8 8 351 264 4.22 3.17 14.5 0 1 5 4
#> 2 15 8 301 335 3.54 3.57 14.6 0 1 5 8
# raises an error
tbl(con, tf) |>
filter(hp > 250) |>
collect()
#> Error in `collect()`:
#> ! Failed to collect lazy table.
#> Caused by error:
#> ! rapi_prepare: Failed to prepare query SELECT "/tmp/Rtmp8d9qdv/file7c7e83242c8f2.csv".*
#> FROM "/tmp/Rtmp8d9qdv/file7c7e83242c8f2.csv"
#> WHERE (hp > 250.0)
#> Error: Binder Error: Referenced table "/tmp/Rtmp8d9qdv/file7c7e83242c8f2.csv" not found!
#> Candidate tables: "file7c7e83242c8f2"
# works when we do a no-op mutate before the filter
tbl(con, tf) |>
mutate(hp = hp + 0) |>
filter(hp > 250) |>
collect()
#> # A tibble: 2 × 11
#> mpg cyl disp hp drat wt qsec vs am gear carb
#> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
#> 1 15.8 8 351 264 4.22 3.17 14.5 0 1 5 4
#> 2 15 8 301 335 3.54 3.57 14.6 0 1 5 8 |
See also #38 I would recommend using something like the tbl(con, "read_csv('mtcars.csv')") So, if we understand that this is embedded in SQL, we can immediately imagine that other functions such as |
Thanks. I renamed |
Hello, it seems that the simple operation is not working as shown on the manual: https://duckdb.org/docs/api/r#dbplyr
Here is my reprex for both formats:
Created on 2024-03-29 with reprex v2.1.0
The text was updated successfully, but these errors were encountered: