You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@orc.apache.org by GitBox <gi...@apache.org> on 2021/08/16 15:56:53 UTC

[GitHub] [orc] belugabehr commented on a change in pull request #743: ORC-834: Do Not Convert to String in DecimalFromTimestampTreeReader

belugabehr commented on a change in pull request #743:
URL: https://github.com/apache/orc/pull/743#discussion_r689661020



##########
File path: java/core/src/java/org/apache/orc/impl/ConvertTreeReaderFactory.java
##########
@@ -962,7 +963,10 @@ public void setConvertVectorElement(int elementNum) throws IOException {
         seconds += 1;
         nanos = 1_000_000_000 - nanos;
       }
-      HiveDecimal value = HiveDecimal.create(String.format("%d.%09d", seconds, nanos));
+      BigDecimal secondsBd = new BigDecimal(seconds);
+      BigDecimal nanosBd = new BigDecimal(nanos).movePointLeft(9);
+      BigDecimal resultBd = (seconds >= 0L) ? secondsBd.add(nanosBd) : secondsBd.subtract(nanosBd);

Review comment:
       If I break this code intentionally (add instead of subtract), there are failures in:
   
   ```
   [ERROR] Failures: 
   [ERROR]   TestProlepticConversions.testSchemaEvolutionTimestamp:375 row 0 ==> expected: <-6212894324588> but was: <-6212894324412>
   [ERROR]   TestProlepticConversions.testSchemaEvolutionTimestamp:375 row 0 ==> expected: <-6212877044588> but was: <-6212877044412>
   [ERROR]   TestProlepticConversions.testSchemaEvolutionTimestamp:375 row 0 ==> expected: <-6212894324588> but was: <-6212894324412>
   [ERROR]   TestProlepticConversions.testSchemaEvolutionTimestamp:375 row 0 ==> expected: <-6212877044588> but was: <-6212877044412>
   ```
   




-- 
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: dev-unsubscribe@orc.apache.org

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