You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
After completing #1558, I discovered there were some other issues with CTEs, namely, dbplyr quoted tables names inconsistently and incorrectly.
I created this test case to generate the two different issues I encountered.
test_that("CTE quoting works right", {
lf1<- lazy_frame(x=1, y=2, .name="lf1")
lf2<- lazy_frame(x=1, z=2, .name="lf2")
# The query is nonsensical, because I took a failing query from the wild and# whiddled it down to the minimum amount of code required to reveal two# separate quoting issues when using CTEsdouble_it<-function(.data, column_name) {
.data %>%
mutate(
"{ column_name }":=.data[[column_name]] *2
)
}
skinny<-function(column_name) {
lf1 %>%
double_it(column_name) %>%
mutate(
column_name=column_name,
.keep="none"
)
}
tall_tbl<-purrr::map(c("x", "y"), skinny) %>%
purrr::reduce(dplyr::union_all)
query<-tall_tbl %>%
left_join(tall_tbl, by= join_by(column_name)) %>%
left_join(tall_tbl, by= join_by(column_name)) %>%
sql_render(sql_options= sql_options(cte=TRUE)) %>%
expect_snapshot()
})
The output produced for this snapshot is the following:
After completing #1558, I discovered there were some other issues with CTEs, namely, dbplyr quoted tables names inconsistently and incorrectly.
I created this test case to generate the two different issues I encountered.
The output produced for this snapshot is the following:
Here are the two issues I noticed:
q06
, you'll see the FROM clause has incorrectly triple-quoted theq03
identifierq09
, you'll see the FROM clause has incorrectly applied single quotes around theq06
identifierEither of these issues render the SQL statement invalid and unable to run on a database.
The text was updated successfully, but these errors were encountered: