Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FR: dbWriteTable() should compare input and output column names. #399

Open
mgirlich opened this issue Oct 19, 2022 · 4 comments
Open

FR: dbWriteTable() should compare input and output column names. #399

mgirlich opened this issue Oct 19, 2022 · 4 comments

Comments

@mgirlich
Copy link

I just learned that (some) databases seem to (silently?) change invalid column names (see tidyverse/dbplyr#1016). This causes issues with the new optimisation in dbplyr::copy_to() where column names do not match.
To handle this correctly it would be necessary for copy_to() to revert to the old behaviour and query the column names again.
To avoid this extra roundtrip with the database it would be great if dbWriteTable() would warn (or even error) if the output column names are different from the input column names.
@krlmlr What do you think?

@krlmlr
Copy link
Member

krlmlr commented Nov 2, 2022

Thanks. How would you query the output column names? How much work would we need to do in the respective backends or in DBI?

@mgirlich
Copy link
Author

There is no possibility to directly get back the column names when creating the table, is there?
dbplyr queries them via SELECT * FROM <tbl> WHERE 0 = 1 but of course it would be nice if we could avoid this extra query to the database. Maybe don't query the names if they are very simple (ASCII + lowercase)?

@krlmlr
Copy link
Member

krlmlr commented Nov 19, 2022

I'm not aware of a way to achieve this in one query.

@krlmlr
Copy link
Member

krlmlr commented Apr 1, 2024

What's the current copy_to() behavior?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants