Skip to content

Commit 1643c1e

Browse files
pitrouemkornfield
authored andcommitted
ARROW-5419: [C++] Allow recognizing empty strings as null strings in CSV files
Author: Antoine Pitrou <[email protected]> Closes #4396 from pitrou/ARROW-5419-csv-empty-null-strings and squashes the following commits: cb086d1 <Antoine Pitrou> ARROW-5419: Allow recognizing empty strings as null strings in CSV files
1 parent 49714fb commit 1643c1e

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

cpp/src/arrow/csv/converter-test.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ TEST(BinaryConversion, Nulls) {
130130
options.strings_can_be_null = true;
131131
AssertConversion<BinaryType, std::string>(binary(), {"ab,N/A\n", "NULL,\n"},
132132
{{"ab", ""}, {"", ""}},
133-
{{true, false}, {false, true}}, options);
133+
{{true, false}, {false, false}}, options);
134134
}
135135

136136
TEST(StringConversion, Basics) {
@@ -152,7 +152,7 @@ TEST(StringConversion, Nulls) {
152152
options.strings_can_be_null = true;
153153
AssertConversion<StringType, std::string>(utf8(), {"ab,N/A\n", "NULL,\n"},
154154
{{"ab", ""}, {"", ""}},
155-
{{true, false}, {false, true}}, options);
155+
{{true, false}, {false, false}}, options);
156156
}
157157

158158
TEST(StringConversion, Errors) {

cpp/src/arrow/csv/converter.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ class VarSizeBinaryConverter : public ConcreteConverter {
144144

145145
if (options_.strings_can_be_null) {
146146
auto visit = [&](const uint8_t* data, uint32_t size, bool quoted) -> Status {
147-
if (size > 0 && IsNull(data, size, false /* quoted */)) {
147+
if (IsNull(data, size, false /* quoted */)) {
148148
builder.UnsafeAppendNull();
149149
return Status::OK();
150150
} else {

0 commit comments

Comments
 (0)