[ 
https://issues.apache.org/jira/browse/HIVE-18291?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16297106#comment-16297106
 ] 

Xuefu Zhang commented on HIVE-18291:
------------------------------------

I think Hive current behavior is well-established, understood, and accepted, 
and I don't see the need to change just because of certain standard, especially 
such a change alters the default behavior. Please note that the standard 
changes too!

Returning NULL in the said case is by design as well. Hive's decimal in fact 
follows more with mySQL, though the implementation borrowed a lot from SQL 
server.

When we test a query on certain DB, we need to note that a DB server may offer 
different mode such as a strict mode in MySQL 
(https://dev.mysql.com/doc/refman/5.7/en/sql-mode.html) that dictates error 
handling. Data errors would throws an exception in strict mode, such as 
divide-by-zero. Otherwise, NULL will be returned.

Since Hive doesn't have a server strict mode, returning NULL for the case here 
is quite reasonable. If one likes to make the behavior configurable, 
introducing different modes in HS2 would be a more appropriate approach.

Thus, I would be -0 on introducing SQL compliance on this, but certainly -1 on 
changing the default behavior.

> 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)

Reply via email to