This commit is contained in:
Aliaksandr Valialkin 2024-05-21 15:58:41 +02:00
parent 32c0fd3437
commit d551520e6f
No known key found for this signature in database
GPG key ID: 52C003EE2BCDB9EB
2 changed files with 83 additions and 0 deletions

View file

@ -13,6 +13,7 @@ func TestParseStatsUniqValuesSuccess(t *testing.T) {
f(`uniq_values(*)`)
f(`uniq_values(a)`)
f(`uniq_values(a, b)`)
f(`uniq_values(a, b) limit 10`)
}
func TestParseStatsUniqValuesFailure(t *testing.T) {
@ -24,6 +25,8 @@ func TestParseStatsUniqValuesFailure(t *testing.T) {
f(`uniq_values`)
f(`uniq_values(a b)`)
f(`uniq_values(x) y`)
f(`uniq_values(x) limit`)
f(`uniq_values(x) limit N`)
}
func TestStatsUniqValues(t *testing.T) {
@ -52,6 +55,26 @@ func TestStatsUniqValues(t *testing.T) {
},
})
f("stats uniq_values(*) limit 1999 as x", [][]Field{
{
{"_msg", `abc`},
{"a", `2`},
{"b", `3`},
},
{
{"_msg", `def`},
{"a", `1`},
},
{
{"a", `-3`},
{"b", `54`},
},
}, [][]Field{
{
{"x", `["-3","1","2","3","54","abc","def"]`},
},
})
f("stats uniq_values(a) as x", [][]Field{
{
{"_msg", `abc`},
@ -237,6 +260,36 @@ func TestStatsUniqValues(t *testing.T) {
},
})
f("stats by (a) uniq_values(*) limit 100 as x", [][]Field{
{
{"_msg", `abc`},
{"a", `1`},
{"b", `3`},
},
{
{"_msg", `def`},
{"a", `1`},
{"c", "3"},
},
{
{"a", `3`},
{"b", `5`},
},
{
{"a", `3`},
{"b", `7`},
},
}, [][]Field{
{
{"a", "1"},
{"x", `["1","3","abc","def"]`},
},
{
{"a", "3"},
{"x", `["3","5","7"]`},
},
})
f("stats by (a) uniq_values(c) as x", [][]Field{
{
{"_msg", `abc`},

View file

@ -0,0 +1,30 @@
package logstorage
import (
"testing"
)
func TestParseStatsValuesSuccess(t *testing.T) {
f := func(pipeStr string) {
t.Helper()
expectParseStatsFuncSuccess(t, pipeStr)
}
f(`values(*)`)
f(`values(a)`)
f(`values(a, b)`)
f(`values(a, b) limit 10`)
}
func TestParseStatsValuesFailure(t *testing.T) {
f := func(pipeStr string) {
t.Helper()
expectParseStatsFuncFailure(t, pipeStr)
}
f(`values`)
f(`values(a b)`)
f(`values(x) y`)
f(`values(a, b) limit`)
f(`values(a, b) limit foo`)
}