-
Notifications
You must be signed in to change notification settings - Fork 166
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
Multiple left joins fails in MS Access #1417
Comments
This is a working version of SQL closest to dplyr's syntax. Use ___ instead of ..., and change the opening bracket to the location after FROM. See also SO
|
Minimal reprex: library(dbplyr)
library(dplyr, warn.conflicts = FALSE)
a <- lazy_frame(x = "a", y1 = "1", con = simulate_access())
b <- lazy_frame(x = "a", y2 = "2", con = simulate_access())
c <- lazy_frame(x = "a", y3 = "3", con = simulate_access())
a |>
left_join(b) |>
left_join(c)
#> Joining with `by = join_by(x)`
#> Joining with `by = join_by(x)`
#> <SQL>
#> SELECT `df...1`.*, `y2`, `y3`
#> FROM `df` AS `df...1`
#> LEFT JOIN `df` AS `df...2`
#> ON (`df...1`.`x` = `df...2`.`x`)
#> LEFT JOIN `df` AS `df...3`
#> ON (`df...1`.`x` = `df...3`.`x`) Created on 2023-12-19 with reprex v2.0.2.9000 It sounds like this is an issue with Access not allowing But you don't get the problem if the tables already have different names: library(dbplyr)
library(dplyr, warn.conflicts = FALSE)
a <- lazy_frame(x = "a", y1 = "1", con = simulate_access(), .name = "a")
b <- lazy_frame(x = "a", y2 = "2", con = simulate_access(), .name = "b")
c <- lazy_frame(x = "a", y3 = "3", con = simulate_access(), .name = "c")
a |>
left_join(b, by = "x") |>
left_join(c, by = "x")
#> <SQL>
#> SELECT `a`.*, `y2`, `y3`
#> FROM `a`
#> LEFT JOIN `b`
#> ON (`a`.`x` = `b`.`x`)
#> LEFT JOIN `c`
#> ON (`a`.`x` = `c`.`x`) Created on 2023-12-19 with reprex v2.0.2.9000 Can you give more details about how you ended up with this problem in actual code? It might be possible to work around it by providing specific names somewhere. |
For a realistic example, see the |
@dmenne what dplyr code are you using? |
Ok, one should not use |
Is this still an issue with the dev version, in particular after #1396? I might have seen a similar problem. |
@krlmlr specifically with Acess, or more generally? |
I was thinking about #1396 (comment): options(conflicts.policy = list(warn = FALSE))
library(dplyr)
library(dbplyr)
lf1 <- lazy_frame(x1 = 1)
lf2 <- lazy_frame(x = 1, y2 = 1)
lf3 <- lazy_frame(x = 1, y = 1)
lf1 %>%
left_join(lf2, by = c(x1 = "x")) %>%
left_join(lf3, by = c(x1 = "x", y2 = "y"))
#> Error in `purrr::map()`:
#> ℹ In index: 2.
#> Caused by error in `sql_table_name_prefix()`:
#> ! `table` must be a single string, not a character vector. |
It just rang a bell, I wasn't following this issue too closely. |
dbplyr 2.4.0.9000 Microsoft Access 2019, 64 bit
(Edited 1.12.2023 to make case clearer)
I have seen #1130, but I am using the github version of tidyverse
Works after replacing "FROM df" by FROM 'a' etc.
One more join
Fails after replacing "FROM df"
which looks reasonable . Run it or paste it directly into an Access Query, it errors
The problem is in the periods. This is ok:
This fails
Workaround: Use a collect() between the joins. Ok for smaller data sets.
Cross-test: a manually created join is fine:
Sample test database attached
testdb.zip
--- Another cross-test ---
With sqlite, the following works fine
The text was updated successfully, but these errors were encountered: