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:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]