fix: parse DateTime to filter by timestamp on search page#2481
fix: parse DateTime to filter by timestamp on search page#2481karl-power wants to merge 4 commits into
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
🦋 Changeset detectedLatest commit: e5df625 The changes in this PR will be included in the next version bump. This PR includes changesets to release 4 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
🟡 Tier 3 — StandardIntroduces new logic, modifies core functionality, or touches areas with non-trivial risk. Why this tier:
Review process: Full human review — logic, architecture, edge cases. Stats
|
Greptile SummaryThis PR fixes a ClickHouse query failure when including or excluding DateTime/DateTime64 column values on the search page. Previously,
Confidence Score: 5/5Safe to merge — the change is narrowly scoped to DateTime column filter generation and its inverse parse step, both covered by new unit tests including adversarial round-trip cases. The fix correctly wraps DateTime values in type-matched ClickHouse expressions across all four date-type variants (DateTime64, DateTime, Date32, Date) including Nullable/LowCardinality wrappers. The symmetric unwrapping regex in No files require special attention. Important Files Changed
Sequence Diagram%%{init: {'theme': 'neutral'}}%%
sequenceDiagram
participant User
participant DBRowTable
participant filterState as useSearchPageFilterState
participant filtersToQuery
participant ClickHouse
participant parseQuery
User->>DBRowTable: Click Exclude on DateTime value
DBRowTable->>filterState: setFilterValue('Timestamp', '2026-06-16T15:35:16Z', 'exclude')
filterState->>filtersToQuery: "filtersToQuery(filters, { dateTimeColumns })"
Note over filtersToQuery: dateTimeValueExpr('DateTime64(9)', ...)
filtersToQuery-->>filterState: Timestamp NOT IN (parseDateTime64BestEffort('2026-06-16T...', 9))
filterState->>ClickHouse: Execute query with wrapped DateTime literal
ClickHouse-->>filterState: Results (no cast error)
Note over filterState,parseQuery: URL round-trip / re-hydration
filterState->>parseQuery: parseQuery(searchQuery)
Note over parseQuery: extractInClauses unwraps wrapper back to plain quoted string
parseQuery-->>filterState: FilterState with bare string values
%%{init: {'theme': 'base', 'themeVariables': {"darkMode": true, "background": "#0d1117", "primaryColor": "#21262d", "primaryTextColor": "#e6edf3", "primaryBorderColor": "#8b949e", "lineColor": "#8b949e", "textColor": "#e6edf3", "edgeLabelBackground": "#161b22", "actorBkg": "#21262d", "actorBorder": "#8b949e", "actorTextColor": "#e6edf3", "actorLineColor": "#8b949e", "signalColor": "#8b949e", "signalTextColor": "#e6edf3", "noteBkgColor": "#373320", "noteBorderColor": "#d4a72c", "noteTextColor": "#f0e6c0", "labelBoxBkgColor": "#21262d", "labelBoxBorderColor": "#8b949e", "labelTextColor": "#e6edf3", "loopTextColor": "#e6edf3", "activationBkgColor": "#30363d", "activationBorderColor": "#8b949e"}}}%%
sequenceDiagram
participant User
participant DBRowTable
participant filterState as useSearchPageFilterState
participant filtersToQuery
participant ClickHouse
participant parseQuery
User->>DBRowTable: Click Exclude on DateTime value
DBRowTable->>filterState: setFilterValue('Timestamp', '2026-06-16T15:35:16Z', 'exclude')
filterState->>filtersToQuery: "filtersToQuery(filters, { dateTimeColumns })"
Note over filtersToQuery: dateTimeValueExpr('DateTime64(9)', ...)
filtersToQuery-->>filterState: Timestamp NOT IN (parseDateTime64BestEffort('2026-06-16T...', 9))
filterState->>ClickHouse: Execute query with wrapped DateTime literal
ClickHouse-->>filterState: Results (no cast error)
Note over filterState,parseQuery: URL round-trip / re-hydration
filterState->>parseQuery: parseQuery(searchQuery)
Note over parseQuery: extractInClauses unwraps wrapper back to plain quoted string
parseQuery-->>filterState: FilterState with bare string values
Reviews (4): Last reviewed commit: "handle DateTime columns" | Re-trigger Greptile |
E2E Test Results✅ All tests passed • 200 passed • 3 skipped • 1348s
Tests ran across 4 shards in parallel. |
0c94f7a to
e5df625
Compare
@pulpdrew It should be working on TimestampTime now too. |
pulpdrew
left a comment
There was a problem hiding this comment.
Current implementation is a good improvement!
However, is there a way to use the types of the columns being returned by the query, rather than the types of the columns on the table? That way aliases and non-column expressions expressions can also be filters. Otherwise maybe we should consider trying not to show the add-to-filters button for cells that we likely can't filter on (could be future work):

Summary
On the search page, including or excluding a value from a DateTime column (e.g.
Timestamp, typeDateTime64(9)) generated SQL that ClickHouse rejects:The filter value was emitted as a bare string literal, but ClickHouse will not implicitly cast an ISO-8601 string to
DateTime64, so the entire query failed and the filter was unusable. This is reachable from the grid cell popover (the "Include"/"Exclude" actions inDBRowTableFieldWithPopover) — both polarities were broken.filtersToQuerynow wraps DateTime column values inparseDateTime64BestEffort('<value>', 9)instead of emitting a plain literal, reusing the exact pattern the codebase already uses for DateTime values inuseRowWhere.tsx. The result for the case above isTimestamp NOT IN (parseDateTime64BestEffort('2026-06-16T15:35:16.731000000Z', 9)), which is valid SQL.Screenshots or video
before.mov
after.mov
How to test on Vercel preview
Preview routes:
/searchSteps:
References