Skip to content

dbplyr::sql_render generates error when using CTEs and dplyr::union #1557

@aguynamedryan

Description

@aguynamedryan

I ran into an error when attempting union some tables with the CTE option turned on.

tib <- tibble::tibble(a = c(1))
con <- dbplyr::simulate_dbi()
t <- dbplyr::tbl_lazy(tib, con = con)
tu <- dplyr::union(t, t)
dbplyr::sql_render(tu, sql_options = dbplyr::sql_options(cte = TRUE))
#> Error in qry$unions$table[[i]]: subscript out of bounds

Created on 2024-11-19 with reprex v2.1.1

I doubt it is relevant to the issue, but I'm using a combination of simulated DBI backends and lazy tables run through dplyr verbs to build up SQL queries. I then use dbplyr::sql_render to produce SQL statements. I was experimenting with using CTEs and when I set cte = TRUE, I got this error.

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