Skip to content

Commit 27fa85d

Browse files
authored
fix(stdlib/influxdata/wideto): panic with null string key (#5493)
Update the wideTo function to cope with tables with a null tag value. In these cases the tag is skipped when writing to influxdb.
1 parent 6412246 commit 27fa85d

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

stdlib/influxdata/influxdb/wide_to.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,11 @@ func getTablePointsMetadata(tbl flux.Table) (md tablePointsMetadata, err error)
231231
}
232232
isTag[col.Label] = true
233233

234+
// If the tag is NULL then skip over adding its value to the tag set.
235+
if tbl.Key().IsNull(j) {
236+
continue
237+
}
238+
234239
value := tbl.Key().ValueString(j)
235240
if value == "" {
236241
// Skip tag value if it is empty.

stdlib/influxdata/influxdb/wide_to_test.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ func TestWideToTransformation(t *testing.T) {
134134
static.Ints("f1", 1, nil, 3, nil),
135135
static.StringKey("_measurement", "m0"),
136136
static.TableList{
137-
static.StringKeys("t0", "a", "b"),
137+
static.StringKeys("t0", "a", nil, "b"),
138138
},
139139
}
140140
if err := input.Do(func(tbl flux.Table) error {
@@ -147,6 +147,9 @@ func TestWideToTransformation(t *testing.T) {
147147
want := `m0,t0=a f0=1,f1=1i 0
148148
m0,t0=a f0=2 10000000000
149149
m0,t0=a f0=3,f1=3i 20000000000
150+
m0 f0=1,f1=1i 0
151+
m0 f0=2 10000000000
152+
m0 f0=3,f1=3i 20000000000
150153
m0,t0=b f0=1,f1=1i 0
151154
m0,t0=b f0=2 10000000000
152155
m0,t0=b f0=3,f1=3i 20000000000

0 commit comments

Comments
 (0)