-
Notifications
You must be signed in to change notification settings - Fork 181
Malfunctioning SQL generation with dbplyr 2.3.0 #1101
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
Comments
Very similarly, library(dplyr, warn.conflicts = FALSE)
library(dbplyr, warn.conflicts = FALSE)
table1 <- tbl_lazy(tibble(key1 = 1), dbplyr::simulate_hana())
table2 <- tbl_lazy(tibble(key2 = 2, parent2 = 3), dbplyr::simulate_hana())
table3 <- tbl_lazy(tibble(key3 = 3, parent3 = 4), dbplyr::simulate_hana())
table4 <- tbl_lazy(tibble(key4 = 4, parent4 = 5), dbplyr::simulate_hana())
table1 %>%
inner_join(table2, by = c("key1" = "parent2")) %>%
inner_join(table3, by = c("key2" = "parent3")) %>%
inner_join(table4, by = c("key3" = "parent4"))
#> <SQL>
#> SELECT `key1`, `key2`, `key3`, `key4`
#> FROM `df` AS `df...1`
#> INNER JOIN `df` AS `df...2`
#> ON (`df...1`.`key1` = `df...2`.`parent2`)
#> INNER JOIN `df` AS `df...3`
#> ON (`df...2`.`key2` = `df...3`.`parent3`)
#> INNER JOIN `df` AS `df...4`
#> ON (`df...3`.`key3` = `df...4`.`parent4`) Created on 2023-01-18 with reprex v2.0.2 While this does not work: (changing column name "key4" to "key3" library(dplyr, warn.conflicts = FALSE)
library(dbplyr, warn.conflicts = FALSE)
table1 <- tbl_lazy(tibble(key1 = 1), dbplyr::simulate_hana())
table2 <- tbl_lazy(tibble(key2 = 2, parent2 = 3), dbplyr::simulate_hana())
table3 <- tbl_lazy(tibble(key3 = 3, parent3 = 4), dbplyr::simulate_hana())
table4 <- tbl_lazy(tibble(key3 = 4, parent4 = 5), dbplyr::simulate_hana())
table1 %>%
inner_join(table2, by = c("key1" = "parent2")) %>%
inner_join(table3, by = c("key2" = "parent3")) %>%
inner_join(table4, by = c("key3" = "parent4"))
#> <SQL>
#> SELECT `key1`, `key2`, `df...3`.`key3` AS `key3.x`, `df...3`.`key3` AS `key3.y`
#> FROM `df` AS `df...1`
#> INNER JOIN `df` AS `df...2`
#> ON (`df...1`.`key1` = `df...2`.`parent2`)
#> INNER JOIN `df` AS `df...3`
#> ON (`df...2`.`key2` = `df...3`.`parent3`)
#> INNER JOIN `df` AS `df...4`
#> ON (`df...3`.`key3` = `df...4`.`parent4`) Created on 2023-01-18 with reprex v2.0.2 |
I think I found the issue and will fix this soon. |
Wow, this is not that easy to trigger 😄 You need:
Could you install the dev version |
You are fast! :) |
After such big changes to the SQL generation I expected some blocker bugs to show up... So I also try to fix them fast 😄 |
Good day,
with dbplyr 2.3.0 I managed to construct a statement which does not correctly translate to SQL.
Consider the following example:
Created on 2023-01-18 with reprex v2.0.2
Notice the fourth line after SELECT:
df...3.key AS table4.key
. I would expect it to readdf...4.key AS table4.key
(4 instead of 3), i.e.Somehow the same column is selected twice with different names.
But I really want "table4.key" from "table4" to be selected.
Unfortunately this behavior seems to break some of my queries which were working before.
The text was updated successfully, but these errors were encountered: