public static List<RexNode> adjustCaseBranchTypes(List<RexNode> nodes, RelDataType retType, RexBuilder rexBuilder) {
    List<RexNode> newNodes = new ArrayList<>();
    for (int i = 0; i < nodes.size(); i++) {
      RexNode node = nodes.get(i);
      if ((i % 2 == 1 || i == nodes.size() - 1)
          && !node.getType().getSqlTypeName().equals(retType.getSqlTypeName())) {
        newNodes.add(rexBuilder.makeCast(retType, node));
      } else {
        newNodes.add(node);
      }
    }
    return newNodes;
  }
Adds explicit casts if Calcite's type system could not resolve the CASE branches to a common type.

Calcite is more stricter than hive w.r.t type conversions.
If a CASE has branches with string/int/boolean branch types; there is no common type.
ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/translator/RexNodeConverter.java