IMPALA-845: Transfer predicates to 2nd phase merge agg in some cases.

Having predicates need to be transferred to the 2nd phase merge agg
for distinct + non-distinct aggregates without group by.
For distinct + non-distinct aggregates with group by, it is correct
to evaluate the predicates at the 2nd phase (non-merge) agg.

Change-Id: I71d73c4ef92becbb81e142bc0cb5f54e790b1fb5
Reviewed-on: http://gerrit.ent.cloudera.com:8080/1743
Reviewed-by: Alex Behm <alex.behm@cloudera.com>
Tested-by: jenkins
IMPALA-822,IMP-1271: Binding predicates on an aggregation now properly trigger slot materialization.

The bug was that the number of materialized agg-tuple slots did not correspond to the number
of materialized agg functions, due to binding predicates against an AggNode causing slot
materialization after SelectStmt.materializeRequiredSlots().
This patch fixes the issue by taking binding predicates (bound to a slot in an agg tuple)
into consideration in SelectStmt.materializeRequiredSlots().
I added a new sanity check in AggregationNode.toThrift() surfaced another issue with slot
materialization that is also fixed in this patch. The ordering exprs must be marked before
the agg exprs in SelectStmt.materializeRequiredSlots() because the odering exprs may contain
agg exprs that are only referenced inside the ORDER BY clause.

Change-Id: I1bdc0466f583907bed625ce6608938e59faee83f
Reviewed-on: http://gerrit.ent.cloudera.com:8080/1639
Reviewed-by: Marcel Kornacker <marcel@cloudera.com>
Tested-by: jenkins
More robust initialization of ScannerContext

This commit is in conjunction with the "Fix missing status check in
lzo scanner." commit in the LZO repo. It provides a test case for the
LZO fix, and changes the ScannerContext initialization so it will fail
more gracefully instead of crashing.

Change-Id: Idcafeb3679a8fa54322d1ec31c6f1aba860e4e4f
Reviewed-on: http://gerrit.ent.cloudera.com:8080/1680
Reviewed-by: Skye Wanderman-Milne <skye@cloudera.com>
Tested-by: jenkins
IMPALA-844: Catch TException rather than TTransportException during RPCs

Change-Id: I9a0df4ed01047860504efbe20ff56d9d2dc191cb
Reviewed-on: http://gerrit.ent.cloudera.com:8080/1732
Reviewed-by: Henry Robinson <henry@cloudera.com>
Tested-by: jenkins