diff --git a/executor.go b/executor.go index 1736ce94a..3b09cd92c 100644 --- a/executor.go +++ b/executor.go @@ -257,7 +257,7 @@ func (e *executor) Execute(ctx context.Context, index string, q *pql.Query, shar opt = &execOptions{} } // Default maximum memory, if not passed in. - if opt.MaxMemory == 0 { + if opt.MaxMemory == 0 && q.HasCall("Extract") { opt.MaxMemory = e.maxMemory } diff --git a/pql/ast.go b/pql/ast.go index 2f9ec02e8..f61ebba95 100644 --- a/pql/ast.go +++ b/pql/ast.go @@ -35,6 +35,16 @@ func (q *Query) ExpandVars(vars map[string]interface{}) (*Query, error) { return &other, nil } +// HasCall returns true if q contains the given call name. +func (q *Query) HasCall(name string) bool { + for _, c := range q.Calls { + if c.HasCall(name) { + return true + } + } + return false +} + func (q *Query) startCall(name string) { // Coerce every name into a canonical form if we know of one. if canon, ok := canonicalCaps[strings.ToLower(name)]; ok { @@ -349,6 +359,20 @@ type Call struct { Precomputed map[uint64]interface{} } +// HasCall returns true if q contains the given call name. +func (c *Call) HasCall(name string) bool { + if c.Name == name { + return true + } + + for _, child := range c.Children { + if child.HasCall(name) { + return true + } + } + return false +} + // callInfo defines the arguments allowed for a particular PQL call, and // possibly things about its semantics. If allowUnknown is true, unfamiliar // non-reserved names are allowed on the assumption that they're field names.