Skip to content

Conversation

@MaxGekk
Copy link
Member

@MaxGekk MaxGekk commented Aug 23, 2020

What changes were proposed in this pull request?

Override def get: Date in DaysWritable use the daysToMillis(int d) from the parent class DateWritable instead of long daysToMillis(int d, boolean doesTimeMatter).

Why are the changes needed?

It fixes failures of HiveSerDeReadWriteSuite with the profile hive-1.2. In that case, the parent class DateWritable has different implementation before the commit to Hive apache/hive@da3ed68. In particular, get() calls new Date(daysToMillis(daysSinceEpoch)) instead of overrided def get(doesTimeMatter: Boolean): Date in the child class. The get() method returns wrong result 1970-01-01 because it uses not updated daysSinceEpoch.

Does this PR introduce any user-facing change?

Yes.

How was this patch tested?

By running the test suite HiveSerDeReadWriteSuite:

$ build/sbt -Phive-1.2 -Phadoop-2.7 "test:testOnly org.apache.spark.sql.hive.execution.HiveSerDeReadWriteSuite"

and

$ build/sbt -Phive-2.3 -Phadoop-2.7 "test:testOnly org.apache.spark.sql.hive.execution.HiveSerDeReadWriteSuite"

@viirya
Copy link
Member

viirya commented Aug 23, 2020

Thanks @MaxGekk

@viirya
Copy link
Member

viirya commented Aug 23, 2020

@MaxGekk This fix is also for branch-3.0, right?

@MaxGekk
Copy link
Member Author

MaxGekk commented Aug 23, 2020

This fix is also for branch-3.0, right?

@viirya Yes.

@SparkQA
Copy link

SparkQA commented Aug 23, 2020

Test build #127811 has finished for PR 29523 at commit 0edd70f.

  • This patch fails Spark unit tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

@viirya
Copy link
Member

viirya commented Aug 23, 2020

Github Actions was passed. org.apache.spark.sql.hive.orc.HiveOrcHadoopFsRelationSuite is another known failure with hive-1.2 profile.

@viirya
Copy link
Member

viirya commented Aug 23, 2020

Thanks @MaxGekk. Merging this to master and branch-3.0.

@viirya viirya closed this in 1c798f9 Aug 23, 2020
viirya pushed a commit that referenced this pull request Aug 23, 2020
…get()` and use Julian days in `DaysWritable`

### What changes were proposed in this pull request?
Override `def get: Date` in `DaysWritable` use the `daysToMillis(int d)` from the parent class `DateWritable` instead of `long daysToMillis(int d, boolean doesTimeMatter)`.

### Why are the changes needed?
It fixes failures of `HiveSerDeReadWriteSuite` with the profile `hive-1.2`. In that case, the parent class `DateWritable` has different implementation before the commit to Hive apache/hive@da3ed68. In particular, `get()` calls `new Date(daysToMillis(daysSinceEpoch))` instead of overrided `def get(doesTimeMatter: Boolean): Date` in the child class. The `get()` method returns wrong result `1970-01-01` because it uses not updated `daysSinceEpoch`.

### Does this PR introduce _any_ user-facing change?
Yes.

### How was this patch tested?
By running the test suite `HiveSerDeReadWriteSuite`:
```
$ build/sbt -Phive-1.2 -Phadoop-2.7 "test:testOnly org.apache.spark.sql.hive.execution.HiveSerDeReadWriteSuite"
```
and
```
$ build/sbt -Phive-2.3 -Phadoop-2.7 "test:testOnly org.apache.spark.sql.hive.execution.HiveSerDeReadWriteSuite"
```

Closes #29523 from MaxGekk/insert-date-into-hive-table-1.2.

Authored-by: Max Gekk <[email protected]>
Signed-off-by: Liang-Chi Hsieh <[email protected]>
(cherry picked from commit 1c798f9)
Signed-off-by: Liang-Chi Hsieh <[email protected]>
@viirya
Copy link
Member

viirya commented Aug 23, 2020

Verified locally this fixed the test in branch-3.0 too.

@maropu
Copy link
Member

maropu commented Aug 23, 2020

late LGTM. Thanks for the fix, @MaxGekk !

@dongjoon-hyun
Copy link
Member

Thank you, @MaxGekk and all!

@MaxGekk MaxGekk deleted the insert-date-into-hive-table-1.2 branch December 11, 2020 20:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants