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

Stamatis Zampetakis commented on HIVE-25653:
--------------------------------------------

To avoid confusion, I think it is better to stick to the SQL terminology. I am 
not sure to which data types you refer when you write "Floating point data 
types" in the summary. In SQL, we distinguish between approximate (float, 
double, real, etc) and exact numerics (decimal, int, long, bigint). When 
operations involve approximate numerics then the result will be approximate as 
well. On the other hand when we do calculations using exact numerics the result 
is usually (not always as this case demonstrates) exact. 

Now the example in the description uses exact numerics so indeed it is a bit 
confusing to have an approximate result but I think this functions are not made 
to be precise/exact. 

> Incorrect results returned by STDDEV, STDDEV_SAMP, STDDEV_POP for floating 
> point data types.
> --------------------------------------------------------------------------------------------
>
>                 Key: HIVE-25653
>                 URL: https://issues.apache.org/jira/browse/HIVE-25653
>             Project: Hive
>          Issue Type: Improvement
>          Components: UDF
>    Affects Versions: 3.1.0, 3.1.2
>            Reporter: Ashish Sharma
>            Assignee: Ashish Sharma
>            Priority: Major
>              Labels: pull-request-available
>             Fix For: 4.0.0
>
>          Time Spent: 1.5h
>  Remaining Estimate: 0h
>
> Description
> *Script*- 
> create table test ( col1 decimal );
> insert into values 
> ('10230.72'),('10230.72'),('10230.72'),('10230.72'),('10230.72'),('10230.72'),('10230.72');
> select STDDEV_SAMP(col1) AS STDDEV_6M , STDDEV(col1) as STDDEV 
> ,STDDEV_POP(col1) as STDDEV_POP from test;
> *Result*- 
> STDDDEV_SAMP                            STDDEV                      
> STDDEV_POP 
> 5.940794514955821E-13     5.42317860890711E-13         5.42317860890711E-13
> *Expected*- 
> STDDDEV_SAMP                            STDDEV                      
> STDDEV_POP 
> 0                                                           0                 
>                0



--
This message was sent by Atlassian Jira
(v8.20.1#820001)

Reply via email to