[codex] fix: date type inference and zoneless CSV timestamps - #320
[codex] fix: date type inference and zoneless CSV timestamps#320youhaowei wants to merge 10 commits into
Conversation
The note pointed readers to the "Date and string branches below", but the Date branch sits above it — half the pointer sent readers the wrong way. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01ANXFmfHVyfnqD1tYwVjApd
📝 WalkthroughSummary by CodeRabbit
WalkthroughThe change adds Arrow schema-aware column typing, broader value inference, numeric display formatting, and epoch-millisecond date formatting. Tests cover numeric, date, mixed, invalid, and string values. ChangesData preview formatting
Estimated code review effort: 3 (Moderate) | ~20 minutes Sequence Diagram(s)sequenceDiagram
participant QueryResult
participant useDataFrameData
participant DataPreview
participant formatCellValue
participant formatDate
QueryResult->>useDataFrameData: provide rows and Arrow schema fields
useDataFrameData->>useDataFrameData: extract declared or inferred column types
useDataFrameData->>DataPreview: provide typed columns and values
DataPreview->>formatCellValue: format numeric values
DataPreview->>formatDate: format date-typed epoch values
formatCellValue-->>DataPreview: return formatted numeric text
formatDate-->>DataPreview: return UTC date text
🚥 Pre-merge checks | ✅ 3 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (3 passed)
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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@packages/app/src/hooks/useDataFrameData.ts`:
- Around line 37-57: Update isDateString in
packages/app/src/hooks/useDataFrameData.ts (lines 37-57) to require an explicit
UTC offset before classifying T-separated timestamps as dates, preventing
zone-less timestamps from shifting calendar dates; preserve date-only and
supported existing cases. Add a regression test in
packages/app/src/hooks/useDataFrameData.test.tsx (lines 639-642) for a zone-less
T-separated timestamp under a positive-offset time zone, documenting that
existing date-only and space-separated cases do not exercise this path.
🪄 Autofix
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: ASSERTIVE
Plan: Pro Plus
Run ID: f16658d6-70ea-485a-a205-4cf1ae00de38
📒 Files selected for processing (7)
packages/app/src/app/insights/[insightId]/_components/sections/DataPreviewSection.tsxpackages/app/src/hooks/useDataFrameData.test.tsxpackages/app/src/hooks/useDataFrameData.tspackages/app/src/lib/cell-formatter.test.tspackages/app/src/lib/cell-formatter.tspackages/ui/src/lib/format-virtual-table-value.test.tspackages/ui/src/lib/format-virtual-table-value.ts
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 9b3e4ca911
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Numeric date values currently render as raw epoch timestamps, while zoneless CSV timestamps are interpreted in the browser's local timezone. CSV columns are also typed from only their first non-empty value, so a later incompatible value can be coerced to null or silently normalized. This change formats schema-declared numeric dates as UTC calendar dates and makes CSV ingestion deterministic and lossless. Zoneless ISO timestamps are interpreted as UTC, explicit offsets retain their instant, ambiguous or impossible date-like values remain text, and mixed-type columns fall back to strings before Arrow encoding so every original value is preserved. This is a current-main replacement for the obsolete approach in #320. ## Local verification - `TURBO_CONCURRENCY=2 bun run check` — 85/85 tasks passed - `bun run format:check` - `bunx turbo build --filter='!@wystack/*'` — 22/22 tasks passed - Runtime CSV-to-Arrow exercises under `Pacific/Auckland` - Focused CSV package gate — 22/22 tests passed ## Independent review The adaptive plan used two required low-effort seats: a Terra runtime review and a Sol source review. Both found the same blocker: impossible or incompatible values after a valid first value could still be corrupted. The fix now infers across every non-empty value. A focused runtime scenario recheck and strict source regression review both passed on `0e02be452df4167c2cfb1b9bf3f22f1118a95b9a`. A fractional-seconds concern was dismissed with source evidence and a passing Arrow regression proving `2024-07-18T00:30:00.123` remains a UTC date. ## Exclusions - The analogous first-value inference path in the REST connector is unchanged. - The old #320 client-side schema-inference changes are not reused. - The unrelated local `bun.lock` change is not included.
Fixes date-column type inference and display in data previews and Insight results. Date columns now use Arrow schema metadata when available, and CSV calendar timestamps no longer shift to the next day when imported west of UTC.
Closes #79.
Issue #78 (numeric aggregate display noise) is explicitly deferred. This PR contains no generic numeric-formatting behavior or test changes.
Changes
Tand space-separated CSV date-times to UTC at the CSV adapter boundary before Arrow persistence.Z, and explicit-offset timestamp behavior.Runtime evidence
Final behavioral QA used a fresh CSV import and a real Insight preview at commit
a80d28f8.zoneless_t2024-01-182024-07-18day_only2024-01-182024-07-18space_datetime2024-01-182024-07-18utc_z2024-01-182024-07-18explicit_offset(-07:00)2024-01-182024-07-19The explicit-offset control proves the offset instant is honored rather than stripped. Browser console contained only development informational messages; no page errors were observed.
Screenshot is stored on the existing
pr-320-screenshotsprerelease, not in git.Verification
bun run check: PASS — all four summary checks, 85/85 package tasks.bun run format:check: PASS.git diff --check: PASS.