diff --git a/lib/trino-record-decoder/src/main/java/io/trino/decoder/avro/AvroColumnDecoder.java b/lib/trino-record-decoder/src/main/java/io/trino/decoder/avro/AvroColumnDecoder.java index 4927dd8d6586..1c33a6acac7f 100644 --- a/lib/trino-record-decoder/src/main/java/io/trino/decoder/avro/AvroColumnDecoder.java +++ b/lib/trino-record-decoder/src/main/java/io/trino/decoder/avro/AvroColumnDecoder.java @@ -178,7 +178,7 @@ public boolean isNull() @Override public double getDouble() { - if (value instanceof Double || value instanceof Float) { + if (value instanceof Double) { return ((Number) value).doubleValue(); } throw new TrinoException(DECODER_CONVERSION_NOT_SUPPORTED, format("cannot decode object of '%s' as '%s' for column '%s'", value.getClass(), columnType, columnName)); diff --git a/lib/trino-record-decoder/src/test/java/io/trino/decoder/avro/TestAvroDecoder.java b/lib/trino-record-decoder/src/test/java/io/trino/decoder/avro/TestAvroDecoder.java index 24ebb8f938b7..c604d3781b44 100644 --- a/lib/trino-record-decoder/src/test/java/io/trino/decoder/avro/TestAvroDecoder.java +++ b/lib/trino-record-decoder/src/test/java/io/trino/decoder/avro/TestAvroDecoder.java @@ -75,6 +75,7 @@ import static io.trino.spi.type.VarcharType.createUnboundedVarcharType; import static io.trino.spi.type.VarcharType.createVarcharType; import static io.trino.type.InternalTypeManager.TESTING_TYPE_MANAGER; +import static java.lang.Float.floatToIntBits; import static java.nio.charset.StandardCharsets.UTF_8; import static org.assertj.core.api.Assertions.assertThatThrownBy; import static org.testng.Assert.assertEquals; @@ -414,22 +415,13 @@ public void testIntDecodedAsTinyInt() checkValue(decodedRow, row, 100); } - @Test - public void testFloatDecodedAsDouble() - { - DecoderTestColumnHandle row = new DecoderTestColumnHandle(0, "row", DOUBLE, "float_field", null, null, false, false, false); - Map decodedRow = buildAndDecodeColumn(row, "float_field", "\"float\"", 10.2f); - - checkValue(decodedRow, row, 10.2); - } - @Test public void testFloatDecodedAsReal() { DecoderTestColumnHandle row = new DecoderTestColumnHandle(0, "row", REAL, "float_field", null, null, false, false, false); Map decodedRow = buildAndDecodeColumn(row, "float_field", "\"float\"", 10.2f); - checkValue(decodedRow, row, 10.2); + checkValue(decodedRow, row, floatToIntBits(10.2f)); } @Test