mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2024-12-31 15:06:26 +00:00
wip
This commit is contained in:
parent
2368a3afce
commit
65dd152387
3 changed files with 10 additions and 15 deletions
|
@ -1457,11 +1457,10 @@ func TestQueryGetNeededColumns(t *testing.T) {
|
||||||
f(`* | sort by (f1) | sort by (f2,f3 desc) desc | fields f4 | rm f1,f2,f5`, `f1,f2,f3,f4`, ``)
|
f(`* | sort by (f1) | sort by (f2,f3 desc) desc | fields f4 | rm f1,f2,f5`, `f1,f2,f3,f4`, ``)
|
||||||
|
|
||||||
f(`* | stats by(f1) count(f2) r1, count(f3,f4) r2`, `f1,f2,f3,f4`, ``)
|
f(`* | stats by(f1) count(f2) r1, count(f3,f4) r2`, `f1,f2,f3,f4`, ``)
|
||||||
f(`* | stats by(f1) count(f2) r1, count(f3,f4) r2 | fields f5,f6`, ``, ``)
|
f(`* | stats by(f1) count(f2) r1, count(f3,f4) r2 | fields f5,f6`, `f1`, ``)
|
||||||
f(`* | stats by(f1) count(f2) r1, count(f3,f4) r2 | fields f1,f5`, `f1`, ``)
|
f(`* | stats by(f1) count(f2) r1, count(f3,f4) r2 | fields f1,f5`, `f1`, ``)
|
||||||
f(`* | stats by(f1) count(f2) r1, count(f3,f4) r2 | fields r1`, `f1,f2`, ``)
|
f(`* | stats by(f1) count(f2) r1, count(f3,f4) r2 | fields r1`, `f1,f2`, ``)
|
||||||
f(`* | stats by(f1) count(f2) r1, count(f3,f4) r2 | fields r2,r3`, `f1,f3,f4`, ``)
|
f(`* | stats by(f1) count(f2) r1, count(f3,f4) r2 | fields r2,r3`, `f1,f3,f4`, ``)
|
||||||
f(`_time:5m | stats by(_time:day) count() r1 | stats values(_time) r2`, `_time`, ``)
|
|
||||||
f(`* | stats count(f1) r1 | stats count() r1`, ``, ``)
|
f(`* | stats count(f1) r1 | stats count() r1`, ``, ``)
|
||||||
f(`* | stats count(f1) r1 | stats count() r2`, ``, ``)
|
f(`* | stats count(f1) r1 | stats count() r2`, ``, ``)
|
||||||
f(`* | stats count(f1) r1 | stats count(r1) r2`, `f1`, ``)
|
f(`* | stats count(f1) r1 | stats count(r1) r2`, `f1`, ``)
|
||||||
|
@ -1473,6 +1472,9 @@ func TestQueryGetNeededColumns(t *testing.T) {
|
||||||
f(`* | stats by(f3,f4) count(f1,f2) r1 | stats count(f2) r1, count(r1) r2 | fields r2`, `f1,f2,f3,f4`, ``)
|
f(`* | stats by(f3,f4) count(f1,f2) r1 | stats count(f2) r1, count(r1) r2 | fields r2`, `f1,f2,f3,f4`, ``)
|
||||||
f(`* | stats by(f3,f4) count(f1,f2) r1 | stats count(f3) r1, count(r1) r2 | fields r1`, `f3,f4`, ``)
|
f(`* | stats by(f3,f4) count(f1,f2) r1 | stats count(f3) r1, count(r1) r2 | fields r1`, `f3,f4`, ``)
|
||||||
|
|
||||||
|
f(`_time:5m | stats by(_time:day) count() r1 | stats values(_time) r2`, `_time`, ``)
|
||||||
|
f(`_time:1y | stats (_time:1w) count() r1 | stats count() r2`, `_time`, ``)
|
||||||
|
|
||||||
f(`* | uniq`, `*`, ``)
|
f(`* | uniq`, `*`, ``)
|
||||||
f(`* | uniq by (f1,f2)`, `f1,f2`, ``)
|
f(`* | uniq by (f1,f2)`, `f1,f2`, ``)
|
||||||
f(`* | uniq by (f1,f2) | fields f1,f3`, `f1,f2`, ``)
|
f(`* | uniq by (f1,f2) | fields f1,f3`, `f1,f2`, ``)
|
||||||
|
|
|
@ -87,21 +87,14 @@ func (ps *pipeStats) updateNeededFields(neededFields, unneededFields fieldsSet)
|
||||||
neededFieldsOrig := neededFields.clone()
|
neededFieldsOrig := neededFields.clone()
|
||||||
neededFields.reset()
|
neededFields.reset()
|
||||||
|
|
||||||
byFields := make([]string, len(ps.byFields))
|
// byFields are needed unconditionally, since the output number of rows depends on them.
|
||||||
for i, bf := range ps.byFields {
|
for _, bf := range ps.byFields {
|
||||||
byFields[i] = bf.name
|
neededFields.add(bf.name)
|
||||||
}
|
|
||||||
|
|
||||||
for _, f := range byFields {
|
|
||||||
if neededFieldsOrig.contains(f) && !unneededFields.contains(f) {
|
|
||||||
neededFields.addAll(byFields)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for i, resultName := range ps.resultNames {
|
for i, resultName := range ps.resultNames {
|
||||||
if neededFieldsOrig.contains(resultName) && !unneededFields.contains(resultName) {
|
if neededFieldsOrig.contains(resultName) && !unneededFields.contains(resultName) {
|
||||||
funcFields := ps.funcs[i].neededFields()
|
funcFields := ps.funcs[i].neededFields()
|
||||||
neededFields.addAll(byFields)
|
|
||||||
neededFields.addAll(funcFields)
|
neededFields.addAll(funcFields)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -44,7 +44,7 @@ func TestPipeStatsUpdateNeededFields(t *testing.T) {
|
||||||
f("stats count(f1,f2) r1, sum(f3,f4) r2", "*", "r1,r3", "f3,f4", "")
|
f("stats count(f1,f2) r1, sum(f3,f4) r2", "*", "r1,r3", "f3,f4", "")
|
||||||
f("stats by (b1,b2) count(f1,f2) r1", "*", "r1,r2", "b1,b2", "")
|
f("stats by (b1,b2) count(f1,f2) r1", "*", "r1,r2", "b1,b2", "")
|
||||||
f("stats by (b1,b2) count(f1,f2) r1", "*", "r1,r2,b1", "b1,b2", "")
|
f("stats by (b1,b2) count(f1,f2) r1", "*", "r1,r2,b1", "b1,b2", "")
|
||||||
f("stats by (b1,b2) count(f1,f2) r1", "*", "r1,r2,b1,b2", "", "")
|
f("stats by (b1,b2) count(f1,f2) r1", "*", "r1,r2,b1,b2", "b1,b2", "")
|
||||||
f("stats by (b1,b2) count(f1,f2) r1, count(f1,f3) r2", "*", "r1,r3", "b1,b2,f1,f3", "")
|
f("stats by (b1,b2) count(f1,f2) r1, count(f1,f3) r2", "*", "r1,r3", "b1,b2,f1,f3", "")
|
||||||
|
|
||||||
// needed fields do not intersect with stats fields
|
// needed fields do not intersect with stats fields
|
||||||
|
@ -52,8 +52,8 @@ func TestPipeStatsUpdateNeededFields(t *testing.T) {
|
||||||
f("stats count(*) r1", "r2", "", "", "")
|
f("stats count(*) r1", "r2", "", "", "")
|
||||||
f("stats count(f1,f2) r1", "r2", "", "", "")
|
f("stats count(f1,f2) r1", "r2", "", "", "")
|
||||||
f("stats count(f1,f2) r1, sum(f3,f4) r2", "r3", "", "", "")
|
f("stats count(f1,f2) r1, sum(f3,f4) r2", "r3", "", "", "")
|
||||||
f("stats by (b1,b2) count(f1,f2) r1", "r2", "", "", "")
|
f("stats by (b1,b2) count(f1,f2) r1", "r2", "", "b1,b2", "")
|
||||||
f("stats by (b1,b2) count(f1,f2) r1, count(f1,f3) r2", "r3", "", "", "")
|
f("stats by (b1,b2) count(f1,f2) r1, count(f1,f3) r2", "r3", "", "b1,b2", "")
|
||||||
|
|
||||||
// needed fields intersect with stats fields
|
// needed fields intersect with stats fields
|
||||||
f("stats count() r1", "r1,r2", "", "", "")
|
f("stats count() r1", "r1,r2", "", "", "")
|
||||||
|
|
Loading…
Reference in a new issue