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

Error when using copy_dm_to() on a table containing a string field with more than 255 characters #2066

Closed
tsilber21 opened this issue Oct 27, 2023 · 5 comments · Fixed by #2082
Labels
bug Something isn't working
Milestone

Comments

@tsilber21
Copy link

I was running into errors when trying to use copy_dm_to() on a dm containing a table with a string field that could exceed 255 characters. Note that I am copying the dm to an MSSQL database.

The error was a SQL error reading: String or binary data would be truncated.

After some digging, I believe the issue stems from the line in build_copy_queries(), which reads: tbl <- tbl_impl(ptype_dm, x)

It seems that it's trying to use the table with 0 rows to inform the column definitions, but this will assume VARCHAR(255) for any strings, even if that column contains a value of greater than 255 characters.

When I updated the line on my end to instead point at dm instead of ptype_dm to read tbl <- collect(tbl_impl(dm, x)) this seemed to fix the issue.

@krlmlr
Copy link
Collaborator

krlmlr commented Oct 29, 2023

Thanks. Is this new in dm 1.0.7? Does dm 1.0.6 work?

Alternatively, can you try #2022?

CC @TSchiefer.

@krlmlr
Copy link
Collaborator

krlmlr commented Oct 29, 2023

You could also try #2082. I might send that to CRAN before #2022.

@tsilber21
Copy link
Author

Should've mentioned earlier that my dm is remote, is_src_db() returns TRUE. I'm copying from one remote source to another.

1.0.6 still has this issue, but if I rollback to version 1.0.5 then the copy is fine.

Neither #2022 nor #2082 solves the issue for this dm (same truncation error).

@krlmlr
Copy link
Collaborator

krlmlr commented Oct 30, 2023

Oh, I see. I'll work on a fix in #2022 and #2082.

@krlmlr krlmlr added this to the copy milestone Oct 30, 2023
Copy link
Contributor

github-actions bot commented Nov 1, 2024

This old thread has been automatically locked. If you think you have found something related to this, please open a new issue and link to this old issue if necessary.

@github-actions github-actions bot locked and limited conversation to collaborators Nov 1, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
2 participants