Skip to content

fix(hive-sync): set HMS table createTime in seconds instead of milliseconds - #19335

Merged
wombatu-kun merged 2 commits into
apache:masterfrom
wombatu-kun:hive-sync-createtime-seconds
Jul 22, 2026
Merged

fix(hive-sync): set HMS table createTime in seconds instead of milliseconds#19335
wombatu-kun merged 2 commits into
apache:masterfrom
wombatu-kun:hive-sync-createtime-seconds

Conversation

@wombatu-kun

Copy link
Copy Markdown
Contributor

Describe the issue this Pull Request addresses

When syncing a table in HMS mode, HMSDDLExecutor.createTable sets the Hive createTime with newTb.setCreateTime((int) System.currentTimeMillis()). Hive stores createTime as seconds since the epoch in an i32 field, but this passes raw milliseconds: the value is 1000x too large and, being ~1.7e12, overflows the int cast into a garbage (often negative or far-past) value. The rest of the codebase already does this correctly, for example HoodieHiveCatalog uses (int) (System.currentTimeMillis() / 1000).

Summary and Changelog

Divides the millisecond timestamp by 1000 before the int cast so the Hive metastore records the table's creation time as epoch seconds, matching Hive's contract and the existing HoodieHiveCatalog usage.

  • HMSDDLExecutor.createTable now calls setCreateTime((int) (System.currentTimeMillis() / 1000)).
  • Adds unit test TestHMSDDLExecutorCreateTable that captures the Table passed to createTable (with a mocked IMetaStoreClient) and asserts createTime is epoch seconds within the call window; this assertion fails against the previous milliseconds value.

Impact

Tables created via HMS-mode Hive sync now record a correct createTime (visible in DESCRIBE FORMATTED and used by tools that read table age). No public API or configuration change.

Risk Level

low

One-line change plus a unit test; the behavior is verified against the corrected value and matches the existing HoodieHiveCatalog convention.

Documentation Update

none

Contributor's checklist

  • Read through contributor's guide
  • Enough context is provided in the sections above
  • Adequate tests were added if applicable

…econds

Hive stores Table.createTime as seconds since the epoch in an i32 field, but HMSDDLExecutor.createTable passed raw System.currentTimeMillis(): the value is 1000x too large and, being ~1.7e12, overflows the int cast into a garbage (often negative or far-past) value. Divide by 1000 before the cast, matching the existing HoodieHiveCatalog usage.

Adds unit test TestHMSDDLExecutorCreateTable that captures the Table passed to createTable (mocked IMetaStoreClient) and asserts createTime is epoch seconds within the call window.
@github-actions github-actions Bot added the size:S PR with lines of changes in (10, 100] label Jul 21, 2026

@hudi-agent hudi-agent 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.

⚠️ 🤖 This review was generated by an AI agent and may contain mistakes. Please verify any suggestions before applying.

Thanks for the contribution! This PR fixes the HMS-mode Hive sync path so the table createTime is recorded in epoch seconds rather than raw milliseconds, matching Hive's i32 contract and the existing HoodieHiveCatalog convention. No correctness issues found. A few style/readability suggestions in the inline comments. Please take a look, and this should be ready for a Hudi committer or PMC member to take it from here. One minor comment on the test — the explanation of the bug overflow behaviour is already covered by the production code comment and could be trimmed.

cc @yihua

verify(client).createTable(captor.capture());
int createTime = captor.getValue().getCreateTime();

// createTime must be epoch seconds within the call window. Passing raw milliseconds instead

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.

🤖 nit: the second sentence here ('Passing raw milliseconds instead would overflow...') duplicates the comment already added in HMSDDLExecutor.java -- could you trim it to just the first sentence describing what the assertion window represents?

⚠️ AI-generated; verify before applying. React 👍/👎 to flag quality.

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 64750b2

@wombatu-kun

Copy link
Copy Markdown
Contributor Author

@voonhous could you please review this easy fix

@wombatu-kun

Copy link
Copy Markdown
Contributor Author

Danny thank you for review!

@hudi-bot

Copy link
Copy Markdown
Collaborator

CI report:

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

@wombatu-kun
wombatu-kun merged commit 58dd532 into apache:master Jul 22, 2026
74 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:S PR with lines of changes in (10, 100]

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants