private VectorExpression getWhenExpression(List<ExprNodeDesc> childExpr,
      VectorExpressionDescriptor.Mode mode, TypeInfo returnType) throws HiveException {

    final int size = childExpr.size();

    final ExprNodeDesc whenDesc = childExpr.get(0);
    final ExprNodeDesc thenDesc = childExpr.get(1);
    final ExprNodeDesc elseDesc;

    if (size == 2) {
      elseDesc = new ExprNodeConstantDesc(returnType, null);
    } else if (size == 3) {
      elseDesc = childExpr.get(2);
    } else {
      final GenericUDFWhen udfWhen = new GenericUDFWhen();
      elseDesc = new ExprNodeGenericFuncDesc(returnType, udfWhen, udfWhen.getUdfName(),
          childExpr.subList(2, childExpr.size()));
    }

    // Transform CASE WHEN with just a THEN/ELSE into an IF statement.
    final GenericUDFIf genericUDFIf = new GenericUDFIf();
    final List<ExprNodeDesc> ifChildExpr =
        Arrays.<ExprNodeDesc>asList(whenDesc, thenDesc, elseDesc);
    return getIfExpression(genericUDFIf, ifChildExpr, mode, returnType);
  }
Invoke special handling for expressions that can't be vectorized by regular
descriptor based lookup.
ql/src/java/org/apache/hadoop/hive/ql/exec/vector/VectorizationContext.java