Skip to content

fix(datagen): preserve timestamp time zones - #7946

Open
xixiGoodLuck wants to merge 1 commit into
lance-format:mainfrom
xixiGoodLuck:codex/fix-7912
Open

fix(datagen): preserve timestamp time zones#7946
xixiGoodLuck wants to merge 1 commit into
lance-format:mainfrom
xixiGoodLuck:codex/fix-7912

Conversation

@xixiGoodLuck

Copy link
Copy Markdown

Summary

  • Preserve the requested timezone metadata when lance-datagen generates timestamp arrays.
  • Prevent rand_struct from panicking when a struct contains a timezone-aware timestamp field.

Root Cause

FnGen constructed the output with PrimitiveArray::from(values), which restores the primitive type's default timestamp metadata. For timezone-aware timestamps, that dropped the timezone and made the generated child array type disagree with the struct field type.

Changes

  • Rebuild ArrayData with the generator's declared data type only when the generated type differs.
  • Add regression coverage for both direct timestamp generation and timestamp fields generated through rand_struct.

Testing

  • cargo fmt --all -- --check
  • cargo test -p lance-datagen --lib (12 passed)
  • cargo clippy -p lance-datagen --all-targets -- -D warnings
  • cargo check --workspace --tests --benches

Related Issue

Fixes #7912

@github-actions github-actions Bot added the bug Something isn't working label Jul 23, 2026
@coderabbitai

coderabbitai Bot commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: QUIET

Plan: Pro Plus

Run ID: 5425779e-f85c-4c43-a7ef-00f83070df59

📥 Commits

Reviewing files that changed from the base of the PR and between ddbc23c and d986100.

📒 Files selected for processing (1)
  • rust/lance-datagen/src/generator.rs

📝 Walkthrough

Walkthrough

Changes

Timestamp type preservation

Layer / File(s) Summary
Typed array generation and validation
rust/lance-datagen/src/generator.rs
FnGen::generate rebuilds arrays when constructed metadata differs from the declared type, preserving timestamp timezones. Tests cover direct timestamp generation and timezone-aware timestamps nested in structs.

Estimated code review effort: 2 (Simple) | ~10 minutes

Suggested reviewers: u70b3

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main fix: preserving timestamp time zones in datagen.
Description check ✅ Passed The description is directly related to the code changes and their regression coverage.
Linked Issues check ✅ Passed The change preserves timezone metadata and covers the rand_struct panic scenario from #7912.
Out of Scope Changes check ✅ Passed The changes stay focused on the timezone preservation bug fix and matching regression tests.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

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

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

lance-datagen drops timestamp time zones, causing rand_struct to panic

1 participant