Coercion between floating point types and exact numeric types should result in floating point type as the common super type
- Dominant language
- Rust
- Stars
- 9.3k
- Forks
- 2.4k
- Avg merge
- 3d 7h
- Merged PRs (30d)
- 344
Description
### Describe the bug
When coercing decimal with other numeric types, the result is always decimal.
However, when one of operands is floating point, the result should be float.
Floating point's range of possible values cannot be fit into a decimal. Also NaN and Infinity cannot be converted to a decimal.
### To Reproduce
```
> SELECT arrow_typeof(a) FROM (SELECT '1'::float UNION ALL SELECT '1'::decimal(10)) t(a);
+-------------------+
| arrow_typeof(t.a) |
+-------------------+
| Decimal128(17, 7) |
| Decimal128(17, 7) |
+-------------------+
```
```
> SELECT '1'::decimal(10,0) = '1e99'::float;
Arrow error: Cast error: Cannot cast to Decimal128(17, 7). Overflowing on inf
```
### Expected behavior
PostgreSQL
```
postgres=# SELECT pg_typeof(a) FROM (SELECT '1'::float UNION ALL SELECT '1'::decimal(10)) t(a);
pg_typeof
------------------
double precision
double precision
```
```
postgres=# SELECT '1'::decimal(10,0) = '1e99'::float;
?column?
----------
f
```
(Note: PostgreSQL's decimal can express NaN and Infinity)
### Additional context
_No response_
Contributor guide
Assessment
This issue has not been assessed yet.