mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2024-12-31 15:06:26 +00:00
wip
This commit is contained in:
parent
1790caa082
commit
277f13f3fa
4 changed files with 24 additions and 2 deletions
|
@ -1513,10 +1513,10 @@ func TestQueryGetNeededColumns(t *testing.T) {
|
||||||
unneededColumns := strings.Join(unneeded, ",")
|
unneededColumns := strings.Join(unneeded, ",")
|
||||||
|
|
||||||
if neededColumns != neededColumnsExpected {
|
if neededColumns != neededColumnsExpected {
|
||||||
t.Fatalf("unexpected neededColumns; got %q; want %q", neededColumns, neededColumnsExpected)
|
t.Fatalf("unexpected neededColumns for [%s]; got %q; want %q", s, neededColumns, neededColumnsExpected)
|
||||||
}
|
}
|
||||||
if unneededColumns != unneededColumnsExpected {
|
if unneededColumns != unneededColumnsExpected {
|
||||||
t.Fatalf("unexpected unneededColumns; got %q; want %q", unneededColumns, unneededColumnsExpected)
|
t.Fatalf("unexpected unneededColumns for [%s]; got %q; want %q", s, unneededColumns, unneededColumnsExpected)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1786,10 +1786,14 @@ func TestQueryGetNeededColumns(t *testing.T) {
|
||||||
f(`* | copy a b, c d | count() r1`, `a`, ``)
|
f(`* | copy a b, c d | count() r1`, `a`, ``)
|
||||||
f(`* | delete a, b | count() r1`, `*`, `a`)
|
f(`* | delete a, b | count() r1`, `*`, `a`)
|
||||||
f(`* | extract "<f1>bar" from x | count() r1`, `x`, ``)
|
f(`* | extract "<f1>bar" from x | count() r1`, `x`, ``)
|
||||||
|
f(`* | extract if (q:w p:a) "<f1>bar" from x | count() r1`, `p,q,x`, ``)
|
||||||
f(`* | extract_regexp "(?P<f1>.*)bar" from x | count() r1`, `x`, ``)
|
f(`* | extract_regexp "(?P<f1>.*)bar" from x | count() r1`, `x`, ``)
|
||||||
|
f(`* | extract_regexp if (q:w p:a) "(?P<f1>.*)bar" from x | count() r1`, `p,q,x`, ``)
|
||||||
f(`* | field_names | count() r1`, `*`, `_time`)
|
f(`* | field_names | count() r1`, `*`, `_time`)
|
||||||
f(`* | limit 10 | field_names as abc | count() r1`, `*`, ``)
|
f(`* | limit 10 | field_names as abc | count() r1`, `*`, ``)
|
||||||
f(`* | fields a, b | count() r1`, `a`, ``)
|
f(`* | fields a, b | count() r1`, `a`, ``)
|
||||||
f(`* | field_values a | count() r1`, `a`, ``)
|
f(`* | field_values a | count() r1`, `a`, ``)
|
||||||
f(`* | limit 10 | filter a:b c:d | count() r1`, `a,c`, ``)
|
f(`* | limit 10 | filter a:b c:d | count() r1`, `a,c`, ``)
|
||||||
|
f(`* | format "<a><b>" as c | count() r1`, `a,b`, ``)
|
||||||
|
f(`* | format if (q:w p:a) "<a><b>" as c | count() r1`, `a,b,p,q`, ``)
|
||||||
}
|
}
|
||||||
|
|
|
@ -62,6 +62,9 @@ func (pe *pipeExtract) initFilterInValues(cache map[string][]string, getFieldVal
|
||||||
func (pe *pipeExtract) updateNeededFields(neededFields, unneededFields fieldsSet) {
|
func (pe *pipeExtract) updateNeededFields(neededFields, unneededFields fieldsSet) {
|
||||||
if neededFields.isEmpty() {
|
if neededFields.isEmpty() {
|
||||||
neededFields.add(pe.fromField)
|
neededFields.add(pe.fromField)
|
||||||
|
if pe.iff != nil {
|
||||||
|
neededFields.addFields(pe.iff.neededFields)
|
||||||
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -64,6 +64,9 @@ func (pe *pipeExtractRegexp) initFilterInValues(cache map[string][]string, getFi
|
||||||
func (pe *pipeExtractRegexp) updateNeededFields(neededFields, unneededFields fieldsSet) {
|
func (pe *pipeExtractRegexp) updateNeededFields(neededFields, unneededFields fieldsSet) {
|
||||||
if neededFields.isEmpty() {
|
if neededFields.isEmpty() {
|
||||||
neededFields.add(pe.fromField)
|
neededFields.add(pe.fromField)
|
||||||
|
if pe.iff != nil {
|
||||||
|
neededFields.addFields(pe.iff.neededFields)
|
||||||
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -43,6 +43,18 @@ func (pf *pipeFormat) String() string {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (pf *pipeFormat) updateNeededFields(neededFields, unneededFields fieldsSet) {
|
func (pf *pipeFormat) updateNeededFields(neededFields, unneededFields fieldsSet) {
|
||||||
|
if neededFields.isEmpty() {
|
||||||
|
for _, step := range pf.steps {
|
||||||
|
if step.field != "" {
|
||||||
|
neededFields.add(step.field)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if pf.iff != nil {
|
||||||
|
neededFields.addFields(pf.iff.neededFields)
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
if neededFields.contains("*") {
|
if neededFields.contains("*") {
|
||||||
if !unneededFields.contains(pf.resultField) {
|
if !unneededFields.contains(pf.resultField) {
|
||||||
if !pf.keepOriginalFields && !pf.skipEmptyResults {
|
if !pf.keepOriginalFields && !pf.skipEmptyResults {
|
||||||
|
|
Loading…
Reference in a new issue