Altinity / clickhouse-grafana

Altinity Grafana datasource plugin for ClickHouse®
MIT License
713 stars 120 forks source link

No longer possible to specify custom timestamp column value in 3.0.0 #529

Closed fnewberg closed 5 months ago

fnewberg commented 5 months ago

It used to be possible to specify a custom value rather than a column in the table as the timestamp value, but this seems to no longer be possible in 3.0.0. Previously I could specify that the timestamp should be computed from an hour column, but this no longer gets saved when I try to specify it.

image

This then in turn breaks the $timeFilter and $timeSeries macros

SELECT $timeSeries as t, count() FROM $table WHERE $timeFilter GROUP BY t ORDER BY t

becomes

SELECT
    (intDiv(toUInt32(undefined), 10) * 10) * 1000 as t,
    count()
FROM session.session_version

WHERE
    date >= toDate(1711124831)
    AND date <= toDate(1711146431)
    AND undefined >= toDateTime(1711124831)
    AND undefined <= toDateTime(1711146431)
GROUP BY t

ORDER BY t

not presence of undefined in 3 places

Slach commented 5 months ago

as quick workaround could you try

SELECT $timeSeries(toDateTime(hour*3600)) as t, count() FROM $table WHERE $timeFilter(toDateTime(hour*3600)) GROUP BY t ORDER BY t

but not sure will it work or not