Repository navigation
Conversation
Signed-off-by: joohwan <piwriw@163.com>
|
cannot you just use UTC as the base so that the timezone issue removes, instead of nanosecond? nanosecond is quite unnecessary. Can you clarify? |
Thanks for raising this. You're right that nanosecond precision is not required to fix the timezone issue. The problem is that Explicitly specifying UTC in the SQL parameter type, or enforcing a UTC session timezone, would also be valid solutions. Using Unix timestamps here avoids relying on either setting. I chose nanoseconds to preserve the precision of the existing |
|
One small thing before we merge: the description mentions regression tests for sub-second precision, the sandbox end-time rounding and query construction, but the PR only adds tests for the timestamp helper. Could you either add those tests or trim the description to match? Either is fine with me. Once that's done I'll get CI running and take it from there. Thanks again for sticking with this one! |
|
Good catch, thanks! @ryan-sana I've updated the PR description to match the actual test coverage. The added tests cover the timestamp helper only; I've removed the claims about query-construction and sandbox end-time rounding tests. |
|
We have not observed any cross-timezone queries unfortunately under our prod. While I acknowledge that this is a good reliability bug fix but I still close this PR and will get back to it once we observe real issues. |
Summary
Follow-up to #3304, which has not been merged. This PR fixes timezone-dependent time filters in ClickHouse metrics queries while preserving the existing sandbox metrics end-time rounding behavior.
Problem
Metrics queries bind time boundaries using
clickhouse.DateNamedwith timezone-unspecifiedDateTime64parameters. The driver serializes these values as date-time strings without an explicit timezone offset.When the timezone used to format a boundary differs from the timezone ClickHouse uses to interpret it, the query window shifts. This can return missing or unexpected metrics.
Converting the Go values to UTC alone does not resolve this ambiguity, since the serialized strings still carry no timezone information.
Changes
Int64Unix timestamps and convert them withfromUnixTimestamp64Nano, avoiding timezone-dependent string parsing.DateTime64(9)columns.int64nanosecond range to prevent overflow.No schema migration or API changes are required.
Validation
go -C packages/clickhouse test -race -count=1 ./...git diff --checkBoth checks pass. The added tests cover the timestamp conversion helper only. This change has not been validated against a live ClickHouse instance with a non-UTC timezone.