This commit is contained in:
Aliaksandr Valialkin 2024-05-24 19:45:43 +02:00
parent b59ed0bc79
commit aa23832921
No known key found for this signature in database
GPG key ID: 52C003EE2BCDB9EB
4 changed files with 27 additions and 4 deletions

View file

@ -20,6 +20,7 @@ according to [these docs](https://docs.victoriametrics.com/victorialogs/quicksta
## tip
* FEATURE: support [comparing](https://docs.victoriametrics.com/victorialogs/logsql/#range-filter) log field values with [special numeric values](https://docs.victoriametrics.com/victorialogs/logsql/#numeric-values). For example, `duration:>1.5s` and `response_size:<15KiB` are valid filters now.
* FEATURE: properly sort [durations](https://docs.victoriametrics.com/victorialogs/logsql/#duration-values) and [short numeric values](https://docs.victoriametrics.com/victorialogs/logsql/#short-numeric-values) in [`sort` pipe](https://docs.victoriametrics.com/victorialogs/logsql/#sort-pipe). For example, `10s` goes in front of `1h`, while `10KB` goes in front of `1GB`.
* FEATURE: add an ability to preserve the original non-empty field values when performing [`extract`](https://docs.victoriametrics.com/victorialogs/logsql/#extract-pipe), [`unpack_json`](https://docs.victoriametrics.com/victorialogs/logsql/#unpack_json-pipe), [`unpack_logfmt`](https://docs.victoriametrics.com/victorialogs/logsql/#unpack_logfmt-pipe) and [`format`](https://docs.victoriametrics.com/victorialogs/logsql/#format-pipe) pipes.
## [v0.10.0](https://github.com/VictoriaMetrics/VictoriaMetrics/releases/tag/v0.10.0-victorialogs)

View file

@ -1700,7 +1700,7 @@ func (c *blockResultColumn) sumValues(br *blockResult) (float64, int) {
values := c.getValuesEncoded(br)
for i := range values {
if i == 0 || values[i-1] != values[i] {
f, ok = tryParseFloat64(values[i])
f, ok = tryParseNumber(values[i])
}
if ok {
sum += f
@ -1713,7 +1713,7 @@ func (c *blockResultColumn) sumValues(br *blockResult) (float64, int) {
a := encoding.GetFloat64s(len(dictValues))
dictValuesFloat := a.A
for i, v := range dictValues {
f, ok := tryParseFloat64(v)
f, ok := tryParseNumber(v)
if !ok {
f = nan
}

View file

@ -621,8 +621,8 @@ func lessString(a, b string) bool {
return nA < nB
}
fA, okA := tryParseFloat64(a)
fB, okB := tryParseFloat64(b)
fA, okA := tryParseNumber(a)
fB, okB := tryParseNumber(b)
if okA && okB {
return fA < fB
}

View file

@ -1,6 +1,7 @@
package logstorage
import (
"strings"
"testing"
)
@ -415,3 +416,24 @@ func TestStatsUniqValues(t *testing.T) {
},
})
}
func TestSortStrings(t *testing.T) {
f := func(s, resultExpected string) {
t.Helper()
a := strings.Split(s, ",")
sortStrings(a)
result := strings.Join(a, ",")
if result != resultExpected {
t.Fatalf("unexpected sort result\ngot\n%q\nwant\n%q", a, resultExpected)
}
}
f("", "")
f("1", "1")
f("foo,bar,baz", "bar,baz,foo")
f("100ms,1.5s,1.23s","100ms,1.23s,1.5s")
f("10KiB,10KB,5.34K","5.34K,10KB,10KiB")
f("v1.10.9,v1.10.10,v1.9.0","v1.9.0,v1.10.9,v1.10.10")
f("10s,123,100M","123,100M,10s")
}