IMPALA-1324,IMPALA-1307: Enforce compatible hash exprs for partitioned joins.

When generating the plan for a partitioned hash join we place the join into a
partition-compatible input fragment, if possible. During this optimization one
must ensure that the hash exchange sending to the new join (which was placed
into a compatible fragment) is compatible with the hash exprs used for sending
to the fragment containing the join node.
In particular, we had two bugs:
1. The number of hash exprs could be different, possibly because of redundant
   exprs on one or both sides
2. The order of the hash exprs could be different, causing two rows with the
   same hash-expr values to be sent to different nodes

The fix is to enfore the above two properties, and revert to exchanging
both sides if no compatible hash exprs can be constructed.

Change-Id: Id155fb8094ed1694f7bc038ed2f9685f4d645fbe
Reviewed-on: http://gerrit.sjc.cloudera.com:8080/4639
Reviewed-by: Alex Behm <alex.behm@cloudera.com>
Tested-by: jenkins
IMPALA-1339: NULLs incorrectly hashed in groupby

Problem: hash table assumed all raw values were at most 16 bytes. This maximum was
increased to to support up to 128 bytes for CHARs.

Change-Id: I107c58b9a013d5db46ff5586bcdceee3961346e9
Reviewed-on: http://gerrit.sjc.cloudera.com:8080/4701
Reviewed-by: Victor Bittorf <victor.bittorf@cloudera.com>
Tested-by: jenkins
IMPALA-1343: Revert in-place state changes to table refs for inverted joins.

The bug was that changes to table refs were done in-place for join inversion,
and not reverted when a particular join re-ordering attempt was unsuccessful.
Subsequent join re-ordering attempts with a different left-most table ref
should use the original unmodified table refs.
To achieve the above, this patch reverts the state changes made to table refs
for unsuccessful join ordering attempts.
TODO: The cleaner fix is to clone all table refs for each new join re-ordering
attempt. However, implementing a state-preserving clone() for table refs is a
more involved change.

Change-Id: Ife0121f0e15441a5c0a23f75054c683c05b1ecac
Reviewed-on: http://gerrit.sjc.cloudera.com:8080/4715
Reviewed-by: Nong Li <nong@cloudera.com>
Tested-by: jenkins
Changed CHAR & VARCHAR max length to match Hive.

Also modified the text of the analysis exception for lengths that are too long or
short because John said they were unclear.

Change-Id: I9427d5c39298aa8207672e50e10fe527c5076599
Reviewed-on: http://gerrit.sjc.cloudera.com:8080/4698
Reviewed-by: Victor Bittorf <victor.bittorf@cloudera.com>
Tested-by: jenkins
IMPALA-1344: Fixed analytic aggregations with CHAR

The fix is to only register aggregates for string, not for CHAR or VARCHAR. The CHAR and
and VARCHAR types are implicitly cast to STRING for aggregation.

Also, fixed aggregate fn builtins that should not ignore distinct.

Change-Id: If4c1a2c6127360c2c8127a5c02949df74fafc85a
Reviewed-on: http://gerrit.sjc.cloudera.com:8080/4717
Reviewed-by: Victor Bittorf <victor.bittorf@cloudera.com>
Tested-by: jenkins
IMPALA-1330: Fix column types for SHOW {table, partition} STATS

Because we add 'total' to the last row in SHOW PARTITIONS, we set the
partition key columns to be string. At least, that's what the comment
said, but we didn't do that in fact.

This patch also corrects the column type for max width, which should be INT.

Change-Id: I787ab17be27f45107340119017e528c58a3daad3
Reviewed-on: http://gerrit.sjc.cloudera.com:8080/4678
Reviewed-by: Henry Robinson <henry@cloudera.com>
Tested-by: jenkins
IMPALA-1318: Joins should not return semi-joined tuples.

Change-Id: I93f5ddb8317af7794b5977e145805f9ff498d722
Reviewed-on: http://gerrit.sjc.cloudera.com:8080/4633
Tested-by: jenkins
Reviewed-by: Nong Li <nong@cloudera.com>