cube-js / cube-js/cube

ClickHouse pre-aggregation WHERE clause loses millisecond precision

Open
#10,326 2 comments 1 reaction 0 assignees View on GitHub
driver:clickhouse help wanted
Dominant language
Rust
Stars
20.8k
Forks
2.1k
Avg merge
1d 2h
Merged PRs (30d)
181

Description

**Describe the bug**
When building ClickHouse pre-aggregations with build_range_end that includes milliseconds (e.g., '2026-01-20T23:59:59.999Z'), the generated WHERE clause uses parseDateTimeBestEffort(), which truncates to seconds. This causes the WHERE filter to exclude the intended millisecond boundary.

This is critical for any pre-aggregation with time boundaries that need millisecond precision with explicitly set build_range_end to the end of period.

**To Reproduce**
Build the pre-aggregation for ClickHouse based Cube
Observe the generated WHERE clause uses parseDateTimeBestEffort() instead of parseDateTime64BestEffort()

**Expected behavior**
The WHERE clause should use parseDateTime64BestEffort() (or equivalent) to preserve millisecond precision.

**Version:**
1.6.4 (relevant for previous too)

**Additional context**
In [packages/cubejs-schema-compiler/src/adapter/ClickHouseQuery.ts](https://github.com/cube-js/cube/blob/v1.6.4/packages/cubejs-schema-compiler/src/adapter/ClickHouseQuery.ts), the dateTimeCast() method returns parseDateTimeBestEffort() when called without a timezone parameter.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.