diff --git a/mqlc/mqlc.go b/mqlc/mqlc.go index 7602c36cae..6841c0899b 100644 --- a/mqlc/mqlc.go +++ b/mqlc/mqlc.go @@ -2243,12 +2243,12 @@ func CompileAST(ast *parser.AST, props map[string]*llx.Primitive, conf CompilerC // Compile a code piece against a schema into chunky code func compile(input string, props map[string]*llx.Primitive, compilerConf CompilerConfig) (*llx.CodeBundle, error) { - conf := compilerConf - conf.Stats = compilerConf.Stats.CompileQuery(input) - // remove leading whitespace; we are re-using this later on input = Dedent(input) + conf := compilerConf + conf.Stats = compilerConf.Stats.CompileQuery(input) + ast, err := parser.Parse(input) if ast == nil { return nil, err diff --git a/mqlc/mqlc_stats.go b/mqlc/mqlc_stats.go index 1c014d954a..21b420831a 100644 --- a/mqlc/mqlc_stats.go +++ b/mqlc/mqlc_stats.go @@ -141,7 +141,18 @@ func newCompilerMultiStats() *compilerMultiStats { } func (c *compilerMultiStats) WalkSorted(f func(resource string, field string, info FieldStat)) { - panic("walking code on multi-stats not yet supported") + c.lock.Lock() + defer c.lock.Unlock() + + aggregate := newCompilerStats() + for _, v := range c.stats { + v.WalkSorted(func(resource, field string, info FieldStat) { + aggregate.CallResource(resource) + aggregate.ResourceFields[resource][field] = info + }) + } + + aggregate.WalkSorted(f) } func (c *compilerMultiStats) WalkCode(f func(code string, stats CompilerStats)) {