Skip to content

HIVE-30020: Fix TIMESTAMP WITH LOCAL TIME ZONE data loss and read failure on ORC tables - #6761

Open
vikramahuja1001 wants to merge 3 commits into
apache:masterfrom
vikramahuja1001:HIVE-30020-ORCFix
Open

vikramahuja1001 wants to merge 3 commits into
apache:masterfrom
vikramahuja1001:HIVE-30020-ORCFix

Conversation

@vikramahuja1001

@vikramahuja1001 vikramahuja1001 commented Sep 7, 2026

Copy link
Copy Markdown
Contributor

What changes were proposed in this pull request?

Fix TIMESTAMP WITH LOCAL TIME ZONE data loss and read failure on ORC tables

Why are the changes needed?

Check https://issues.apache.org/jira/browse/HIVE-30020 for more details

Does this PR introduce any user-facing change?

No

How was this patch tested?

Added a new test case(.q file)

@vikramahuja1001

Copy link
Copy Markdown
Contributor Author

Can you help in reviewing this PR as per your availability?
cc @ayushtkn , @zabetak , @zhangbutao , @deniskuzZ , @dengzhhu653

vector.time[rowId] = timestampTZ.toEpochMilli();
vector.nanos[rowId] = timestampTZ.getNanos();
break;
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

default case is not handled for primitive category due to that the data is getting written in this case. Handle default case and throw exception so that the error will come while writing the data itself for unsupported/unhandled primitive type.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

done, thanks for pointing it out

.getPrimitiveJavaObject(obj).toSqlTimestamp());
break;
}
case TIMESTAMPLOCALTZ: {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

It looks indentation problem for this block, please check and fix.

@vikramahuja1001 vikramahuja1001 Sep 11, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I am not able to understand why indentation is being flagged here. Indentation level is same as other case statements above and below. Can you take a look once?


insert into timestampltz_orc_format select * from timestampltz_formats;

SELECT * FROM timestampltz_orc_format; No newline at end of file

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Adding ORDER BY clause to the select query is resulting an exception with the patch, please check.

@vikramahuja1001 vikramahuja1001 Sep 11, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yes rightly pointed, ORDER BY clause is giving an exception. To fix that will require a lot of changes, which are separate from the scope of this PR. I have raised a follow up JIRA and will work on that as well, hope that's fine.
JIRA ID: https://issues.apache.org/jira/browse/HIVE-30042

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I am ok with handling this scenario in a separate JIRA mentioned above. But I request you to add proper details with exception in the description section of the JIRA. Thanks.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Sure, will do.

@vikramahuja1001

Copy link
Copy Markdown
Contributor Author

Thanks for reviewing this PR @mdayakar . I have raised a follow up JIRA to fix the order by query clause as well and will raise a PR for that as well.

@mdayakar mdayakar left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM. Pending tests.

@vikramahuja1001

Copy link
Copy Markdown
Contributor Author

@mdayakar , could you please merge this PR as well?

@mdayakar

Copy link
Copy Markdown
Contributor

@mdayakar , could you please merge this PR as well?

@vikramahuja1001 I am not a committer to merge this PR. I request @zabetak , @kasakrisz , @soumyakanti3578 to review and merge this PR.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

One or more issues must be addressed before approval.

Get a fresh assessment by requesting another Copilot review.

Pull request overview

Adds ORC read/write support for TIMESTAMP WITH LOCAL TIME ZONE and a regression query validating round-trip preservation.

Changes:

  • Converts local-time-zone timestamps to ORC timestamp-instant vectors.
  • Restores timestamp-zone writable values during ORC reads.
  • Adds an ORC round-trip query and expected output.
File summaries
File Description
ql/src/test/results/clientpositive/llap/timestampz_with_file_formats.q.out Updated as part of this pull request.
ql/src/test/queries/clientpositive/timestampz_with_file_formats.q Updated as part of this pull request.
ql/src/java/org/apache/hadoop/hive/ql/io/orc/WriterImpl.java Updated as part of this pull request.
ql/src/java/org/apache/hadoop/hive/ql/io/orc/RecordReaderImpl.java Updated as part of this pull request.
ql/src/java/org/apache/hadoop/hive/ql/io/orc/OrcStruct.java Updated as part of this pull request.
Review details

Suppressed comments (2)

ql/src/java/org/apache/hadoop/hive/ql/io/orc/OrcStruct.java:605

  • This mapping fixes row materialization, but ORC schema inference still unconditionally rejects TIMESTAMP WITH LOCAL TIME ZONE in OrcSerde.convertPrimitiveType (ql/src/java/org/apache/hadoop/hive/ql/io/orc/OrcSerde.java:167-169). As a result, CREATE TABLE ... LIKE FILE ORC ... continues to fail for files containing this type, so the ORC read support remains incomplete unless that path is updated or the scope is narrowed.
      case TIMESTAMP_INSTANT:
        return PrimitiveObjectInspectorFactory.writableTimestampTZObjectInspector;

ql/src/java/org/apache/hadoop/hive/ql/io/orc/WriterImpl.java:224

  • This changes observable query behavior: ORC TIMESTAMP WITH LOCAL TIME ZONE values that previously failed or lost data can now round-trip. The PR template defines any user-facing behavioral change as “Yes”, so please update the description’s user-facing-change answer and describe the compatibility impact.
              vector.time[rowId] = timestampTZ.toEpochMilli();
              vector.nanos[rowId] = timestampTZ.getNanos();
              break;
  • Files reviewed: 5/5 changed files
  • Comments generated: 1
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread ql/src/java/org/apache/hadoop/hive/ql/io/orc/RecordReaderImpl.java Outdated
@vikramahuja1001

Copy link
Copy Markdown
Contributor Author

Requesting @zabetak , @kasakrisz , @soumyakanti3578, @ayushtkn , @deniskuzZ , @dengzhhu653, @saihemanth-cloudera
to kindly review this PR. Thanks in advance.

@vikramahuja1001

Copy link
Copy Markdown
Contributor Author

Handled all the review comments. Requesting PR review @ayushtkn, @saihemanth-cloudera

@saihemanth-cloudera

Copy link
Copy Markdown
Contributor

CI is not green yet. @vikramahuja1001 can you try and get it green? then we can merge this. Thanks.

@sonarqubecloud

Copy link
Copy Markdown

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants