fix(inputs.sql): cast measurement_column to string (#12323)

This commit is contained in:
jinx 2022-12-08 23:27:48 +08:00 committed by GitHub
parent f2729298ed
commit ad780bb1eb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 2 deletions

View File

@ -81,8 +81,12 @@ func (q *Query) parse(acc telegraf.Accumulator, rows *dbsql.Rows, t time.Time) (
for i, name := range columnNames {
if q.MeasurementColumn != "" && name == q.MeasurementColumn {
var ok bool
if measurement, ok = columnData[i].(string); !ok {
switch raw := columnData[i].(type) {
case string:
measurement = raw
case []byte:
measurement = string(raw)
default:
return 0, fmt.Errorf("measurement column type \"%T\" unsupported", columnData[i])
}
}