diff --git a/datafusion/expr-common/src/type_coercion/binary.rs b/datafusion/expr-common/src/type_coercion/binary.rs index 83f47883add93..4c6c47a6516d0 100644 --- a/datafusion/expr-common/src/type_coercion/binary.rs +++ b/datafusion/expr-common/src/type_coercion/binary.rs @@ -928,9 +928,6 @@ fn coerce_numeric_type_to_decimal(numeric_type: &DataType) -> Option { Int16 | UInt16 => Some(Decimal128(5, 0)), Int32 | UInt32 => Some(Decimal128(10, 0)), Int64 | UInt64 => Some(Decimal128(20, 0)), - // TODO if we convert the floating-point data to the decimal type, it maybe overflow. - Float32 => Some(Decimal128(14, 7)), - Float64 => Some(Decimal128(30, 15)), _ => None, } } @@ -946,9 +943,6 @@ fn coerce_numeric_type_to_decimal256(numeric_type: &DataType) -> Option Some(Decimal256(5, 0)), Int32 | UInt32 => Some(Decimal256(10, 0)), Int64 | UInt64 => Some(Decimal256(20, 0)), - // TODO if we convert the floating-point data to the decimal type, it maybe overflow. - Float32 => Some(Decimal256(14, 7)), - Float64 => Some(Decimal256(30, 15)), _ => None, } } diff --git a/datafusion/sqllogictest/test_files/math.slt b/datafusion/sqllogictest/test_files/math.slt index 37b5a378fc027..a3db496dd9fda 100644 --- a/datafusion/sqllogictest/test_files/math.slt +++ b/datafusion/sqllogictest/test_files/math.slt @@ -694,3 +694,9 @@ select FACTORIAL(350943270); statement ok drop table signed_integers + +# Should not fail. The operands should coerce to float +query B +SELECT '1'::decimal(10,0) = '1e40'::double; +---- +false diff --git a/datafusion/sqllogictest/test_files/union.slt b/datafusion/sqllogictest/test_files/union.slt index 352c01ca295c9..479f152b39b72 100644 --- a/datafusion/sqllogictest/test_files/union.slt +++ b/datafusion/sqllogictest/test_files/union.slt @@ -836,3 +836,18 @@ physical_plan # Clean up after the test statement ok drop table aggregate_test_100; + +query T +SELECT DISTINCT arrow_typeof(a) FROM (SELECT '1'::float UNION ALL SELECT '1'::decimal(10)) t(a) +---- +Float32 + +query T +SELECT DISTINCT arrow_typeof(a) FROM (SELECT '1'::decimal(10) UNION ALL SELECT '1'::float ) t(a) +---- +Float32 + +query T +SELECT DISTINCT arrow_typeof(a) FROM (SELECT '1'::decimal(10) UNION ALL SELECT '1'::double) t(a) +---- +Float64