Altinity / clickhouse-grafana

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

how to configure chart when using groupArray #484

Closed yangjianzhou closed 5 months ago

yangjianzhou commented 1 year ago

my sql is :

SELECT
    time,
    groupArray((placement, value)) AS groupArr
FROM
(
    SELECT
        time,
        intDiv(toUInt32(time), 60)  AS t,
        placement,
        sum(value)/1000000 AS value
    FROM tbl.test_table FINAL
    WHERE source = 'REVENUE'
    GROUP BY time, placement
    ORDER BY time, placement
)
GROUP BY time
ORDER BY time

my datasource is clickhouse then the panel shows Data is missing a number field , how to solve this ?

Slach commented 5 months ago

sorry for late respone

your SQL should be rewrite as

SELECT
    t,
    groupArray((placement, value)) AS groupArr
FROM
(
    SELECT
        intDiv(toUInt32(time), 60)  AS t,
        placement,
        sum(value)/1000000 AS value
    FROM tbl.test_table FINAL
    WHERE source = 'REVENUE'
    GROUP BY t, placement
    ORDER BY t, placement
)
GROUP BY t
ORDER BY t

Thereafter, it will display as multiple time series, each separate time series for each distinct placement value