Skip to content

Commit

Permalink
CSV: fix issue in setSchema (#481)
Browse files Browse the repository at this point in the history
  • Loading branch information
pjfanning authored and cowtowncoder committed Jun 26, 2024
1 parent ff5d1d6 commit e51d723
Showing 1 changed file with 5 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -509,14 +509,13 @@ public void setCodec(ObjectCodec c) {
}

@Override
public void setSchema(FormatSchema schema)
public void setSchema(final FormatSchema schema)
{
if (schema instanceof CsvSchema) {
_schema = (CsvSchema) schema;
String str = _schema.getNullValueString();
_nullValue = str;
_nullValue = _schema.getNullValueString();
} else if (schema == null) {
schema = EMPTY_SCHEMA;
_schema = EMPTY_SCHEMA;
} else {
super.setSchema(schema);
}
Expand Down Expand Up @@ -931,7 +930,7 @@ protected void _readHeaderLine() throws IOException {
int newColumnCount = newSchema.size();
if (newColumnCount < 2) { // 1 just because we may get 'empty' header name
String first = (newColumnCount == 0) ? "" : newSchema.columnName(0).trim();
if (first.length() == 0) {
if (first.isEmpty()) {
_reportCsvMappingError("Empty header line: can not bind data");
}
}
Expand Down Expand Up @@ -1475,9 +1474,6 @@ protected boolean _isNullValue(String value) {
if (_cfgEmptyStringAsNull && value.isEmpty()) {
return true;
}
if (_cfgEmptyUnquotedStringAsNull && value.isEmpty() && !_reader.isCurrentTokenQuoted()) {
return true;
}
return false;
return _cfgEmptyUnquotedStringAsNull && value.isEmpty() && !_reader.isCurrentTokenQuoted();
}
}

0 comments on commit e51d723

Please sign in to comment.