Skip to content

Commit

Permalink
Avoid writing NaN and Infinity with json format table
Browse files Browse the repository at this point in the history
  • Loading branch information
sug-ghosh committed Dec 22, 2024
1 parent a401e37 commit 360d7a0
Showing 1 changed file with 10 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,16 @@ else if (REAL.equals(type)) {
return (generator, block, position) -> generator.writeNumber(REAL.getFloat(block, position));
}
else if (DOUBLE.equals(type)) {
return (generator, block, position) -> generator.writeNumber(DOUBLE.getDouble(block, position));
return (generator, block, position) -> {
Double value = DOUBLE.getDouble(block, position);
System.out.println(value);
if (!Double.isNaN(value) && !Double.isInfinite(value)) {
generator.writeNumber(value);
}
else {
throw new TrinoException(StandardErrorCode.INVALID_JSON_LITERAL, "Invalid value to Insert " + value);
}
};
}
else if (DATE.equals(type)) {
return (generator, block, position) -> generator.writeString(HiveFormatUtils.formatHiveDate(block, position));
Expand Down

0 comments on commit 360d7a0

Please sign in to comment.