-
Notifications
You must be signed in to change notification settings - Fork 185
Description
I use dbplyr with a database where some column names are invalid.
If a table with invalid column name is copied to the data base, invalid
names are changed to valid ones. Thus when using copy_to, the table in the
database might have column names than are different from the original data frame.
This was no problem in dbplyr 2.1.1, but in dbplyr 2.2.1 the returned tbl object
contains the old (invalid) column names instead of the new correct ones. This leads
to bugs when working with the table.
A closer look into the code showed that the following line led to the problem:
https://github.com/tidyverse/dbplyr/blame/main/R/verb-copy-to.R#L86
Before the line was changes, the column names were read from the table. Now it is
assumed that they are the same as the ones in the data frame. This assumption isn't
true in my case and I think that there are also other data bases where this isn't
necessarily true (random example: https://www.techtalkcorner.com/parquet-files-column-names-with-spaces/).
Can we either
- get back to the old behaviour in
copy_toto read the column names from the table or - add a parameter to switch the behavior (use column names from data frame or read them from table)?