Skip to content
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

[HUDI-7955] Account for WritableTimestampObjectInspector#getPrimitive… #11576

Conversation

voonhous
Copy link
Member

@voonhous voonhous commented Jul 5, 2024

…JavaObject discrepancies in Hive3 and Hive2

The invocation of getPrimitiveJavaObject returns a different implementation of timestamp in Hive3 and Hive2. 

  • Hive2: java.sql.Timestamp
  • Hive3: org.apache.hadoop.hive.common.type.Timestamp

Hudi common is compiled with Hive2, but Trino is using Hive3, causing the discrepancy between compile and runtime. When execution flow falls into this section of the code where the trigger conditions are listed below:

  1. MOR table is used
  2. User is querying the _rt table
  3. User's table has a TIMESTAMP type and query requires it
  4. Merge is required as record is present in both Parquet and Log file

Error below will be thrown:

Query 20240704_075218_05052_yfmfc failed: 'java.sql.Timestamp org.apache.hadoop.hive.serde2.objectinspector.primitive.WritableTimestampObjectInspector.getPrimitiveJavaObject(java.lang.Object)'
java.lang.NoSuchMethodError: 'java.sql.Timestamp org.apache.hadoop.hive.serde2.objectinspector.primitive.WritableTimestampObjectInspector.getPrimitiveJavaObject(java.lang.Object)'
        at org.apache.hudi.hadoop.utils.HiveAvroSerializer.serializePrimitive(HiveAvroSerializer.java:304)
        at org.apache.hudi.hadoop.utils.HiveAvroSerializer.serialize(HiveAvroSerializer.java:212)
        at org.apache.hudi.hadoop.utils.HiveAvroSerializer.setUpRecordFieldFromWritable(HiveAvroSerializer.java:121)
        at org.apache.hudi.hadoop.utils.HiveAvroSerializer.serialize(HiveAvroSerializer.java:108)
        at org.apache.hudi.hadoop.realtime.RealtimeCompactedRecordReader.convertArrayWritableToHoodieRecord(RealtimeCompactedRecordReader.java:185)
        at org.apache.hudi.hadoop.realtime.RealtimeCompactedRecordReader.mergeRecord(RealtimeCompactedRecordReader.java:172)
        at org.apache.hudi.hadoop.realtime.RealtimeCompactedRecordReader.next(RealtimeCompactedRecordReader.java:114)
        at org.apache.hudi.hadoop.realtime.RealtimeCompactedRecordReader.next(RealtimeCompactedRecordReader.java:49)
        at org.apache.hudi.hadoop.realtime.HoodieRealtimeRecordReader.next(HoodieRealtimeRecordReader.java:88)
        at org.apache.hudi.hadoop.realtime.HoodieRealtimeRecordReader.next(HoodieRealtimeRecordReader.java:36)
        at io.trino.plugin.hive.GenericHiveRecordCursor.advanceNextPosition(GenericHiveRecordCursor.java:215)
        at io.trino.spi.connector.RecordPageSource.getNextPage(RecordPageSource.java:88)
        at io.trino.plugin.hudi.HudiPageSource.getNextPage(HudiPageSource.java:120)

For more details on screenshots + SQL to reproduce, please refer to the JIRA ticket HUDI-7955.

Hive3

image

Hive2

image

Change Logs

Added Hive shim for WritableTimestampObjectInspector#getPrimitiveJavaObject.

Impact

None

Risk level (write none, low medium or high below)

None

Documentation Update

Describe any necessary documentation update if there is any new feature, config, or user-facing change. If not, put "none".

  • The config description must be updated if new configs are added or the default value of the configs are changed
  • Any new feature or user-facing change requires updating the Hudi website. Please create a Jira ticket, attach the
    ticket number here and follow the instruction to make
    changes to the website.

Contributor's checklist

  • Read through contributor's guide
  • Change Logs and Impact were stated clearly
  • Adequate tests were added if applicable
  • CI passed

@github-actions github-actions bot added the size:S PR with lines of changes in (10, 100] label Jul 5, 2024
@@ -42,6 +42,11 @@ public Writable getTimestampWriteable(long value, boolean timestampMillis) {
return new TimestampWritable(timestamp);
}

@Override
public Object getPrimitiveJavaObject(Object o) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we can name it unwrapTimestampAsPrimitive

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Copy link
Contributor

@danny0405 danny0405 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1, nice catch~

@hudi-bot
Copy link

hudi-bot commented Jul 8, 2024

CI report:

Bot commands @hudi-bot supports the following commands:
  • @hudi-bot run azure re-run the last Azure build

@danny0405 danny0405 merged commit b0e0efc into apache:master Jul 8, 2024
49 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
schema-and-data-types size:S PR with lines of changes in (10, 100]
Projects
Status: ✅ Done
Development

Successfully merging this pull request may close these issues.

None yet

3 participants