MaxGekk opened a new pull request #29409:
URL: https://github.com/apache/spark/pull/29409


   ### What changes were proposed in this pull request?
   Fix `DaysWritable` by overriding parent's method `def get(doesTimeMatter: 
Boolean): Date` from `DateWritable` instead of `Date get()` because the former 
one uses the first one. The bug occurs because `HiveOutputWriter.write()` call 
`def get(doesTimeMatter: Boolean): Date` transitively with default 
implementation from the parent class  `DateWritable` which doesn't respect date 
rebases and uses not initialized `daysSinceEpoch` (0 which `1970-01-01`).
   
   ### Why are the changes needed?
   The changes fix the bug:
   ```sql
   spark-sql> CREATE TABLE table1 (d date);
   spark-sql> INSERT INTO table1 VALUES (date '2020-08-11');
   spark-sql> SELECT * FROM table1;
   1970-01-01
   ```
   The expected result of the last SQL statement must be **2020-08-11** but got 
**1970-01-01**.
   
   ### Does this PR introduce _any_ user-facing change?
   Yes. After the fix, `INSERT` work correctly:
   ```sql
   spark-sql> SELECT * FROM table1;
   2020-08-11
   ```
   
   ### How was this patch tested?
   Add new test to `HiveSerDeReadWriteSuite`


----------------------------------------------------------------
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:
us...@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org

Reply via email to