Restore casts stripped from grouping exprs by substitution.

Change-Id: I2a317025f9a8549beed7cf79b463239e11a6a2d0
Reviewed-on: http://gerrit.ent.cloudera.com:8080/3352
Reviewed-by: Nong Li <nong@cloudera.com>
Tested-by: jenkins