Skip to content

A sequence of union() should not produce subqueries #1269

Closed
@mgirlich

Description

@mgirlich
library(dplyr, warn.conflicts = FALSE)
library(dbplyr, warn.conflicts = FALSE)

lf1 <- lazy_frame(x = 1, y = 1, .name = "lf1")
lf2 <- lazy_frame(y = 1, .name = "lf2")
lf3 <- lazy_frame(z = 1, .name = "lf3")


lf1 %>%
  union(lf2) %>% 
  union(lf3)
#> <SQL>
#> (
#>   SELECT *, NULL AS `z`
#>   FROM (
#>     (
#>       SELECT *
#>       FROM `lf1`
#>     )
#>     UNION
#>     (
#>       SELECT NULL AS `x`, *
#>       FROM `lf2`
#>     )
#>   ) `q01`
#> )
#> UNION
#> (
#>   SELECT NULL AS `x`, NULL AS `y`, *
#>   FROM `lf3`
#> )

Created on 2023-04-28 with reprex v2.0.2

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