Check-in for Impala stuff

Rewrite of queries to run on Impala