[
https://issues.apache.org/jira/browse/HIVE-18291?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16296963#comment-16296963
]
Marco Gaido commented on HIVE-18291:
------------------------------------
Thanks for your analysis [~kgyrtkirk], I can add to your comparisons that:
- Oracle is like Postgres
- SQLServer, from which Hive draws his inspiration for the implementation of
Decimal operations, behaves like Hive in case of truncation needed (even though
in addition and subtractions it seems that Hive looses an extra digit compared
to SQLServer, but this is a minor issue at the moment IMHO), but it throws an
exception instead of returning {{NULL}}, ie. SQLServer respects the standard,
but Hive doesn't.
I agree on adding a configuration option to switch to previous Hive behavior,
but I'd set it by default to behave like SQL standard suggests.
> An exception should be raised if the result is outside the range of decimal
> ---------------------------------------------------------------------------
>
> Key: HIVE-18291
> URL: https://issues.apache.org/jira/browse/HIVE-18291
> Project: Hive
> Issue Type: Sub-task
> Components: SQL
> Affects Versions: 2.3.0
> Reporter: Marco Gaido
> Assignee: Daniel Voros
>
> Citing SQL:2011 on page 27 available at
> http://standards.iso.org/ittf/PubliclyAvailableStandards/c053681_ISO_IEC_9075-1_2011.zip:
> {noformat}
> If the result cannot be represented exactly in the result type, then whether
> it is rounded
> or truncated is implementation-defined. An exception condition is raised if
> the result is
> outside the range of numeric values of the result type, or if the arithmetic
> operation
> is not defined for the operands.
> {noformat}
> Currently Hive is returning NULL instead of throwing an exception if the
> result is out of range, eg.:
> {code}
> > select 1000000000000000000.000001*1000000000000000000.000001;
> +-------+
> | _c0 |
> +-------+
> | NULL |
> +-------+
> {code}
--
This message was sent by Atlassian JIRA
(v6.4.14#64029)