Repository navigation
fix: dbCreateTable() gives character columns of zero-row data frames a type that holds any string - #588
Merged
Conversation
…s a type that holds any string Without a non-NA value there is no width to size a character or factor column from, so zero-row and all-NA columns now become `TEXT` instead of `VARCHAR(1)`, the type that values wider than 255 characters already get. This unskips the Arrow DBItest specs that create tables from zero-row prototypes. Closes #585. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Hr1rd5PUWgaCJzotWt9NhJ
1 of 2 tasks
Member
Author
Question:
|
Member
Author
Accepted limitations
Generated by Claude Code |
krlmlr
marked this pull request as ready for review
November 29, 2026 11:46
This was referenced Nov 29, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #585. Stacked on #584.
Before this change,
get_char_type()sized character and factor columns asVARCHAR(max(nchar(x), 1)). A column with no non-NAvalue therefore gotVARCHAR(1), and appending any longer string failed with "Data too long for column". DBI's defaultdbCreateTableArrow()anddbWriteTableArrow()create tables from zero-row prototypes, so every Arrow write with strings hit this.Change
get_char_type()returnsTEXTwhenall(is.na(x)), which covers zero-length and all-NAinput. Values wider than 255 characters already getTEXT. Input that has values gets the same type as before.VARCHAR(n); one without levels getsTEXT.NAcharacter column used to becomeVARCHAR(1)and now becomesTEXT.tests/testthat/test-dbCreateTable.R(new) covers zero-row and all-NAcharacter and factor columns, each followed by appending and reading back a 600-character string.dbCreateTable()with a zero-row data frame makes character columnsVARCHAR(1)#585 are enabled again.Tests
Run locally against MariaDB 10.11 with
NOT_CRAN=true. DBItest had 8870 expectations, with 0 failures. The whole suite has one error, intest-timezone.R("US/Alaska" unknown to CCTZ in this container), which also happens onmain.Session: https://claude.ai/code/session_01Hr1rd5PUWgaCJzotWt9NhJ
Generated by Claude Code