Skip to content

Missing columns cause errors with union_all in postgres #183

@karldw

Description

@karldw

When I try to use union_all to append two remote postgres tables with mismatched column names, I get an error. The error message is "Cannot pass NA to dbQuoteIdentifier()".

I expected the missing column to be filled in with NAs, as happens with SQLite. Or, if that's not possible, it might be helpful to have a clearer error message.

library(dplyr)
con <- DBI::dbConnect(RPostgres::Postgres())
DBI::dbWriteTable(con, "iris", iris, temporary=TRUE)
iris_db <- tbl(con, "iris")
union_all(select(iris_db, -Species), iris_db)
# Error: Cannot pass NA to dbQuoteIdentifier()

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugan unexpected problem or unintended behaviordplyr verbs 🤖Translation of dplyr verbs to SQL

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions