First cut at query analysis, add analysis tests.
Add tests
Fix bug where function calls would incorrectly short-circuit analysis.