You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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
The text was updated successfully, but these errors were encountered:
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
Expected behavior
PostgreSQL
(Note: PostgreSQL's decimal can express NaN and Infinity)
Additional context
No response
The text was updated successfully, but these errors were encountered: