Fix aggregations over empty tables

Summary:
I had originally hoped that a query like "SELECT COUNT(*) FROM my_table" could
be interpreted as "SELECT COUNT(*) FROM my_table GROUP BY [empty tuple]". It
almost works: since there are no fields being grouped, the only possible group
key is the empty tuple, so all rows are in the same group and the aggregation
naturally happens over all rows in the table. The problem is that normal
GROUP BY semantics say that a group key mapping to zero rows shouldn't show up
in the output. That meant that "SELECT COUNT(*) FROM my_table" incorrectly
returned the empty set of results instead of a single 0 when my_table was empty.

To fix this, I added a special case to detect when we're grouping over nothing,
and I made sure that the empty tuple group always made it into the set of
groups. In the long run, a better solution may be to view full-table aggregates
as a completely separate case.

Test Plan: tools/runtests.py third_party/tinyquery

Reviewers: colin, benkraft

Reviewed By: colin, benkraft

Subscribers: benkraft

Differential Revision: http://phabricator.khanacademy.org/D12138
Implement querying over views

Summary:
I already stored views as special table-like objects, but I hadn't implemented a
way to query them. Querying them was almost really easy, except that handling
table aliases was a little tricky. Views can almost be seen as subqueries,
except that putting an alias on a regular subquery (almost) doesn't do anything,
and we need view aliases to actually take effect. So instead of just calling the
subquery compilation code, I based the view compilation code off of it (which
wasn't a big deal since it wasn't that long in the first place).

Test Plan: tools/runtests.py third_party/tinyquery

Reviewers: colin

Reviewed By: colin

Subscribers: benkraft

Differential Revision: http://phabricator.khanacademy.org/D12139