michelin / snowflake-grafana-datasource

Snowflake Grafana datasource plugin enables the visual representation of Snowflake data within Grafana dashboards and manages alerts.
Apache License 2.0
67 stars 33 forks source link

Time series: pivoting of label column generates phantom values #64

Closed rumbin closed 5 months ago

rumbin commented 6 months ago

Severity

This is pretty severe, since the chart is lying.

Description

In a time series chart on a table in long/narrow format (EAV, entity-attribute-value), the pivoting operation on the attribute/label column results in the values of previous data points to be forward-filled if there is no data present for the given attribute/label.

How to reproduce

Minimal example:

select
    ts::timestamp_ntz as ts
    , label
    , val    
from (values
    (1709050594, 'state_1', 1)
    , (1709050794, 'state_2', 2)
    , (1709050994, 'state_3', 3)
    , (1709051000, 'state_3', 3)
) s(ts, label, val)
 order by
    ts

Create a time series chart out of this query. In the following screenshot I am using ${__field.labels.LABEL} as the Display name formatter:

image

Table view:

image

Expected behavior

Only the data points of the query must be present in the table view and in the time series chart. Null values are respected.

WojtekWaga commented 5 months ago

Hey, this seems to be cause by the fillMode working in a strange way. This seems to fix this issue:

                if tsSchema.Type == data.TimeSeriesTypeLong {
-                       fillMode := &data.FillMissing{Mode: mapFillMode(queryConfig.FillMode), Value: queryConfig.FillValue}
-                       frame, err = data.LongToWide(frame, fillMode)
+                       frame, err = data.LongToWide(frame, nil)