[ https://issues.apache.org/jira/browse/HIVE-25653?focusedWorklogId=677881&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-677881 ]
ASF GitHub Bot logged work on HIVE-25653: ----------------------------------------- Author: ASF GitHub Bot Created on: 05/Nov/21 20:48 Start Date: 05/Nov/21 20:48 Worklog Time Spent: 10m Work Description: ashish-kumar-sharma commented on a change in pull request #2760: URL: https://github.com/apache/hive/pull/2760#discussion_r743388404 ########## File path: ql/src/test/queries/clientpositive/sdtdev.q ########## @@ -0,0 +1,12 @@ +create table test ( col1 decimal(10,3) ); +insert into test 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 , variance(col1) as variance,var_pop(col1) as var_pop,var_samp(col1) as var_samp from test; + +create table testpoint ( col1 decimal(10,3)); +insert into testpoint values (0.12345678),(0.25362123),(0.62437485),(0.65133746),(0.98765432),(0.12435647),(0.7654321445); +select STDDEV_SAMP(col1) AS STDDEV_6M , STDDEV(col1) as STDDEV ,STDDEV_POP(col1) as STDDEV_POP , variance(col1) as variance,var_pop(col1) as var_pop,var_samp(col1) as var_samp from testpoint; + +create table testint(col1 int); +insert into testint values (85),(86),(100),(76),(81),(93),(84),(99),(71),(69),(93),(85),(81),(87),(89); +select STDDEV_SAMP(col1) AS STDDEV_6M , STDDEV(col1) as STDDEV ,STDDEV_POP(col1) as STDDEV_POP, variance(col1) as variance,var_pop(col1) as var_pop,var_samp(col1) as var_samp from testint; + Review comment: Done ########## File path: ql/src/java/org/apache/hadoop/hive/ql/udf/generic/GenericUDAFStd.java ########## @@ -90,7 +92,9 @@ public GenericUDAFEvaluator getEvaluator(TypeInfo[] parameters) * use it, etc. */ public static double calculateStdResult(double variance, long count) { - return Math.sqrt(variance / count); + BigDecimal bvariance = new BigDecimal(variance); + BigDecimal result = bvariance.divide(new BigDecimal(count)); + return Math.sqrt(result.doubleValue()); Review comment: Done -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: gitbox-unsubscr...@hive.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org Issue Time Tracking ------------------- Worklog Id: (was: 677881) Time Spent: 50m (was: 40m) > Precision problem in STD, STDDDEV_SAMP,STDDEV_POP > ------------------------------------------------- > > Key: HIVE-25653 > URL: https://issues.apache.org/jira/browse/HIVE-25653 > Project: Hive > Issue Type: Improvement > Reporter: Ashish Sharma > Assignee: Ashish Sharma > Priority: Major > Labels: pull-request-available > Time Spent: 50m > Remaining Estimate: 0h > > Description > *Script*- > create table test ( col1 int ); > 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.3.4#803005)