hive-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "ASF GitHub Bot (Jira)" <j...@apache.org>
Subject [jira] [Work logged] (HIVE-23371) StatsUtils.getConstValue may log misleading exception
Date Thu, 07 May 2020 15:19:00 GMT

     [ https://issues.apache.org/jira/browse/HIVE-23371?focusedWorklogId=431786&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-431786
]

ASF GitHub Bot logged work on HIVE-23371:
-----------------------------------------

                Author: ASF GitHub Bot
            Created on: 07/May/20 15:18
            Start Date: 07/May/20 15:18
    Worklog Time Spent: 10m 
      Work Description: jcamachor commented on a change in pull request #1006:
URL: https://github.com/apache/hive/pull/1006#discussion_r421586996



##########
File path: ql/src/java/org/apache/hadoop/hive/ql/stats/StatsUtils.java
##########
@@ -1637,28 +1639,28 @@ private static ColStatistics buildColStatForConstant(HiveConf conf,
long numRows
   }
 
   private static Optional<Number> getConstValue(ExprNodeConstantDesc encd) {
-    if (encd.getValue() != null) {
-      String constant = encd.getValue().toString();
-      PrimitiveCategory category = GenericUDAFSum.getReturnType(encd.getTypeInfo());
-      try {
-        switch (category) {
-        case INT:
-        case BYTE:
-        case SHORT:
-        case LONG:
-          return Optional.of(Long.parseLong(constant));
-        case FLOAT:
-        case DOUBLE:
-        case DECIMAL:
-          return Optional.of(Double.parseDouble(constant));
-        default:
-        }
-      } catch (Exception e) {
-        LOG.debug("Interpreting constant (" + constant + ")  resulted in exception", e);
-      }
+    if (encd.getValue() == null) {
+      return Optional.empty();
+    }
+    String constant = encd.getValue().toString();
+    PrimitiveCategory category = GenericUDAFSum.getReturnType(encd.getTypeInfo());
+    if (category == null) {
+      return Optional.empty();
+    }
+    switch (category) {
+    case INT:
+    case BYTE:
+    case SHORT:
+    case LONG:
+      return Optional.ofNullable(Longs.tryParse(constant));
+    case FLOAT:
+    case DOUBLE:
+    case DECIMAL:
+      return Optional.ofNullable(Doubles.tryParse(constant));
+    default:
+      return Optional.empty();
+    }
     }

Review comment:
       nit. Indentation seems off for this line?




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

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Issue Time Tracking
-------------------

    Worklog Id:     (was: 431786)
    Time Spent: 20m  (was: 10m)

> StatsUtils.getConstValue may log misleading exception
> -----------------------------------------------------
>
>                 Key: HIVE-23371
>                 URL: https://issues.apache.org/jira/browse/HIVE-23371
>             Project: Hive
>          Issue Type: Bug
>            Reporter: Zoltan Haindrich
>            Assignee: Zoltan Haindrich
>            Priority: Major
>              Labels: pull-request-available
>         Attachments: HIVE-23371.01.patch, HIVE-23371.02.patch, HIVE-23371.03.patch
>
>          Time Spent: 20m
>  Remaining Estimate: 0h
>
> it logs exceptions like:
> {code}
> 2020-05-05T01:51:59,609 DEBUG [cba65ded-3bb5-4295-9b3f-cdf844a8faec main] stats.StatsUtils:
Interpreting constant (2008-04-08)  resulted in exception
> java.lang.NumberFormatException: For input string: "2008-04-08"
>         at sun.misc.FloatingDecimal.readJavaFormatString(FloatingDecimal.java:2043) ~[?:1.8.0_252]
>         at sun.misc.FloatingDecimal.parseDouble(FloatingDecimal.java:110) ~[?:1.8.0_252]
>         at java.lang.Double.parseDouble(Double.java:538) ~[?:1.8.0_252]
>         at org.apache.hadoop.hive.ql.stats.StatsUtils.getConstValue(StatsUtils.java:1653)
[hive-exec-4.0.0-SNAPSHOT.jar:4.0.0-SNAPSHOT]
>         at org.apache.hadoop.hive.ql.stats.StatsUtils.buildColStatForConstant(StatsUtils.java:1632)
[hive-exec-4.0.0-SNAPSHOT.jar:4.0.0-SNAPSHOT]
>         at org.apache.hadoop.hive.ql.stats.StatsUtils.getColStatisticsFromExpression(StatsUtils.java:1538)
[hive-exec-4.0.0-SNAPSHOT.jar:4.0.0-SNAPSHOT]
> {code}
> however...these exceptions are not that important; might just draw attention away from
important ones



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Mime
View raw message