mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2024-12-31 15:06:26 +00:00
wip
This commit is contained in:
parent
fa20f150a6
commit
c19bf7abb5
3 changed files with 11 additions and 19 deletions
|
@ -1820,4 +1820,6 @@ func TestQueryGetNeededColumns(t *testing.T) {
|
||||||
f(`* | unpack_logfmt from x fields (a,b) | count() r1`, ``, ``)
|
f(`* | unpack_logfmt from x fields (a,b) | count() r1`, ``, ``)
|
||||||
f(`* | unpack_logfmt if (q:w p:a) from x | count() r1`, `p,q`, ``)
|
f(`* | unpack_logfmt if (q:w p:a) from x | count() r1`, `p,q`, ``)
|
||||||
f(`* | unpack_logfmt if (q:w p:a) from x fields(a,b) | count() r1`, `p,q`, ``)
|
f(`* | unpack_logfmt if (q:w p:a) from x fields(a,b) | count() r1`, `p,q`, ``)
|
||||||
|
f(`* | unroll (a, b) | count() r1`, `a,b`, ``)
|
||||||
|
f(`* | unroll if (q:w p:a) (a, b) | count() r1`, `a,b,p,q`, ``)
|
||||||
}
|
}
|
||||||
|
|
|
@ -52,25 +52,15 @@ func (pu *pipeUnroll) initFilterInValues(cache map[string][]string, getFieldValu
|
||||||
|
|
||||||
func (pu *pipeUnroll) updateNeededFields(neededFields, unneededFields fieldsSet) {
|
func (pu *pipeUnroll) updateNeededFields(neededFields, unneededFields fieldsSet) {
|
||||||
if neededFields.contains("*") {
|
if neededFields.contains("*") {
|
||||||
unneededFieldsCount := 0
|
if pu.iff != nil {
|
||||||
for _, f := range pu.fields {
|
|
||||||
if unneededFields.contains(f) {
|
|
||||||
unneededFieldsCount++
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if unneededFieldsCount < len(pu.fields) && pu.iff != nil {
|
|
||||||
unneededFields.removeFields(pu.iff.neededFields)
|
unneededFields.removeFields(pu.iff.neededFields)
|
||||||
}
|
}
|
||||||
|
unneededFields.removeFields(pu.fields)
|
||||||
} else {
|
} else {
|
||||||
needIfFields := false
|
if pu.iff != nil {
|
||||||
for _, f := range pu.fields {
|
|
||||||
if neededFields.contains(f) {
|
|
||||||
needIfFields = true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if needIfFields && pu.iff != nil {
|
|
||||||
neededFields.addFields(pu.iff.neededFields)
|
neededFields.addFields(pu.iff.neededFields)
|
||||||
}
|
}
|
||||||
|
neededFields.addFields(pu.fields)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -225,13 +225,13 @@ func TestPipeUnrollUpdateNeededFields(t *testing.T) {
|
||||||
f("unroll if (f1:b) (x)", "*", "f1,f2", "*", "f2")
|
f("unroll if (f1:b) (x)", "*", "f1,f2", "*", "f2")
|
||||||
|
|
||||||
// all the needed fields, unneeded fields intersect with src
|
// all the needed fields, unneeded fields intersect with src
|
||||||
f("unroll (x)", "*", "f2,x", "*", "f2,x")
|
f("unroll (x)", "*", "f2,x", "*", "f2")
|
||||||
f("unroll if (a:b) (x)", "*", "f2,x", "*", "f2,x")
|
f("unroll if (a:b) (x)", "*", "f2,x", "*", "f2")
|
||||||
f("unroll if (f2:b) (x)", "*", "f2,x", "*", "f2,x")
|
f("unroll if (f2:b) (x)", "*", "f2,x", "*", "")
|
||||||
|
|
||||||
// needed fields do not intersect with src
|
// needed fields do not intersect with src
|
||||||
f("unroll (x)", "f1,f2", "", "f1,f2", "")
|
f("unroll (x)", "f1,f2", "", "f1,f2,x", "")
|
||||||
f("unroll if (a:b) (x)", "f1,f2", "", "f1,f2", "")
|
f("unroll if (a:b) (x)", "f1,f2", "", "a,f1,f2,x", "")
|
||||||
|
|
||||||
// needed fields intersect with src
|
// needed fields intersect with src
|
||||||
f("unroll (x)", "f2,x", "", "f2,x", "")
|
f("unroll (x)", "f2,x", "", "f2,x", "")
|
||||||
|
|
Loading…
Reference in a new issue