Skip to content

Commit

Permalink
fix(stdlib/influxdata/wideto): panic with null string key (#5493)
Browse files Browse the repository at this point in the history
Update the wideTo function to cope with tables with a null tag
value. In these cases the tag is skipped when writing to influxdb.
  • Loading branch information
mhilton authored Jun 13, 2024
1 parent 6412246 commit 27fa85d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
5 changes: 5 additions & 0 deletions stdlib/influxdata/influxdb/wide_to.go
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,11 @@ func getTablePointsMetadata(tbl flux.Table) (md tablePointsMetadata, err error)
}
isTag[col.Label] = true

// If the tag is NULL then skip over adding its value to the tag set.
if tbl.Key().IsNull(j) {
continue
}

value := tbl.Key().ValueString(j)
if value == "" {
// Skip tag value if it is empty.
Expand Down
5 changes: 4 additions & 1 deletion stdlib/influxdata/influxdb/wide_to_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ func TestWideToTransformation(t *testing.T) {
static.Ints("f1", 1, nil, 3, nil),
static.StringKey("_measurement", "m0"),
static.TableList{
static.StringKeys("t0", "a", "b"),
static.StringKeys("t0", "a", nil, "b"),
},
}
if err := input.Do(func(tbl flux.Table) error {
Expand All @@ -147,6 +147,9 @@ func TestWideToTransformation(t *testing.T) {
want := `m0,t0=a f0=1,f1=1i 0
m0,t0=a f0=2 10000000000
m0,t0=a f0=3,f1=3i 20000000000
m0 f0=1,f1=1i 0
m0 f0=2 10000000000
m0 f0=3,f1=3i 20000000000
m0,t0=b f0=1,f1=1i 0
m0,t0=b f0=2 10000000000
m0,t0=b f0=3,f1=3i 20000000000
Expand Down

0 comments on commit 27fa85d

Please sign in to comment.