Details
-
Improvement
-
Status: Resolved
-
Major
-
Resolution: Fixed
-
4.0.0
Description
The ANSI standard says UDAF should return NULL when all inputs are NULL.
Hive is very generous and accepts non-numeric texts as input for SUM. To give some consistency to the generous specification, we believe `SUM(string_col)` should behave in the same way as `SUM(CAST(string_col AS DOUBLE))`.
However, Hive's SUM returns 0.0 in that case.
> SELECT SUM(CAST(null AS STRING)), SUM('invalid num'), SUM(CAST('invalid num' AS DOUBLE)); +-------+------+-------+ | _c0 | _c1 | _c2 | +-------+------+-------+ | NULL | 0.0 | NULL | +-------+------+-------+
We see some more discussions in https://github.com/apache/hive/pull/5091.
Attachments
Issue Links
- relates to
-
HIVE-28082 HiveAggregateReduceFunctionsRule could generate an inconsistent result
- Resolved
- links to