DRILL-1663: Fix casting to a variable width type implicitly in a join condition

Factor out logic in ExpressionTreeMaterializer so the same logic can be reused in ChainedHashTable.
DRILL-1631: Bump optiq version to r8
Add test case. Fix is in optiq.