Bug: ISO timestamps are normalized in chart WHERE filters but not WITH FILL bounds
维护者通常 1 天内回复
还没有人认领这个 Issue。
评估
- 难度
- 3/5
- 预计耗时
- 1-2 天
- 新手友好度
- 68/100
- Issue 类型
- 缺陷
- 描述清晰度
- 描述清楚
- 活跃度
- 活跃
- 技术栈
- clickhouse, typescript
调研方向
Read packages/core/src/modules/report/src/chart-dates.ts and packages/core/src/modules/chart/src/sql.ts, focusing on normalizeBoundary(), dateRangeWhere(), and intervalBucket(). Trace how custom date boundaries reach the WHERE filters and WITH FILL bounds, then inspect nearby tests for coverage. Done when supported inputs produce consistently normalized bounds and regression coverage checks the generated fill parameters.
由索引模型根据 Issue 内容生成。
描述
Summary
Time-series chart queries handle the same custom date range differently in two parts of the generated SQL. The WHERE filters normalize ISO timestamps to ClickHouse date strings, while WITH FILL passes the original ISO strings to toDateTime().
For an input such as 2025-01-15T00:00:00.000Z, this leaves a fractional ISO timestamp in a toDateTime(String) expression and can cause ClickHouse to reject the chart query with Code 6 (CANNOT_PARSE_TEXT).
All dates and identifiers below are synthetic. No application data is required for the SQL example.
Version checked
- Repository:
Openpanel-dev/openpanel - Branch:
main - Commit:
a5a6eb7d62c9579620ec5e3fbfd4ce760f3d8073 - Verification: source inspection and execution of the current date-normalization and SQL-fragment helpers in memory. A full application/database test was not run for this commit.
Steps to reproduce
- Use a valid chart request for a project in a local development environment.
- Set these custom range fields, keeping the remaining request fields valid:
{
"range": "custom",
"interval": "minute",
"startDate": "2025-01-15T00:00:00.000Z",
"endDate": "2025-01-15T01:00:00.000Z"
}
- Inspect the generated SQL and bound parameters, then execute the query against ClickHouse.
The relevant generated expressions are equivalent to:
-- WHERE: normalized
created_at >= toDateTime('2025-01-15 00:00:00')
-- WITH FILL: original ISO strings
WITH FILL
FROM toStartOfMinute(toDateTime('2025-01-15T00:00:00.000Z'))
TO toStartOfMinute(toDateTime('2025-01-15T01:00:00.000Z'))
STEP toIntervalMinute(1)
In the current implementation these values are bound as String parameters; parameter binding does not normalize their date format.
Minimal SQL example
This isolates the generated fill expression without accessing application tables:
SELECT
toStartOfMinute(toDateTime('2025-01-15 00:00:00')) AS date,
count() AS count
FROM numbers(1)
GROUP BY date
ORDER BY date WITH FILL
FROM toStartOfMinute(toDateTime('2025-01-15T00:00:00.000Z'))
TO toStartOfMinute(toDateTime('2025-01-15T01:00:00.000Z'))
STEP toIntervalMinute(1);
Replacing only the fill bounds with 2025-01-15 00:00:00 and 2025-01-15 01:00:00 provides a comparison with consistent formatting. The example is provided for database reproduction; the verification performed on the commit above was limited to helper execution and generated parameters.
Expected behavior
A supported custom date range should be normalized consistently for filtering and gap filling, and the chart query should succeed. Unsupported date formats should be rejected before issuing a database query.
Actual behavior
The generated WHERE parameter is 2025-01-15 00:00:00, but the generated fill parameter remains 2025-01-15T00:00:00.000Z. The latter can produce a ClickHouse date-parsing error instead of a chart result.
Local helper execution confirmed the same unnormalized String bounds for minute, hour, day, week, and month. This confirms SQL generation across those intervals, not five end-to-end database tests.
Relevant source
- Custom date normalization:
normalizeBoundary()expands date-only inputs but returns full timestamp strings unchanged. - WHERE date normalization:
dateRangeWhere()appliesformatClickhouseDate(). - Fill bounds:
intervalBucket()passes the original bounds throughsql.string()intotoDateTime(). - Fill construction:
chartSeriesQuery()forwardsstartDateandendDateto the bucket's fill function.
Suggested fix and regression coverage
Normalize custom date boundaries consistently before building both WHERE and WITH FILL, preserving the intended timezone and range semantics. Alternatively, use a consistent typed date-binding/parsing approach for both clauses.
Add regression coverage for ISO timestamps with milliseconds and Z, explicit timezone offsets, date-only inputs, and existing ClickHouse-style date strings. Include a database-backed test for the generated WITH FILL query, in addition to SQL-parameter assertions.
- 主要语言
- TypeScript
- 星标
- 7.3k
- 派生
- 539
- 平均合并
- 1 天 20 小时
- 30 天内合并 PR
- 80
环境准备
- 提供 Dockerfile 或 Docker Compose 文件
- 没有 Pull Request 模板
- 没有贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
Openpanel-dev/openpanel 的其他 Issue
-
难度 2/5 1-3 小时 新手友好度 68/100
Openpanel-dev/openpanel#653 · 1 个 reaction ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 73/100
Openpanel-dev/openpanel#610 · 1 条评论 ·
维护者通常 1 天内回复
-
Bug: Funnel has_profile filter conflicts with the profile_id aggregate alias (ClickHouse Code 184)未关闭
难度 3/5 1-2 天 新手友好度 76/100
Openpanel-dev/openpanel#663 ·
维护者通常 1 天内回复
-
Retention matrix drops cohorts where nobody did the return event可能已有人在做 @officialasishkumar 于 3 天前认领。 未关闭
难度 4/5 3-5 天 新手友好度 35/100
Openpanel-dev/openpanel#656 ·
维护者通常 1 天内回复
-
Conversion breakdowns drop every later day once the series limit is reached可能已有人在做 @officialasishkumar 于 3 天前认领。 未关闭
难度 2/5 1-3 小时 新手友好度 35/100
Openpanel-dev/openpanel#655 ·
维护者通常 1 天内回复
查看 Openpanel-dev/openpanel 的全部 Issue
相似的 Issue
-
Bug: Cloudflare Pages static _redirects identity rule causes RSC Flight to reload as HTML可能已有人在做 @Donvero 今天认领。 未关闭
难度 2/5 1-3 小时 新手友好度 78/100
Mantitup-Org/vista#210 ·
-
难度 2/5 1-3 小时 新手友好度 78/100
simstudioai/sim#9831 ·
维护者通常 1 天内回复
-
status: waiting for maintainer
难度 2/5 1-3 小时 新手友好度 88/100
mui/material-ui#49751 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 88/100
维护者通常 2 天内回复
-
难度 2/5 1-3 小时 新手友好度 76/100
diplodoc-platform/transform#1184 ·
维护者通常 1 天内回复