InfluxDB: Flux: timestamp-column has to be first in dataframes (#35036) (#35053)

(cherry picked from commit 38b030e2a4)

Co-authored-by: Gábor Farkas <gabor.farkas@gmail.com>
This commit is contained in:
Grot (@grafanabot)
2021-06-01 18:09:30 +02:00
committed by GitHub
co-authored by Gábor Farkas
parent d1b02d524c
commit adfb3d4e21
6 changed files with 100 additions and 64 deletions
+6 -7
View File
@@ -167,10 +167,6 @@ func (fb *frameBuilder) Init(metadata *query.FluxTableMetadata) error {
dataColumns := getDataColumns(columns)
fb.hasUsualStartStop = hasUsualStartStop(dataColumns)
// first we store the column-info structures as pointers,
// because we need to modify some items in the list
var columnInfos []*columnInfo
for _, col := range dataColumns {
if col.IsGroup() {
fb.labels = append(fb.labels, col.Name())
@@ -191,8 +187,6 @@ func (fb *frameBuilder) Init(metadata *query.FluxTableMetadata) error {
isTheSingleValue: false,
}
columnInfos = append(columnInfos, info)
if isTimestamp {
timestampCols = append(timestampCols, info)
} else {
@@ -216,7 +210,12 @@ func (fb *frameBuilder) Init(metadata *query.FluxTableMetadata) error {
nonTimestampCols[0].isTheSingleValue = true
}
for _, colInfo := range columnInfos {
// grafana wants the timestamp columns first, so we add them first
for _, colInfo := range timestampCols {
fb.columns = append(fb.columns, *colInfo)
}
// then we add the non-timestamp-columns
for _, colInfo := range nonTimestampCols {
fb.columns = append(fb.columns, *colInfo)
}