Chore: Add last downsampling function to Resample expression (#57379)

This commit is contained in:
Yuriy Tseretyan
2022-10-21 10:03:43 -04:00
committed by GitHub
parent cd0e0fcc53
commit 245c1ee3d3
3 changed files with 37 additions and 0 deletions
+4
View File
@@ -54,6 +54,8 @@ func (s Series) Resample(refID string, interval time.Duration, downsampler strin
default:
return s, fmt.Errorf("upsampling %v not implemented", upsampler)
}
} else if len(vals) == 1 {
value = vals[0]
} else { // downsampling
fVec := data.NewField("", s.GetLabels(), vals)
ff := Float64Field(*fVec)
@@ -67,6 +69,8 @@ func (s Series) Resample(refID string, interval time.Duration, downsampler strin
tmp = Min(&ff)
case "max":
tmp = Max(&ff)
case "last":
tmp = Last(&ff)
default:
return s, fmt.Errorf("downsampling %v not implemented", downsampler)
}