belugabehr commented on pull request #1938:
URL: https://github.com/apache/hive/pull/1938#issuecomment-777937297


   @pgaref I pushed another commit that simplifies the builder code and adds 
some more detailed comments.  In generating the comments, I learned something 
interesting.
   
   ```java
   private static final DateTimeFormatter PARSE_FORMATTER = new 
DateTimeFormatterBuilder()
         // Date
         .appendValue(YEAR, 1, 10, 
SignStyle.NORMAL).appendLiteral('-').appendValue(MONTH_OF_YEAR, 1, 2, 
SignStyle.NORMAL) ...
   
   private static final DateTimeFormatter PRINT_FORMATTER = new 
DateTimeFormatterBuilder()
         // Date and Time Parts
         .append(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")) ...
   ```
   
   When the PARSING code is built, it uses YEAR.  However the FORMATTER code is 
using "yyyy".  The equivalence is:
   
   `ChornoField.YEAR` = "uuuu"
   `ChronoField.YEAR_OF_ERA` = "yyyy"
   
   So, what I ran into in my work on skipping the timestamp parsing is that I 
stumbled on the fact that Hive is reading YEAR but displaying YEAR_OF_ERA, 
which are not the same things.  YEAR has negative dates, YEAR_OF_ERA does not 
usually have negative dates, for example a "negative date" in YEAR_OF_ERA would 
be +2000 BCE whereas YEAR would be -2000.  So, Hive is kinda whacky and out of 
sync currently for negative years.


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

Reply via email to