Description
Component(s)
exporter/clickhouse
Is your feature request related to a problem? Please describe.
Currently the %s_trace_id_ts table description is as follow:
CREATE TABLE IF NOT EXISTS "%s"."%s_trace_id_ts" %s (
TraceId String CODEC(ZSTD(1)),
Start DateTime CODEC(Delta, ZSTD(1)),
End DateTime CODEC(Delta, ZSTD(1)),
INDEX idx_trace_id TraceId TYPE bloom_filter(0.01) GRANULARITY 1
) ENGINE = %s
PARTITION BY toDate(Start)
ORDER BY (TraceId, Start)
%s
SETTINGS index_granularity=8192, ttl_only_drop_parts = 1
And the materialized view definition is
CREATE MATERIALIZED VIEW IF NOT EXISTS "%s"."%s_trace_id_ts_mv" %s
TO "%s"."%s_trace_id_ts"
AS SELECT
TraceId,
min(Timestamp) as Start,
max(Timestamp) as End
FROM "%s"."%s"
WHERE TraceId != ''
GROUP BY TraceId
While in traces_table the definition of Timestamp is Timestamp DateTime64(9) CODEC(Delta, ZSTD(1))
The Start and End fields in the target table are defined as DateTime, which results in a loss of nanosecond precision when aggregating Timestamp values from the source table. This truncation causes a loss of accuracy, especially for short-duration traces, where nanosecond-level granularity is significant.
Describe the solution you'd like
Suggested Fix
To preserve the original precision, the Start and End fields in the %s_trace_id_ts table should be defined as DateTime64(9) instead of DateTime, matching the data type of the source Timestamp column.
Describe alternatives you've considered
No response
Additional context
No response