You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I was using the ParseDelimitedRow filter and set the columns config, where some of the columns were double. I end up with parsing problems for valid inputs such as 2.434534534.
Currently, the code to parse both floats and doubles is similar to this
Objects.requireNonNull(value, "value can't be null");
if (valueinstanceofString && isNumber((String) value)) {
returnnewBigDecimal(value.toString()).doubleValue();
}
if (valueinstanceofNumber) {
Numbernumber = (Number) value;
returnnumber.doubleValue();
}
thrownewDataException(String.format("Cannot parse 64-bits double content from \"%s\"", value));
The isNumber method will always return false for numbers with decimal part since it doesn't check for characters like . or ,. This leads to a DataException for these types.
I think we could change the code to something like this
Objects.requireNonNull(value, "value can't be null");
if (valueinstanceofString) {
try {
returnnewBigDecimal(value.toString()).doubleValue();
} catch (NumberFormatExceptione) {
thrownewDataException(String.format("Cannot parse 64-bits double content from \"%s\"", value));
}
}
if (valueinstanceofNumber) {
Numbernumber = (Number) value;
returnnumber.doubleValue();
}
thrownewDataException(String.format("Cannot parse 64-bits double content from \"%s\"", value));
I think we don't need to check if the string number is correct since the BigDecimal is already making those checks. This change is also applicable to the other numeric types.
The text was updated successfully, but these errors were encountered:
I was using the ParseDelimitedRow filter and set the columns config, where some of the columns were double. I end up with parsing problems for valid inputs such as
2.434534534
.Currently, the code to parse both floats and doubles is similar to this
The
isNumber
method will always return false for numbers with decimal part since it doesn't check for characters like.
or,
. This leads to a DataException for these types.I think we could change the code to something like this
I think we don't need to check if the string number is correct since the BigDecimal is already making those checks. This change is also applicable to the other numeric types.
The text was updated successfully, but these errors were encountered: