-
Notifications
You must be signed in to change notification settings - Fork 3k
Hive3/Hadoop3 upgrade for iceberg-mr and iceberg-flink - [Draft] #1455
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -52,3 +52,5 @@ derby.log | |
|
|
||
| # Python stuff | ||
| python/.mypy_cache/ | ||
|
|
||
| hive2-metastore/src | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -127,7 +127,7 @@ private static Object leafToLiteral(PredicateLeaf leaf) { | |
| case FLOAT: | ||
| return leaf.getLiteral(); | ||
| case DATE: | ||
| return daysFromTimestamp((Timestamp) leaf.getLiteral()); | ||
| return daysFromDate((Date) leaf.getLiteral()); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we should check the type returned by
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good point, I'll make that change. |
||
| case TIMESTAMP: | ||
| return microsFromTimestamp((Timestamp) LITERAL_FIELD.get(leaf)); | ||
| case DECIMAL: | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -19,9 +19,9 @@ | |
|
|
||
| package org.apache.iceberg.mr.hive.serde.objectinspector; | ||
|
|
||
| import java.sql.Date; | ||
| import java.time.LocalDate; | ||
| import org.apache.hadoop.hive.serde2.io.DateWritable; | ||
| import org.apache.hadoop.hive.common.type.Date; | ||
| import org.apache.hadoop.hive.serde2.io.DateWritableV2; | ||
| import org.apache.hadoop.hive.serde2.objectinspector.primitive.AbstractPrimitiveJavaObjectInspector; | ||
| import org.apache.hadoop.hive.serde2.objectinspector.primitive.DateObjectInspector; | ||
| import org.apache.hadoop.hive.serde2.typeinfo.TypeInfoFactory; | ||
|
|
@@ -42,17 +42,17 @@ private IcebergDateObjectInspector() { | |
|
|
||
| @Override | ||
| public Date getPrimitiveJavaObject(Object o) { | ||
| return o == null ? null : Date.valueOf((LocalDate) o); | ||
| return o == null ? null : Date.valueOf(o.toString()); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Date/time values must be converted directly and not via string. Conversions like this will lead to time zone bugs.
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good point! I will fix the conversion logic to avoid using toString. As for timezones, the expected LocalDate/LocalDateTime objects in these inspectors contain no timezone information or any offsets. |
||
| } | ||
|
|
||
| @Override | ||
| public DateWritable getPrimitiveWritableObject(Object o) { | ||
| return o == null ? null : new DateWritable(DateTimeUtil.daysFromDate((LocalDate) o)); | ||
| public DateWritableV2 getPrimitiveWritableObject(Object o) { | ||
| return o == null ? null : new DateWritableV2(DateTimeUtil.daysFromDate((LocalDate) o)); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we control the type returned by the object inspector through a config or by detecting whether
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Unfortunately there was a breaking change in the DateObjectInspector and TimestampObjectInspector interfaces in Hive3. Since we are implementing these interfaces, there has to a be a separate Hive2- and Hive3-compatible version of these implementations. I will open a new PR where the Hive2 and Hive3-specific parts of MR are separated into distinct modules. |
||
| } | ||
|
|
||
| @Override | ||
| public Object copyObject(Object o) { | ||
| return o == null ? null : new Date(((Date) o).getTime()); | ||
| return o == null ? null : Date.valueOf(o.toString()); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Are you sure that
To me, it seems like the stack trace's value to developers has decreased here, but perhaps I'm not understanding the semantics of Additionally, I think we tend to prefer to use
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good catch!
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good point! As @pvary mentioned, with hive3, date and timestamp storage has changed and requires using types from the hive.common package instead of java.sql. I will fix the conversion logic to avoid calling toString. |
||
| } | ||
|
|
||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Small nit: why the change from single quotes?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, it was unintentional. Thanks for the catch