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

dbWriteTable error with empty char column #40

Closed
tomazweiss opened this issue Jul 5, 2019 · 1 comment · Fixed by #55
Closed

dbWriteTable error with empty char column #40

tomazweiss opened this issue Jul 5, 2019 · 1 comment · Fixed by #55
Labels
bug Unwanted / harmful behavior

Comments

@tomazweiss
Copy link

I have a R table with an empty column of type character. When I try to write this table to Exasol with dbWriteTable (to a non-existing table), an invalid CREATE TABLE statement is generated:

[EXASOL][EXASolution driver]syntax error, unexpected '-', expecting UNSIGNED_INTEGER_ [line 1, column 815] 

In addition: Warning message:
In max(nchar(as.character(x)), na.rm = TRUE) :
  no non-missing arguments to max; returning -Inf

In these cases, the function max(nchar(as.character(x)), na.rm = TRUE) returns -Inf and the generated CREATE TABLE statement tries to create a column of type VARCHAR(-Inf).

Workaround:
backup your R table, identify empty char columns, temporary fill them with something, execute dbWriteTable, create and save DDL statement on exasol, drop table on exasol, create new table on exasol with saved DDL and fix varchar lenghts, write backup table to exasol.

@redcatbear redcatbear added the bug Unwanted / harmful behavior label Jan 25, 2021
@tkilias
Copy link
Collaborator

tkilias commented Jan 25, 2021

Hello @tomazweiss,

Thank you for reporting this bug.

I think, the problem happens here. The function dbDataType can't determine the database type for the empty column in the data.frame. I am not sure, if this is fixable, I need to look deeper into this problem.
However, you can use field_types parameter to specify the database types for the columns directly to work around the problem.

#' @param field_types A character vector containing the column data types, in the form

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

Successfully merging a pull request may close this issue.

4 participants