Fix destructive queries. Add logic to have non-aggregate queries use a local engine.