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 Jun 26, 2024
1 parent 8dd8b53 commit 3712bec
Showing 1 changed file with 5 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -498,14 +498,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 @@ -924,7 +923,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 @@ -1468,9 +1467,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 3712bec

Please sign in to comment.