diff --git a/lib/trino-hive-formats/src/main/java/io/trino/hive/formats/line/json/JsonSerializer.java b/lib/trino-hive-formats/src/main/java/io/trino/hive/formats/line/json/JsonSerializer.java index 40debc88f4d0..33ae1f37200b 100644 --- a/lib/trino-hive-formats/src/main/java/io/trino/hive/formats/line/json/JsonSerializer.java +++ b/lib/trino-hive-formats/src/main/java/io/trino/hive/formats/line/json/JsonSerializer.java @@ -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));