hive-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mmccl...@apache.org
Subject [39/51] [partial] hive git commit: HIVE-17433: Vectorization: Support Decimal64 in Hive Query Engine (Matt McCline, reviewed by Teddy Choi)
Date Sun, 29 Oct 2017 20:40:18 GMT
http://git-wip-us.apache.org/repos/asf/hive/blob/e63ebccc/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/RoundWithNumDigitsDoubleToDouble.java
----------------------------------------------------------------------
diff --git a/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/RoundWithNumDigitsDoubleToDouble.java b/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/RoundWithNumDigitsDoubleToDouble.java
index 4b791b6..d49dab8 100644
--- a/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/RoundWithNumDigitsDoubleToDouble.java
+++ b/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/RoundWithNumDigitsDoubleToDouble.java
@@ -23,14 +23,13 @@ import org.apache.hadoop.hive.ql.udf.generic.RoundUtils;
 import org.apache.hadoop.io.IntWritable;
 
 // Vectorized implementation of ROUND(Col, N) function
-public class RoundWithNumDigitsDoubleToDouble extends MathFuncDoubleToDouble
-    implements ISetLongArg {
+public class RoundWithNumDigitsDoubleToDouble extends MathFuncDoubleToDouble {
   private static final long serialVersionUID = 1L;
 
   private IntWritable decimalPlaces;
 
-  public RoundWithNumDigitsDoubleToDouble(int colNum, long scalarVal, int outputColumn) {
-    super(colNum, outputColumn);
+  public RoundWithNumDigitsDoubleToDouble(int colNum, long scalarVal, int outputColumnNum) {
+    super(colNum, outputColumnNum);
     this.decimalPlaces = new IntWritable();
     decimalPlaces.set((int) scalarVal);
   }
@@ -54,11 +53,6 @@ public class RoundWithNumDigitsDoubleToDouble extends MathFuncDoubleToDouble
   }
 
   @Override
-  public void setArg(long l) {
-    this.decimalPlaces.set((int) l);
-  }
-
-  @Override
   public String vectorExpressionParameters() {
     return "col " + colNum + ", decimalPlaces " + decimalPlaces.get();
   }

http://git-wip-us.apache.org/repos/asf/hive/blob/e63ebccc/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/SelectColumnIsFalse.java
----------------------------------------------------------------------
diff --git a/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/SelectColumnIsFalse.java b/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/SelectColumnIsFalse.java
index a906bef..121acba 100644
--- a/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/SelectColumnIsFalse.java
+++ b/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/SelectColumnIsFalse.java
@@ -27,15 +27,19 @@ import org.apache.hadoop.hive.ql.exec.vector.VectorizedRowBatch;
  */
 public class SelectColumnIsFalse extends VectorExpression {
   private static final long serialVersionUID = 1L;
-  private int colNum1;
+
+  private final int colNum1;
 
   public SelectColumnIsFalse(int colNum1) {
-    this();
+    super();
     this.colNum1 = colNum1;
   }
 
   public SelectColumnIsFalse() {
     super();
+
+    // Dummy final assignments.
+    colNum1 = -1;
   }
 
   @Override
@@ -120,26 +124,8 @@ public class SelectColumnIsFalse extends VectorExpression {
     }
   }
 
-  @Override
-  public int getOutputColumn() {
-    return -1;
-  }
-
-  @Override
-  public String getOutputType() {
-    return "boolean";
-  }
-
-  public int getColNum1() {
-    return colNum1;
-  }
-
-  public void setColNum1(int colNum1) {
-    this.colNum1 = colNum1;
-  }
-
   public String vectorExpressionParameters() {
-    return "col " + colNum1;
+    return getColumnParamString(0, colNum1);
   }
 
   @Override

http://git-wip-us.apache.org/repos/asf/hive/blob/e63ebccc/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/SelectColumnIsNotNull.java
----------------------------------------------------------------------
diff --git a/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/SelectColumnIsNotNull.java b/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/SelectColumnIsNotNull.java
index f8517dd..f0f1a9f 100644
--- a/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/SelectColumnIsNotNull.java
+++ b/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/SelectColumnIsNotNull.java
@@ -27,15 +27,19 @@ import org.apache.hadoop.hive.ql.exec.vector.VectorizedRowBatch;
  */
 public class SelectColumnIsNotNull extends VectorExpression {
   private static final long serialVersionUID = 1L;
-  private int colNum;
+
+  private final int colNum;
 
   public SelectColumnIsNotNull(int colNum) {
-    this();
+    super();
     this.colNum = colNum;
   }
 
   public SelectColumnIsNotNull() {
     super();
+
+    // Dummy final assignments.
+    colNum = -1;
   }
 
   @Override
@@ -90,26 +94,8 @@ public class SelectColumnIsNotNull extends VectorExpression {
   }
 
   @Override
-  public int getOutputColumn() {
-    return -1;
-  }
-
-  @Override
-  public String getOutputType() {
-    return "boolean";
-  }
-
-  public int getColNum() {
-    return colNum;
-  }
-
-  public void setColNum(int colNum) {
-    this.colNum = colNum;
-  }
-
-  @Override
   public String vectorExpressionParameters() {
-    return "col " + colNum;
+    return getColumnParamString(0, colNum);
   }
 
   @Override

http://git-wip-us.apache.org/repos/asf/hive/blob/e63ebccc/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/SelectColumnIsNull.java
----------------------------------------------------------------------
diff --git a/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/SelectColumnIsNull.java b/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/SelectColumnIsNull.java
index b792bbe..ffdd7fd 100644
--- a/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/SelectColumnIsNull.java
+++ b/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/SelectColumnIsNull.java
@@ -26,18 +26,22 @@ import org.apache.hadoop.hive.ql.exec.vector.VectorizedRowBatch;
  * This expression selects a row if the given column is null.
  */
 public class SelectColumnIsNull extends VectorExpression {
+
   private static final long serialVersionUID = 1L;
-  private int colNum;
+
+  private final int colNum;
 
   public SelectColumnIsNull(int colNum) {
-    this();
+    super();
     this.colNum = colNum;
   }
 
   public SelectColumnIsNull() {
     super();
-  }
 
+    // Dummy final assignments.
+    colNum = -1;
+  }
 
   @Override
   public void evaluate(VectorizedRowBatch batch) {
@@ -88,26 +92,8 @@ public class SelectColumnIsNull extends VectorExpression {
   }
 
   @Override
-  public int getOutputColumn() {
-    return -1;
-  }
-
-  @Override
-  public String getOutputType() {
-    return "boolean";
-  }
-
-  public int getColNum() {
-    return colNum;
-  }
-
-  public void setColNum(int colNum) {
-    this.colNum = colNum;
-  }
-
-  @Override
   public String vectorExpressionParameters() {
-    return "col " + colNum;
+    return getColumnParamString(0, colNum);
   }
 
   @Override

http://git-wip-us.apache.org/repos/asf/hive/blob/e63ebccc/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/SelectColumnIsTrue.java
----------------------------------------------------------------------
diff --git a/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/SelectColumnIsTrue.java b/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/SelectColumnIsTrue.java
index b58b49e..7292168 100644
--- a/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/SelectColumnIsTrue.java
+++ b/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/SelectColumnIsTrue.java
@@ -27,15 +27,19 @@ import org.apache.hadoop.hive.ql.exec.vector.VectorizedRowBatch;
  */
 public class SelectColumnIsTrue extends VectorExpression {
   private static final long serialVersionUID = 1L;
-  private int colNum1;
+
+  private final int colNum1;
 
   public SelectColumnIsTrue(int colNum1) {
-    this();
+    super();
     this.colNum1 = colNum1;
   }
 
   public SelectColumnIsTrue() {
     super();
+
+    // Dummy final assignments.
+    colNum1 = -1;
   }
 
   @Override
@@ -120,26 +124,8 @@ public class SelectColumnIsTrue extends VectorExpression {
   }
 
   @Override
-  public int getOutputColumn() {
-    return -1;
-  }
-
-  @Override
-  public String getOutputType() {
-    return "boolean";
-  }
-
-  public int getColNum1() {
-    return colNum1;
-  }
-
-  public void setColNum1(int colNum1) {
-    this.colNum1 = colNum1;
-  }
-
-  @Override
   public String vectorExpressionParameters() {
-    return "col " + colNum1;
+    return getColumnParamString(0, colNum1);
   }
 
   @Override

http://git-wip-us.apache.org/repos/asf/hive/blob/e63ebccc/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/SelectStringColLikeStringScalar.java
----------------------------------------------------------------------
diff --git a/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/SelectStringColLikeStringScalar.java b/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/SelectStringColLikeStringScalar.java
index 5ebd18d..17bdf97 100644
--- a/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/SelectStringColLikeStringScalar.java
+++ b/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/SelectStringColLikeStringScalar.java
@@ -30,21 +30,24 @@ import org.apache.hadoop.hive.ql.exec.vector.VectorizedRowBatch;
 public class SelectStringColLikeStringScalar extends VectorExpression {
 
   private static final long serialVersionUID = 1L;
-  
-  private int colNum;
-  private int outputColumn;
+
+  private final int colNum;
+
   private byte[] pattern;
+
   transient Checker checker = null;
 
   public SelectStringColLikeStringScalar() {
     super();
+
+    // Dummy final assignments.
+    colNum = -1;
   }
 
-  public SelectStringColLikeStringScalar(int colNum, byte[] pattern, int outputColumn) {
-    super();
+  public SelectStringColLikeStringScalar(int colNum, byte[] pattern, int outputColumnNum) {
+    super(outputColumnNum);
     this.colNum = colNum;
     this.pattern = pattern;
-    this.outputColumn = outputColumn;
   }
 
   @Override
@@ -64,18 +67,18 @@ public class SelectStringColLikeStringScalar extends VectorExpression {
     byte[][] vector = inputColVector.vector;
     int[] length = inputColVector.length;
     int[] start = inputColVector.start;
-    
-    LongColumnVector outV = (LongColumnVector) batch.cols[outputColumn];
+
+    LongColumnVector outV = (LongColumnVector) batch.cols[outputColumnNum];
     long[] outputVector = outV.vector;
-    
+
     // return immediately if batch is empty
     if (n == 0) {
       return;
     }
-    
+
     outV.noNulls = inputColVector.noNulls;
     outV.isRepeating = inputColVector.isRepeating;
-    
+
     if (inputColVector.noNulls) {
       if (inputColVector.isRepeating) {
         outputVector[0] = (checker.check(vector[0], start[0], length[0]) ? 1 : 0);
@@ -126,58 +129,31 @@ public class SelectStringColLikeStringScalar extends VectorExpression {
       }
     }
 	}
-  
+
   private Checker borrowChecker() {
     FilterStringColLikeStringScalar fil = new FilterStringColLikeStringScalar();
     return fil.createChecker(new String(pattern, StandardCharsets.UTF_8));
   }
 
-  public int getColNum() {
-    return colNum;
-  }
-
-  public void setColNum(int colNum) {
-    this.colNum = colNum;
-  }
-
-  public byte[] getPattern() {
-    return pattern;
-  }
-
   public void setPattern(byte[] pattern) {
     this.pattern = pattern;
   }
 
-  public void setOutputColumn(int outputColumn) {
-    this.outputColumn = outputColumn;
-  }
-  
-  @Override
-  public int getOutputColumn() {
-    return outputColumn;
-  }
-  
-  @Override
-  public String getOutputType() {
-    return "String_Family";
-  }
-
   public String vectorExpressionParameters() {
-    return "col " + colNum;
+    return getColumnParamString(0, colNum);
   }
 
-@Override
-public Descriptor getDescriptor() {
-    return (new VectorExpressionDescriptor.Builder())
-        .setMode(
-            VectorExpressionDescriptor.Mode.PROJECTION)
-        .setNumArguments(2)
-        .setArgumentTypes(
-            VectorExpressionDescriptor.ArgumentType.STRING_FAMILY,
-            VectorExpressionDescriptor.ArgumentType.STRING)
-        .setInputExpressionTypes(
-            VectorExpressionDescriptor.InputExpressionType.COLUMN,
-            VectorExpressionDescriptor.InputExpressionType.SCALAR).build();
-}
-
+  @Override
+  public Descriptor getDescriptor() {
+      return (new VectorExpressionDescriptor.Builder())
+          .setMode(
+              VectorExpressionDescriptor.Mode.PROJECTION)
+          .setNumArguments(2)
+          .setArgumentTypes(
+              VectorExpressionDescriptor.ArgumentType.STRING_FAMILY,
+              VectorExpressionDescriptor.ArgumentType.STRING)
+          .setInputExpressionTypes(
+              VectorExpressionDescriptor.InputExpressionType.COLUMN,
+              VectorExpressionDescriptor.InputExpressionType.SCALAR).build();
+  }
 }

http://git-wip-us.apache.org/repos/asf/hive/blob/e63ebccc/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/StringColumnInList.java
----------------------------------------------------------------------
diff --git a/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/StringColumnInList.java b/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/StringColumnInList.java
index b1ceb9a..191047a7 100644
--- a/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/StringColumnInList.java
+++ b/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/StringColumnInList.java
@@ -39,8 +39,7 @@ import java.util.regex.Pattern;
  */
 public class StringColumnInList extends VectorExpression implements IStringInExpr {
   private static final long serialVersionUID = 1L;
-  private int inputCol;
-  private int outputColumn;
+  protected int inputCol;
   private byte[][] inListValues;
 
   // The set object containing the IN list. This is optimized for lookup
@@ -49,15 +48,14 @@ public class StringColumnInList extends VectorExpression implements IStringInExp
 
   public StringColumnInList() {
     super();
-    inSet = null;
   }
 
   /**
    * After construction you must call setInListValues() to add the values to the IN set.
    */
-  public StringColumnInList(int colNum, int outputColumn) {
+  public StringColumnInList(int colNum, int outputColumnNum) {
+    super(outputColumnNum);
     this.inputCol = colNum;
-    this.outputColumn = outputColumn;
     inSet = null;
   }
 
@@ -74,7 +72,7 @@ public class StringColumnInList extends VectorExpression implements IStringInExp
     }
 
     BytesColumnVector inputColVector = (BytesColumnVector) batch.cols[inputCol];
-    LongColumnVector outputColVector = (LongColumnVector) batch.cols[outputColumn];
+    LongColumnVector outputColVector = (LongColumnVector) batch.cols[outputColumnNum];
     int[] sel = batch.selected;
     boolean[] nullPos = inputColVector.isNull;
     int n = batch.size;
@@ -134,33 +132,6 @@ public class StringColumnInList extends VectorExpression implements IStringInExp
     }
   }
 
-
-  @Override
-  public String getOutputType() {
-    return "boolean";
-  }
-
-  public void setInputColumn(int inputCol) {
-    this.inputCol = inputCol;
-  }
-
-  @Override
-  public int getOutputColumn() {
-    return this.outputColumn;
-  }
-
-  public void setOutputColumn(int value) {
-    this.outputColumn = value;
-  }
-
-  public int getInputCol() {
-    return inputCol;
-  }
-
-  public void setInputCol(int colNum) {
-    this.inputCol = colNum;
-  }
-
   @Override
   public Descriptor getDescriptor() {
 
@@ -168,16 +139,12 @@ public class StringColumnInList extends VectorExpression implements IStringInExp
     return null;
   }
 
-  public byte[][] getInListValues() {
-    return this.inListValues;
-  }
-
   public void setInListValues(byte [][] a) {
     this.inListValues = a;
   }
 
   @Override
   public String vectorExpressionParameters() {
-    return "col " + inputCol + ", values " + Arrays.toString(inListValues);
+    return getColumnParamString(0, inputCol) + ", values " + Arrays.toString(inListValues);
   }
 }

http://git-wip-us.apache.org/repos/asf/hive/blob/e63ebccc/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/StringGroupColConcatCharScalar.java
----------------------------------------------------------------------
diff --git a/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/StringGroupColConcatCharScalar.java b/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/StringGroupColConcatCharScalar.java
index 3708654..f82a7a2 100644
--- a/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/StringGroupColConcatCharScalar.java
+++ b/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/StringGroupColConcatCharScalar.java
@@ -28,8 +28,8 @@ import org.apache.hadoop.hive.ql.exec.vector.VectorExpressionDescriptor;
 public class StringGroupColConcatCharScalar extends StringGroupColConcatStringScalar {
   private static final long serialVersionUID = 1L;
 
-  public StringGroupColConcatCharScalar(int colNum, HiveChar value, int outputColumn) {
-    super(colNum, value.getStrippedValue().getBytes(), outputColumn);
+  public StringGroupColConcatCharScalar(int colNum, HiveChar value, int outputColumnNum) {
+    super(colNum, value.getStrippedValue().getBytes(), outputColumnNum);
   }
 
   public StringGroupColConcatCharScalar() {

http://git-wip-us.apache.org/repos/asf/hive/blob/e63ebccc/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/StringGroupColConcatStringScalar.java
----------------------------------------------------------------------
diff --git a/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/StringGroupColConcatStringScalar.java b/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/StringGroupColConcatStringScalar.java
index f1c40c2..b544b39 100644
--- a/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/StringGroupColConcatStringScalar.java
+++ b/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/StringGroupColConcatStringScalar.java
@@ -30,19 +30,22 @@ import org.apache.hadoop.hive.ql.exec.vector.VectorizedRowBatch;
  */
 public class StringGroupColConcatStringScalar extends VectorExpression {
   private static final long serialVersionUID = 1L;
-  private int colNum;
-  private int outputColumn;
-  private byte[] value;
 
-  public StringGroupColConcatStringScalar(int colNum, byte[] value, int outputColumn) {
-    this();
+  private final int colNum;
+  private final byte[] value;
+
+  public StringGroupColConcatStringScalar(int colNum, byte[] value, int outputColumnNum) {
+    super(outputColumnNum);
     this.colNum = colNum;
-    this.outputColumn = outputColumn;
     this.value = value;
   }
 
   public StringGroupColConcatStringScalar() {
     super();
+
+    // Dummy final assignments.
+    colNum = -1;
+    value = null;
   }
 
   @Override
@@ -53,7 +56,7 @@ public class StringGroupColConcatStringScalar extends VectorExpression {
     }
 
     BytesColumnVector inputColVector = (BytesColumnVector) batch.cols[colNum];
-    BytesColumnVector outV = (BytesColumnVector) batch.cols[outputColumn];
+    BytesColumnVector outV = (BytesColumnVector) batch.cols[outputColumnNum];
     int[] sel = batch.selected;
     int n = batch.size;
     byte[][] vector = inputColVector.vector;
@@ -121,38 +124,8 @@ public class StringGroupColConcatStringScalar extends VectorExpression {
   }
 
   @Override
-  public int getOutputColumn() {
-    return outputColumn;
-  }
-
-  @Override
-  public String getOutputType() {
-    return "String_Family";
-  }
-
-  public int getColNum() {
-    return colNum;
-  }
-
-  public void setColNum(int colNum) {
-    this.colNum = colNum;
-  }
-
-  public byte[] getValue() {
-    return value;
-  }
-
-  public void setValue(byte[] value) {
-    this.value = value;
-  }
-
-  public void setOutputColumn(int outputColumn) {
-    this.outputColumn = outputColumn;
-  }
-
-  @Override
   public String vectorExpressionParameters() {
-    return "col " + colNum + ", val " + displayUtf8Bytes(value);
+    return getColumnParamString(0, colNum) + ", val " + displayUtf8Bytes(value);
   }
 
   @Override

http://git-wip-us.apache.org/repos/asf/hive/blob/e63ebccc/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/StringGroupColConcatVarCharScalar.java
----------------------------------------------------------------------
diff --git a/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/StringGroupColConcatVarCharScalar.java b/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/StringGroupColConcatVarCharScalar.java
index 7a1d8a3..4c1b55d 100644
--- a/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/StringGroupColConcatVarCharScalar.java
+++ b/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/StringGroupColConcatVarCharScalar.java
@@ -28,8 +28,8 @@ import org.apache.hadoop.hive.ql.exec.vector.VectorExpressionDescriptor;
 public class StringGroupColConcatVarCharScalar extends StringGroupColConcatStringScalar {
   private static final long serialVersionUID = 1L;
 
-  public StringGroupColConcatVarCharScalar(int colNum, HiveVarchar value, int outputColumn) {
-    super(colNum, value.getValue().getBytes(), outputColumn);
+  public StringGroupColConcatVarCharScalar(int colNum, HiveVarchar value, int outputColumnNum) {
+    super(colNum, value.getValue().getBytes(), outputColumnNum);
   }
 
   public StringGroupColConcatVarCharScalar() {

http://git-wip-us.apache.org/repos/asf/hive/blob/e63ebccc/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/StringGroupConcatColCol.java
----------------------------------------------------------------------
diff --git a/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/StringGroupConcatColCol.java b/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/StringGroupConcatColCol.java
index 35666d8..4c02ff1 100644
--- a/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/StringGroupConcatColCol.java
+++ b/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/StringGroupConcatColCol.java
@@ -29,19 +29,22 @@ import org.apache.hadoop.hive.ql.exec.vector.VectorizedRowBatch;
  */
 public class StringGroupConcatColCol extends VectorExpression {
   private static final long serialVersionUID = 1L;
-  private int colNum1;
-  private int colNum2;
-  private int outputColumn;
 
-  public StringGroupConcatColCol(int colNum1, int colNum2, int outputColumn) {
-    this();
+  private final int colNum1;
+  private final int colNum2;
+
+  public StringGroupConcatColCol(int colNum1, int colNum2, int outputColumnNum) {
+    super(outputColumnNum);
     this.colNum1 = colNum1;
     this.colNum2 = colNum2;
-    this.outputColumn = outputColumn;
   }
 
   public StringGroupConcatColCol() {
     super();
+
+    // Dummy final assignments.
+    colNum1 = -1;
+    colNum2 = -1;
   }
 
   @Override
@@ -53,7 +56,7 @@ public class StringGroupConcatColCol extends VectorExpression {
 
     BytesColumnVector inV1 = (BytesColumnVector) batch.cols[colNum1];
     BytesColumnVector inV2 = (BytesColumnVector) batch.cols[colNum2];
-    BytesColumnVector outV = (BytesColumnVector) batch.cols[outputColumn];
+    BytesColumnVector outV = (BytesColumnVector) batch.cols[outputColumnNum];
     int[] sel = batch.selected;
     int n = batch.size;
     byte[][] vector1 = inV1.vector;
@@ -410,38 +413,8 @@ public class StringGroupConcatColCol extends VectorExpression {
   }
 
   @Override
-  public int getOutputColumn() {
-    return outputColumn;
-  }
-
-  @Override
-  public String getOutputType() {
-    return "String_Family";
-  }
-
-  public int getColNum1() {
-    return colNum1;
-  }
-
-  public void setColNum1(int colNum1) {
-    this.colNum1 = colNum1;
-  }
-
-  public int getColNum2() {
-    return colNum2;
-  }
-
-  public void setColNum2(int colNum2) {
-    this.colNum2 = colNum2;
-  }
-
-  public void setOutputColumn(int outputColumn) {
-    this.outputColumn = outputColumn;
-  }
-
-  @Override
   public String vectorExpressionParameters() {
-    return "col " + colNum1 + ", col " + colNum2;
+    return getColumnParamString(0, colNum1) + ", " + getColumnParamString(1, colNum2);
   }
 
   @Override

http://git-wip-us.apache.org/repos/asf/hive/blob/e63ebccc/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/StringHex.java
----------------------------------------------------------------------
diff --git a/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/StringHex.java b/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/StringHex.java
index 0e7384d..b8b9204 100644
--- a/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/StringHex.java
+++ b/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/StringHex.java
@@ -23,7 +23,7 @@ import org.apache.hadoop.hive.ql.udf.UDFHex;
 
 // Implement vectorized function Hex(string) returning string
 public class StringHex extends StringUnaryUDF {
-  StringHex(int colNum, int outputColumn) {
-    super(colNum, outputColumn, (IUDFUnaryString) new UDFHex());
+  StringHex(int colNum, int outputColumnNum) {
+    super(colNum, outputColumnNum, (IUDFUnaryString) new UDFHex());
   }
 }

http://git-wip-us.apache.org/repos/asf/hive/blob/e63ebccc/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/StringInitCap.java
----------------------------------------------------------------------
diff --git a/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/StringInitCap.java b/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/StringInitCap.java
index ff46ab7..3156599 100644
--- a/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/StringInitCap.java
+++ b/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/StringInitCap.java
@@ -30,8 +30,8 @@ import org.apache.hadoop.io.Text;
 public class StringInitCap extends StringUnaryUDF {
   private static final long serialVersionUID = 1L;
 
-  public StringInitCap(int colNum, int outputColumn) {
-    super(colNum, outputColumn, new IUDFUnaryString() {
+  public StringInitCap(int colNum, int outputColumnNum) {
+    super(colNum, outputColumnNum, new IUDFUnaryString() {
 
       Text t = new Text();
 

http://git-wip-us.apache.org/repos/asf/hive/blob/e63ebccc/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/StringLTrim.java
----------------------------------------------------------------------
diff --git a/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/StringLTrim.java b/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/StringLTrim.java
index 7e9b36a..231fabb 100644
--- a/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/StringLTrim.java
+++ b/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/StringLTrim.java
@@ -23,8 +23,8 @@ import org.apache.hadoop.hive.ql.exec.vector.BytesColumnVector;
 public class StringLTrim extends StringUnaryUDFDirect {
   private static final long serialVersionUID = 1L;
 
-  public StringLTrim(int inputColumn, int outputColumn) {
-    super(inputColumn, outputColumn);
+  public StringLTrim(int inputColumn, int outputColumnNum) {
+    super(inputColumn, outputColumnNum);
   }
 
   public StringLTrim() {

http://git-wip-us.apache.org/repos/asf/hive/blob/e63ebccc/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/StringLength.java
----------------------------------------------------------------------
diff --git a/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/StringLength.java b/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/StringLength.java
index cdaf694..a0ee858 100644
--- a/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/StringLength.java
+++ b/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/StringLength.java
@@ -29,17 +29,19 @@ import org.apache.hadoop.hive.ql.exec.vector.VectorizedRowBatch;
  */
 public class StringLength extends VectorExpression {
   private static final long serialVersionUID = 1L;
-  private int colNum;
-  private int outputColumn;
 
-  public StringLength(int colNum, int outputColumn) {
-    this();
+  private final int colNum;
+
+  public StringLength(int colNum, int outputColumnNum) {
+    super(outputColumnNum);
     this.colNum = colNum;
-    this.outputColumn = outputColumn;
   }
 
   public StringLength() {
     super();
+
+    // Dummy final assignments.
+    colNum = -1;
   }
 
   // Calculate the length of the UTF-8 strings in input vector and place results in output vector.
@@ -51,7 +53,7 @@ public class StringLength extends VectorExpression {
     }
 
     BytesColumnVector inputColVector = (BytesColumnVector) batch.cols[colNum];
-    LongColumnVector outV = (LongColumnVector) batch.cols[outputColumn];
+    LongColumnVector outV = (LongColumnVector) batch.cols[outputColumnNum];
     int[] sel = batch.selected;
     int n = batch.size;
     byte[][] vector = inputColVector.vector;
@@ -134,30 +136,8 @@ public class StringLength extends VectorExpression {
     return resultLength;
   }
 
-  @Override
-  public int getOutputColumn() {
-    return outputColumn;
-  }
-
-  @Override
-  public String getOutputType() {
-    return "Long";
-  }
-
-  public int getColNum() {
-    return colNum;
-  }
-
-  public void setColNum(int colNum) {
-    this.colNum = colNum;
-  }
-
-  public void setOutputColumn(int outputColumn) {
-    this.outputColumn = outputColumn;
-  }
-
   public String vectorExpressionParameters() {
-    return "col " + colNum;
+    return getColumnParamString(0, colNum);
   }
 
   @Override

http://git-wip-us.apache.org/repos/asf/hive/blob/e63ebccc/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/StringLower.java
----------------------------------------------------------------------
diff --git a/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/StringLower.java b/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/StringLower.java
index ee0182b..945ff1d 100644
--- a/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/StringLower.java
+++ b/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/StringLower.java
@@ -27,8 +27,8 @@ import org.apache.hadoop.io.Text;
 public class StringLower extends StringUnaryUDF {
   private static final long serialVersionUID = 1L;
 
-  public StringLower(int colNum, int outputColumn) {
-    super(colNum, outputColumn, new IUDFUnaryString() {
+  public StringLower(int colNum, int outputColumnNum) {
+    super(colNum, outputColumnNum, new IUDFUnaryString() {
 
       private final Text t = new Text();
 

http://git-wip-us.apache.org/repos/asf/hive/blob/e63ebccc/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/StringRTrim.java
----------------------------------------------------------------------
diff --git a/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/StringRTrim.java b/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/StringRTrim.java
index 94821a1..85ba424 100644
--- a/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/StringRTrim.java
+++ b/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/StringRTrim.java
@@ -23,8 +23,8 @@ import org.apache.hadoop.hive.ql.exec.vector.BytesColumnVector;
 public class StringRTrim extends StringUnaryUDFDirect {
   private static final long serialVersionUID = 1L;
 
-  public StringRTrim(int inputColumn, int outputColumn) {
-    super(inputColumn, outputColumn);
+  public StringRTrim(int inputColumn, int outputColumnNum) {
+    super(inputColumn, outputColumnNum);
   }
 
   public StringRTrim() {

http://git-wip-us.apache.org/repos/asf/hive/blob/e63ebccc/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/StringScalarConcatStringGroupCol.java
----------------------------------------------------------------------
diff --git a/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/StringScalarConcatStringGroupCol.java b/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/StringScalarConcatStringGroupCol.java
index a72a7df..97d817c 100644
--- a/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/StringScalarConcatStringGroupCol.java
+++ b/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/StringScalarConcatStringGroupCol.java
@@ -30,19 +30,22 @@ import org.apache.hadoop.hive.ql.exec.vector.VectorizedRowBatch;
  */
 public class StringScalarConcatStringGroupCol extends VectorExpression {
   private static final long serialVersionUID = 1L;
-  private int colNum;
-  private int outputColumn;
-  private byte[] value;
 
-  public StringScalarConcatStringGroupCol(byte[] value, int colNum, int outputColumn) {
-    this();
+  private final int colNum;
+  private final byte[] value;
+
+  public StringScalarConcatStringGroupCol(byte[] value, int colNum, int outputColumnNum) {
+    super(outputColumnNum);
     this.colNum = colNum;
-    this.outputColumn = outputColumn;
     this.value = value;
   }
 
   public StringScalarConcatStringGroupCol() {
     super();
+
+    // Dummy final assignments.
+    colNum = -1;
+    value = null;
   }
 
   @Override
@@ -53,7 +56,7 @@ public class StringScalarConcatStringGroupCol extends VectorExpression {
       }
 
     BytesColumnVector inputColVector = (BytesColumnVector) batch.cols[colNum];
-    BytesColumnVector outV = (BytesColumnVector) batch.cols[outputColumn];
+    BytesColumnVector outV = (BytesColumnVector) batch.cols[outputColumnNum];
     int[] sel = batch.selected;
     int n = batch.size;
     byte[][] vector = inputColVector.vector;
@@ -121,38 +124,8 @@ public class StringScalarConcatStringGroupCol extends VectorExpression {
   }
 
   @Override
-  public int getOutputColumn() {
-    return outputColumn;
-  }
-
-  @Override
-  public String getOutputType() {
-    return "String_Family";
-  }
-
-  public int getColNum() {
-    return colNum;
-  }
-
-  public void setColNum(int colNum) {
-    this.colNum = colNum;
-  }
-
-  public byte[] getValue() {
-    return value;
-  }
-
-  public void setValue(byte[] value) {
-    this.value = value;
-  }
-
-  public void setOutputColumn(int outputColumn) {
-    this.outputColumn = outputColumn;
-  }
-
-  @Override
   public String vectorExpressionParameters() {
-    return "val " + displayUtf8Bytes(value) + ", col " + colNum;
+    return "val " + displayUtf8Bytes(value) + ", " + getColumnParamString(1, colNum);
   }
 
   @Override

http://git-wip-us.apache.org/repos/asf/hive/blob/e63ebccc/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/StringSubstrColStart.java
----------------------------------------------------------------------
diff --git a/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/StringSubstrColStart.java b/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/StringSubstrColStart.java
index 305d1a7..e8cf945 100644
--- a/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/StringSubstrColStart.java
+++ b/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/StringSubstrColStart.java
@@ -31,9 +31,11 @@ import org.apache.hadoop.hive.ql.exec.vector.VectorizedRowBatch;
  */
 public class StringSubstrColStart extends VectorExpression {
   private static final long serialVersionUID = 1L;
+
+  private final int colNum;
+
   private int startIdx;
-  private int colNum;
-  private int outputColumn;
+
   private transient static byte[] EMPTY_STRING;
 
   // Populating the Empty string bytes. Putting it as static since it should be immutable and can
@@ -46,8 +48,8 @@ public class StringSubstrColStart extends VectorExpression {
     }
   }
 
-  public StringSubstrColStart(int colNum, int startIdx, int outputColumn) {
-    this();
+  public StringSubstrColStart(int colNum, int startIdx, int outputColumnNum) {
+    super(outputColumnNum);
     this.colNum = colNum;
 
     /* Switch from a 1-based start offset (the Hive end user convention) to a 0-based start offset
@@ -65,11 +67,14 @@ public class StringSubstrColStart extends VectorExpression {
       // start index of -n means give the last n characters of the string
       this.startIdx = startIdx;
     }
-    this.outputColumn = outputColumn;
   }
 
   public StringSubstrColStart() {
     super();
+
+    // Dummy final assignments.
+    colNum = -1;
+    startIdx = -1;
   }
 
   /**
@@ -120,7 +125,7 @@ public class StringSubstrColStart extends VectorExpression {
     }
 
     BytesColumnVector inV = (BytesColumnVector) batch.cols[colNum];
-    BytesColumnVector outV = (BytesColumnVector) batch.cols[outputColumn];
+    BytesColumnVector outV = (BytesColumnVector) batch.cols[outputColumnNum];
 
     int n = batch.size;
 
@@ -215,38 +220,8 @@ public class StringSubstrColStart extends VectorExpression {
   }
 
   @Override
-  public int getOutputColumn() {
-    return outputColumn;
-  }
-
-  @Override
-  public String getOutputType() {
-    return "string";
-  }
-
-  public int getStartIdx() {
-    return startIdx;
-  }
-
-  public void setStartIdx(int startIdx) {
-    this.startIdx = startIdx;
-  }
-
-  public int getColNum() {
-    return colNum;
-  }
-
-  public void setColNum(int colNum) {
-    this.colNum = colNum;
-  }
-
-  public void setOutputColumn(int outputColumn) {
-    this.outputColumn = outputColumn;
-  }
-
-  @Override
   public String vectorExpressionParameters() {
-    return "col " + colNum + ", start " + startIdx;
+    return getColumnParamString(0, colNum) + ", start " + startIdx;
   }
 
   @Override

http://git-wip-us.apache.org/repos/asf/hive/blob/e63ebccc/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/StringSubstrColStartLen.java
----------------------------------------------------------------------
diff --git a/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/StringSubstrColStartLen.java b/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/StringSubstrColStartLen.java
index 4a7dbdc..597bc38 100644
--- a/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/StringSubstrColStartLen.java
+++ b/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/StringSubstrColStartLen.java
@@ -33,11 +33,13 @@ import org.apache.hadoop.hive.ql.exec.vector.VectorizedRowBatch;
  */
 public class StringSubstrColStartLen extends VectorExpression {
   private static final long serialVersionUID = 1L;
-  private int startIdx;
-  private int colNum;
-  private int length;
-  private int outputColumn;
-  private transient final int[] offsetArray;
+
+  private final int colNum;
+
+  private final int startIdx;
+  private final int length;
+  private final int[] offsetArray;
+
   private transient static byte[] EMPTY_STRING;
 
   // Populating the Empty string bytes. Putting it as static since it should be immutable and can be
@@ -50,9 +52,10 @@ public class StringSubstrColStartLen extends VectorExpression {
     }
   }
 
-  public StringSubstrColStartLen(int colNum, int startIdx, int length, int outputColumn) {
-    this();
+  public StringSubstrColStartLen(int colNum, int startIdx, int length, int outputColumnNum) {
+    super(outputColumnNum);
     this.colNum = colNum;
+    offsetArray = new int[2];
 
     /* Switch from a 1-based start offset (the Hive end user convention) to a 0-based start offset
      * (the internal convention).
@@ -71,12 +74,16 @@ public class StringSubstrColStartLen extends VectorExpression {
     }
 
     this.length = length;
-    this.outputColumn = outputColumn;
   }
 
   public StringSubstrColStartLen() {
     super();
-    offsetArray = new int[2];
+
+    // Dummy final assignments.
+    colNum = -1;
+    startIdx = -1;
+    length = 0;
+    offsetArray = null;
   }
 
   /**
@@ -139,7 +146,7 @@ public class StringSubstrColStartLen extends VectorExpression {
     }
 
     BytesColumnVector inV = (BytesColumnVector) batch.cols[colNum];
-    BytesColumnVector outV = (BytesColumnVector) batch.cols[outputColumn];
+    BytesColumnVector outV = (BytesColumnVector) batch.cols[outputColumnNum];
 
     int n = batch.size;
 
@@ -234,46 +241,8 @@ public class StringSubstrColStartLen extends VectorExpression {
   }
 
   @Override
-  public int getOutputColumn() {
-    return outputColumn;
-  }
-
-  @Override
-  public String getOutputType() {
-    return "string";
-  }
-
-  public int getStartIdx() {
-    return startIdx;
-  }
-
-  public void setStartIdx(int startIdx) {
-    this.startIdx = startIdx;
-  }
-
-  public int getColNum() {
-    return colNum;
-  }
-
-  public void setColNum(int colNum) {
-    this.colNum = colNum;
-  }
-
-  public int getLength() {
-    return length;
-  }
-
-  public void setLength(int length) {
-    this.length = length;
-  }
-
-  public void setOutputColumn(int outputColumn) {
-    this.outputColumn = outputColumn;
-  }
-
-  @Override
   public String vectorExpressionParameters() {
-    return "col " + colNum + ", start " + startIdx + ", length " + length;
+    return getColumnParamString(0, colNum) + ", start " + startIdx + ", length " + length;
   }
 
   @Override

http://git-wip-us.apache.org/repos/asf/hive/blob/e63ebccc/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/StringTrim.java
----------------------------------------------------------------------
diff --git a/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/StringTrim.java b/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/StringTrim.java
index 88504f8..9706666 100644
--- a/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/StringTrim.java
+++ b/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/StringTrim.java
@@ -23,8 +23,8 @@ import org.apache.hadoop.hive.ql.exec.vector.BytesColumnVector;
 public class StringTrim extends StringUnaryUDFDirect {
   private static final long serialVersionUID = 1L;
 
-  public StringTrim(int inputColumn, int outputColumn) {
-    super(inputColumn, outputColumn);
+  public StringTrim(int inputColumn, int outputColumnNum) {
+    super(inputColumn, outputColumnNum);
   }
 
   public StringTrim() {

http://git-wip-us.apache.org/repos/asf/hive/blob/e63ebccc/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/StringUnaryUDF.java
----------------------------------------------------------------------
diff --git a/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/StringUnaryUDF.java b/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/StringUnaryUDF.java
index 527d3b3..2a4ac43 100644
--- a/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/StringUnaryUDF.java
+++ b/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/StringUnaryUDF.java
@@ -37,21 +37,25 @@ public class StringUnaryUDF extends VectorExpression {
   }
 
   private static final long serialVersionUID = 1L;
-  private int colNum;
-  private int outputColumn;
-  private IUDFUnaryString func;
-  private transient final Text s;
 
-  StringUnaryUDF(int colNum, int outputColumn, IUDFUnaryString func) {
-    this();
+  private final int colNum;
+  private final IUDFUnaryString func;
+
+  private Text s;
+
+  StringUnaryUDF(int colNum, int outputColumnNum, IUDFUnaryString func) {
+    super(outputColumnNum);
     this.colNum = colNum;
-    this.outputColumn = outputColumn;
     this.func = func;
+    s = new Text();
   }
 
   public StringUnaryUDF() {
     super();
-    s = new Text();
+
+    // Dummy final assignments.
+    colNum = -1;
+    func = null;
   }
 
   @Override
@@ -67,7 +71,7 @@ public class StringUnaryUDF extends VectorExpression {
     byte[][] vector = inputColVector.vector;
     int [] start = inputColVector.start;
     int [] length = inputColVector.length;
-    BytesColumnVector outV = (BytesColumnVector) batch.cols[outputColumn];
+    BytesColumnVector outV = (BytesColumnVector) batch.cols[outputColumnNum];
     outV.initBuffer();
     Text t;
 
@@ -165,38 +169,8 @@ public class StringUnaryUDF extends VectorExpression {
   }
 
   @Override
-  public int getOutputColumn() {
-    return outputColumn;
-  }
-
-  @Override
-  public String getOutputType() {
-    return "String";
-  }
-
-  public int getColNum() {
-    return colNum;
-  }
-
-  public void setColNum(int colNum) {
-    this.colNum = colNum;
-  }
-
-  public IUDFUnaryString getFunc() {
-    return func;
-  }
-
-  public void setFunc(IUDFUnaryString func) {
-    this.func = func;
-  }
-
-  public void setOutputColumn(int outputColumn) {
-    this.outputColumn = outputColumn;
-  }
-
-  @Override
   public String vectorExpressionParameters() {
-    return "col " + colNum;
+    return getColumnParamString(0, colNum);
   }
 
   @Override

http://git-wip-us.apache.org/repos/asf/hive/blob/e63ebccc/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/StringUnaryUDFDirect.java
----------------------------------------------------------------------
diff --git a/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/StringUnaryUDFDirect.java b/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/StringUnaryUDFDirect.java
index c87371f..e01ca55 100644
--- a/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/StringUnaryUDFDirect.java
+++ b/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/StringUnaryUDFDirect.java
@@ -29,16 +29,19 @@ import org.apache.hadoop.hive.ql.exec.vector.VectorizedRowBatch;
  */
 abstract public class StringUnaryUDFDirect extends VectorExpression {
   private static final long serialVersionUID = 1L;
-  int inputColumn;
-  int outputColumn;
 
-  public StringUnaryUDFDirect(int inputColumn, int outputColumn) {
+  protected final int inputColumn;
+
+  public StringUnaryUDFDirect(int inputColumn, int outputColumnNum) {
+    super(outputColumnNum);
     this.inputColumn = inputColumn;
-    this.outputColumn = outputColumn;
   }
 
   public StringUnaryUDFDirect() {
     super();
+
+    // Dummy final assignments.
+    inputColumn = -1;
   }
 
   abstract protected void func(BytesColumnVector outV, byte[][] vector, int[] start, int[] length, int i);
@@ -56,7 +59,7 @@ abstract public class StringUnaryUDFDirect extends VectorExpression {
     byte[][] vector = inputColVector.vector;
     int start[] = inputColVector.start;
     int length[] = inputColVector.length;
-    BytesColumnVector outV = (BytesColumnVector) batch.cols[outputColumn];
+    BytesColumnVector outV = (BytesColumnVector) batch.cols[outputColumnNum];
     outV.initBuffer();
 
     if (n == 0) {
@@ -113,31 +116,8 @@ abstract public class StringUnaryUDFDirect extends VectorExpression {
     }
   }
 
-
-  @Override
-  public int getOutputColumn() {
-    return outputColumn;
-  }
-
-  public void setOutputColumn(int outputColumn) {
-    this.outputColumn = outputColumn;
-  }
-
-  public int getInputColumn() {
-    return inputColumn;
-  }
-
-  public void setInputColumn(int inputColumn) {
-    this.inputColumn = inputColumn;
-  }
-
-  @Override
-  public String getOutputType() {
-    return "String";
-  }
-
   public String vectorExpressionParameters() {
-    return "col " + inputColumn;
+    return getColumnParamString(0, inputColumn);
   }
 
   @Override

http://git-wip-us.apache.org/repos/asf/hive/blob/e63ebccc/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/StringUpper.java
----------------------------------------------------------------------
diff --git a/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/StringUpper.java b/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/StringUpper.java
index 9ceae4d..ca8252b 100644
--- a/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/StringUpper.java
+++ b/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/StringUpper.java
@@ -27,8 +27,8 @@ import org.apache.hadoop.io.Text;
 public class StringUpper extends StringUnaryUDF {
   private static final long serialVersionUID = 1L;
 
-  public StringUpper(int colNum, int outputColumn) {
-    super(colNum, outputColumn, new IUDFUnaryString() {
+  public StringUpper(int colNum, int outputColumnNum) {
+    super(colNum, outputColumnNum, new IUDFUnaryString() {
 
       Text t = new Text();
 

http://git-wip-us.apache.org/repos/asf/hive/blob/e63ebccc/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/StructColumnInList.java
----------------------------------------------------------------------
diff --git a/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/StructColumnInList.java b/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/StructColumnInList.java
index 7d25446..901a1a8 100644
--- a/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/StructColumnInList.java
+++ b/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/StructColumnInList.java
@@ -42,6 +42,7 @@ import org.apache.hadoop.hive.serde2.binarysortable.fast.BinarySortableSerialize
  */
 public class StructColumnInList extends StringColumnInList implements IStructInExpr {
   private static final long serialVersionUID = 1L;
+
   private VectorExpression[] structExpressions;
   private ColumnVector.Type[] fieldVectorColumnTypes;
   private int[] structColumnMap;
@@ -57,8 +58,8 @@ public class StructColumnInList extends StringColumnInList implements IStructInE
   /**
    * After construction you must call setInListValues() to add the values to the IN set.
    */
-  public StructColumnInList(int outputColumn) {
-    super(-1, outputColumn);
+  public StructColumnInList(int outputColumnNum) {
+    super(-1, outputColumnNum);
   }
 
   @Override
@@ -137,12 +138,6 @@ public class StructColumnInList extends StringColumnInList implements IStructInE
     }
    }
 
-
-  @Override
-  public String getOutputType() {
-    return "boolean";
-  }
-
   @Override
   public Descriptor getDescriptor() {
 
@@ -156,7 +151,7 @@ public class StructColumnInList extends StringColumnInList implements IStructInE
 
     // Tell our super class FilterStringColumnInList it will be evaluating our scratch
     // BytesColumnVector.
-    super.setInputColumn(scratchBytesColumn);
+    inputCol = scratchBytesColumn;
     this.scratchBytesColumn = scratchBytesColumn;
   }
 
@@ -169,7 +164,7 @@ public class StructColumnInList extends StringColumnInList implements IStructInE
     structColumnMap = new int[structExpressions.length];
     for (int i = 0; i < structColumnMap.length; i++) {
       VectorExpression ve = structExpressions[i];
-      structColumnMap[i] = ve.getOutputColumn();
+      structColumnMap[i] = ve.getOutputColumnNum();
     }
     this.fieldVectorColumnTypes = fieldVectorColumnTypes;
   }

http://git-wip-us.apache.org/repos/asf/hive/blob/e63ebccc/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/TimestampColumnInList.java
----------------------------------------------------------------------
diff --git a/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/TimestampColumnInList.java b/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/TimestampColumnInList.java
index 5e76de8..5636c94 100644
--- a/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/TimestampColumnInList.java
+++ b/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/TimestampColumnInList.java
@@ -32,24 +32,27 @@ import org.apache.hadoop.hive.ql.exec.vector.VectorizedRowBatch;
  */
 public class TimestampColumnInList extends VectorExpression implements ITimestampInExpr {
   private static final long serialVersionUID = 1L;
-  private int inputCol;
+
+  private final int inputCol;
+
   private Timestamp[] inListValues;
-  private int outputColumn;
 
   // The set object containing the IN list.
   private transient HashSet<Timestamp> inSet;
 
   public TimestampColumnInList() {
     super();
-    inSet = null;
+
+    // Dummy final assignments.
+    inputCol = -1;
   }
 
   /**
    * After construction you must call setInListValues() to add the values to the IN set.
    */
-  public TimestampColumnInList(int colNum, int outputColumn) {
+  public TimestampColumnInList(int colNum, int outputColumnNum) {
+    super(outputColumnNum);
     this.inputCol = colNum;
-    this.outputColumn = outputColumn;
     inSet = null;
   }
 
@@ -68,7 +71,7 @@ public class TimestampColumnInList extends VectorExpression implements ITimestam
     }
 
     TimestampColumnVector inputColVector = (TimestampColumnVector) batch.cols[inputCol];
-    LongColumnVector outputColVector = (LongColumnVector) batch.cols[outputColumn];
+    LongColumnVector outputColVector = (LongColumnVector) batch.cols[outputColumnNum];
     int[] sel = batch.selected;
     boolean[] nullPos = inputColVector.isNull;
     boolean[] outNulls = outputColVector.isNull;
@@ -130,17 +133,6 @@ public class TimestampColumnInList extends VectorExpression implements ITimestam
     }
   }
 
-
-  @Override
-  public String getOutputType() {
-    return "boolean";
-  }
-
-  @Override
-  public int getOutputColumn() {
-    return outputColumn;
-  }
-
   @Override
   public Descriptor getDescriptor() {
 
@@ -154,6 +146,6 @@ public class TimestampColumnInList extends VectorExpression implements ITimestam
 
   @Override
   public String vectorExpressionParameters() {
-    return "col " + inputCol + ", values " + Arrays.toString(inListValues);
+    return getColumnParamString(0, inputCol) + ", values " + Arrays.toString(inListValues);
   }
 }

http://git-wip-us.apache.org/repos/asf/hive/blob/e63ebccc/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/TimestampToStringUnaryUDF.java
----------------------------------------------------------------------
diff --git a/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/TimestampToStringUnaryUDF.java b/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/TimestampToStringUnaryUDF.java
index 32cf527..2a19dae 100644
--- a/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/TimestampToStringUnaryUDF.java
+++ b/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/TimestampToStringUnaryUDF.java
@@ -29,16 +29,19 @@ import org.apache.hadoop.hive.ql.exec.vector.VectorizedRowBatch;
  */
 abstract public class TimestampToStringUnaryUDF extends VectorExpression {
   private static final long serialVersionUID = 1L;
-  int inputColumn;
-  int outputColumn;
 
-  public TimestampToStringUnaryUDF(int inputColumn, int outputColumn) {
+  private final int inputColumn;
+
+  public TimestampToStringUnaryUDF(int inputColumn, int outputColumnNum) {
+    super(outputColumnNum);
     this.inputColumn = inputColumn;
-    this.outputColumn = outputColumn;
   }
 
   public TimestampToStringUnaryUDF() {
     super();
+
+    // Dummy final assignments.
+    inputColumn = -1;
   }
 
   abstract protected void func(BytesColumnVector outV, TimestampColumnVector inV, int i);
@@ -53,7 +56,7 @@ abstract public class TimestampToStringUnaryUDF extends VectorExpression {
     TimestampColumnVector inputColVector = (TimestampColumnVector) batch.cols[inputColumn];
     int[] sel = batch.selected;
     int n = batch.size;
-    BytesColumnVector outV = (BytesColumnVector) batch.cols[outputColumn];
+    BytesColumnVector outV = (BytesColumnVector) batch.cols[outputColumnNum];
     outV.initBuffer();
 
     if (n == 0) {
@@ -110,31 +113,8 @@ abstract public class TimestampToStringUnaryUDF extends VectorExpression {
     }
   }
 
-
-  @Override
-  public int getOutputColumn() {
-    return outputColumn;
-  }
-
-  public void setOutputColumn(int outputColumn) {
-    this.outputColumn = outputColumn;
-  }
-
-  public int getInputColumn() {
-    return inputColumn;
-  }
-
-  public void setInputColumn(int inputColumn) {
-    this.inputColumn = inputColumn;
-  }
-
-  @Override
-  public String getOutputType() {
-    return "String";
-  }
-
   public String vectorExpressionParameters() {
-    return "col " + inputColumn;
+    return getColumnParamString(0, inputColumn);
   }
 
   @Override

http://git-wip-us.apache.org/repos/asf/hive/blob/e63ebccc/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/VarCharScalarConcatStringGroupCol.java
----------------------------------------------------------------------
diff --git a/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/VarCharScalarConcatStringGroupCol.java b/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/VarCharScalarConcatStringGroupCol.java
index 8ca9611..8aa3e63 100644
--- a/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/VarCharScalarConcatStringGroupCol.java
+++ b/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/VarCharScalarConcatStringGroupCol.java
@@ -28,8 +28,8 @@ import org.apache.hadoop.hive.ql.exec.vector.VectorExpressionDescriptor;
 public class VarCharScalarConcatStringGroupCol extends StringScalarConcatStringGroupCol {
   private static final long serialVersionUID = 1L;
 
-  public VarCharScalarConcatStringGroupCol(HiveVarchar value, int colNum, int outputColumn) {
-    super(value.getValue().getBytes(), colNum, outputColumn);
+  public VarCharScalarConcatStringGroupCol(HiveVarchar value, int colNum, int outputColumnNum) {
+    super(value.getValue().getBytes(), colNum, outputColumnNum);
   }
 
   public VarCharScalarConcatStringGroupCol() {

http://git-wip-us.apache.org/repos/asf/hive/blob/e63ebccc/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/VectorCoalesce.java
----------------------------------------------------------------------
diff --git a/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/VectorCoalesce.java b/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/VectorCoalesce.java
index c0870c8..0997ae5 100644
--- a/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/VectorCoalesce.java
+++ b/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/VectorCoalesce.java
@@ -31,20 +31,21 @@ import java.util.Arrays;
  * in the given set of inputs expressions.
  */
 public class VectorCoalesce extends VectorExpression {
-
   private static final long serialVersionUID = 1L;
-  private int [] inputColumns;
-  private int outputColumn;
 
-  public VectorCoalesce(int [] inputColumns, int outputColumn) {
-    this();
+  private final int[] inputColumns;
+
+  public VectorCoalesce(int [] inputColumns, int outputColumnNum) {
+    super(outputColumnNum);
     this.inputColumns = inputColumns;
-    this.outputColumn = outputColumn;
     Preconditions.checkArgument(this.inputColumns.length > 0);
   }
 
   public VectorCoalesce() {
     super();
+
+    // Dummy final assignments.
+    inputColumns = null;
   }
 
   @Override
@@ -56,7 +57,7 @@ public class VectorCoalesce extends VectorExpression {
 
     int[] sel = batch.selected;
     int n = batch.size;
-    ColumnVector outputVector = batch.cols[outputColumn];
+    ColumnVector outputVector = batch.cols[outputColumnNum];
     if (n <= 0) {
       // Nothing to do
       return;
@@ -119,28 +120,6 @@ public class VectorCoalesce extends VectorExpression {
   }
 
   @Override
-  public int getOutputColumn() {
-    return outputColumn;
-  }
-
-  @Override
-  public String getOutputType() {
-    return outputType;
-  }
-
-  public int [] getInputColumns() {
-    return inputColumns;
-  }
-
-  public void setInputColumns(int [] inputColumns) {
-    this.inputColumns = inputColumns;
-  }
-
-  public void setOutputColumn(int outputColumn) {
-    this.outputColumn = outputColumn;
-  }
-
-  @Override
   public String vectorExpressionParameters() {
     return "columns " + Arrays.toString(inputColumns);
   }

http://git-wip-us.apache.org/repos/asf/hive/blob/e63ebccc/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/VectorElt.java
----------------------------------------------------------------------
diff --git a/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/VectorElt.java b/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/VectorElt.java
index 5e0e7aa..750babd 100644
--- a/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/VectorElt.java
+++ b/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/VectorElt.java
@@ -25,19 +25,20 @@ import org.apache.hadoop.hive.ql.exec.vector.VectorExpressionDescriptor;
 import org.apache.hadoop.hive.ql.exec.vector.VectorizedRowBatch;
 
 public class VectorElt extends VectorExpression {
-
   private static final long serialVersionUID = 1L;
-  private int [] inputColumns;
-  private int outputColumn;
 
-  public VectorElt(int [] inputColumns, int outputColumn) {
-    this();
+  private final int[] inputColumns;
+
+  public VectorElt(int [] inputColumns, int outputColumnNum) {
+    super(outputColumnNum);
     this.inputColumns = inputColumns;
-    this.outputColumn = outputColumn;
   }
 
   public VectorElt() {
     super();
+
+    // Dummy final assignments.
+    inputColumns = null;
   }
 
   @Override
@@ -49,7 +50,7 @@ public class VectorElt extends VectorExpression {
 
     int[] sel = batch.selected;
     int n = batch.size;
-    BytesColumnVector outputVector = (BytesColumnVector) batch.cols[outputColumn];
+    BytesColumnVector outputVector = (BytesColumnVector) batch.cols[outputColumnNum];
     if (n <= 0) {
       return;
     }
@@ -109,28 +110,6 @@ public class VectorElt extends VectorExpression {
   }
 
   @Override
-  public int getOutputColumn() {
-    return outputColumn;
-  }
-
-  @Override
-  public String getOutputType() {
-    return outputType;
-  }
-
-  public int [] getInputColumns() {
-    return inputColumns;
-  }
-
-  public void setInputColumns(int [] inputColumns) {
-    this.inputColumns = inputColumns;
-  }
-
-  public void setOutputColumn(int outputColumn) {
-    this.outputColumn = outputColumn;
-  }
-
-  @Override
   public String vectorExpressionParameters() {
     return "columns " + Arrays.toString(inputColumns);
   }

http://git-wip-us.apache.org/repos/asf/hive/blob/e63ebccc/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/VectorExpression.java
----------------------------------------------------------------------
diff --git a/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/VectorExpression.java b/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/VectorExpression.java
index 8e23094..b5399d6 100644
--- a/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/VectorExpression.java
+++ b/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/VectorExpression.java
@@ -20,105 +20,249 @@ package org.apache.hadoop.hive.ql.exec.vector.expressions;
 
 import java.io.Serializable;
 import java.nio.charset.StandardCharsets;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
 import java.util.Map;
 
 import com.google.common.collect.ImmutableMap;
 
 import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.hive.common.type.DataTypePhysicalVariation;
+import org.apache.hadoop.hive.ql.exec.vector.ColumnVector;
 import org.apache.hadoop.hive.ql.exec.vector.VectorExpressionDescriptor;
+import org.apache.hadoop.hive.ql.exec.vector.VectorizationContext;
 import org.apache.hadoop.hive.ql.exec.vector.VectorizedRowBatch;
+import org.apache.hadoop.hive.serde2.typeinfo.TypeInfo;
+import org.apache.hadoop.hive.serde2.typeinfo.TypeInfoUtils;
+import org.apache.hadoop.hive.ql.exec.vector.ColumnVector.Type;
+import org.apache.hadoop.hive.ql.metadata.HiveException;
 
 /**
- * Base class for expressions.
+ * Base class for vector expressions.
+ *
+ * A vector expression is a vectorized execution tree that evaluates the same result as a (row-mode)
+ * ExprNodeDesc tree describes.
+ *
+ * A vector expression has 0, 1, or more parameters and an optional output column.  These are
+ * normally passed to the vector expression object' constructor.  A few special case classes accept
+ * extra parameters via set* method.
+ *
+ * A ExprNodeColumnDesc vectorizes to the IdentityExpression class where the input column number
+ * parameter is the same as the output column number.
+ *
+ * A ExprNodeGenericFuncDesc's generic function can vectorize to many different vectorized objects
+ * depending on the parameter expression kinds (column, constant, etc) and data types.  Each
+ * vectorized class implements the getDecription which indicates the particular expression kind
+ * and data type specialization that class is designed for.  The Description is used by the
+ * VectorizationContext class in matching the right vectorized class.
+ *
+ * The constructor parameters need to be in the same order as the generic function because
+ * the VectorizationContext class automates parameter generation and object construction.
+ *
+ * Type information is remembered for the input parameters and the output type.
+ *
+ * A vector expression has optional children vector expressions when 1 or more parameters need
+ * to be calculated into vector scratch columns.  Columns and constants do not need children
+ * expressions.
  */
 public abstract class VectorExpression implements Serializable {
-  public enum Type {
-    STRING, CHAR, VARCHAR, TIMESTAMP, DATE, LONG, DOUBLE, DECIMAL,
-    INTERVAL_YEAR_MONTH, INTERVAL_DAY_TIME, BINARY, OTHER;
-    private static Map<String, Type> types = ImmutableMap.<String, Type>builder()
-        .put("string", STRING)
-        .put("char", CHAR)
-        .put("varchar", VARCHAR)
-        .put("timestamp", TIMESTAMP)
-        .put("date", DATE)
-        .put("long", LONG)
-        .put("double", DOUBLE)
-        .put("decimal", DECIMAL)
-        .put("interval_year_month", INTERVAL_YEAR_MONTH)
-        .put("interval_day_time", INTERVAL_DAY_TIME)
-        .put("binary", BINARY)
-        .build();
-
-    public static Type getValue(String name) {
-      String nameLower = name.toLowerCase();
-      if (types.containsKey(nameLower)) {
-        return types.get(nameLower);
-      }
-      return OTHER;
-    }
-  }
 
   private static final long serialVersionUID = 1L;
+
   /**
-   * Child expressions are evaluated post order.
+   * Child expressions for parameters -- but only those that need to be computed.
+   *
+   * NOTE: Columns and constants are not included in the children.  That is: column numbers and
+   * scalar values are passed via the constructor and remembered by the individual vector expression
+   * classes. They are not represented in the children.
    */
-  protected VectorExpression [] childExpressions = null;
+  protected VectorExpression [] childExpressions;
 
   /**
-   * More detailed input types, such as date and timestamp.
+   * ALL input parameter type information is here including those for (non-computed) columns and
+   * scalar values.
+   *
+   * The vectorExpressionParameters() method is used to get the displayable string for the
+   * parameters used by EXPLAIN, logging, etc.
    */
-  protected Type [] inputTypes;
+  protected TypeInfo[] inputTypeInfos;
+  protected DataTypePhysicalVariation[] inputDataTypePhysicalVariations;
 
   /**
-   * Output type of the expression.
+   * Output column number and type information of the vector expression.
+   */
+  protected final int outputColumnNum;
+
+  protected TypeInfo outputTypeInfo;
+  protected DataTypePhysicalVariation outputDataTypePhysicalVariation;
+
+  /*
+   * Use this constructor when there is NO output column.
+   */
+  public VectorExpression() {
+
+    // Initially, no children or inputs; set later with setInput* methods.
+    childExpressions = null;
+    inputTypeInfos = null;
+    inputDataTypePhysicalVariations = null;
+
+    // No output type information.
+    outputColumnNum = -1;
+    outputTypeInfo = null;
+    outputDataTypePhysicalVariation = null;
+  }
+
+  /*
+   * Use this constructor when there is an output column.
    */
-  protected String outputType;
+  public VectorExpression(int outputColumnNum) {
+
+    // By default, no children or inputs.
+    childExpressions = null;
+    inputTypeInfos = null;
+    inputDataTypePhysicalVariations = null;
+
+    this.outputColumnNum = outputColumnNum;
+
+    // Set later with setOutput* methods.
+    outputTypeInfo = null;
+    outputDataTypePhysicalVariation = null;
+  }
+
+  //------------------------------------------------------------------------------------------------
 
   /**
-   * This is the primary method to implement expression logic.
-   * @param batch
+   * Initialize the child expressions.
    */
-  public abstract void evaluate(VectorizedRowBatch batch);
+  public void setChildExpressions(VectorExpression[] childExpressions) {
+    this.childExpressions = childExpressions;
+  }
 
-  public void init(Configuration conf) {
-    if (childExpressions != null) {
-      for (VectorExpression child : childExpressions) {
-        child.init(conf);
+  public VectorExpression[] getChildExpressions() {
+    return childExpressions;
+  }
+
+  //------------------------------------------------------------------------------------------------
+
+  public void setInputTypeInfos(TypeInfo ...inputTypeInfos) {
+    this.inputTypeInfos = inputTypeInfos;
+  }
+
+  public TypeInfo[] getInputTypeInfos() {
+    return inputTypeInfos;
+  }
+
+  public void setInputDataTypePhysicalVariations(
+      DataTypePhysicalVariation ...inputDataTypePhysicalVariations) {
+    this.inputDataTypePhysicalVariations = inputDataTypePhysicalVariations;
+  }
+
+  public DataTypePhysicalVariation[] getInputDataTypePhysicalVariations() {
+    return inputDataTypePhysicalVariations;
+  }
+
+  /*
+   * Return a short string with the parameters of the vector expression that will be
+   * shown in EXPLAIN output, etc.
+   */
+  public abstract String vectorExpressionParameters();
+
+  //------------------------------------------------------------------------------------------------
+
+  public void transientInit() throws HiveException {
+    // Do nothing by default.
+  }
+
+  public static void doTransientInit(VectorExpression vecExpr) throws HiveException {
+    if (vecExpr == null) {
+      return;
+    }
+    doTransientInitRecurse(vecExpr);
+  }
+
+  public static void doTransientInit(VectorExpression[] vecExprs) throws HiveException {
+    if (vecExprs == null) {
+      return;
+    }
+    for (VectorExpression vecExpr : vecExprs) {
+      doTransientInitRecurse(vecExpr);
+    }
+  }
+
+  private static void doTransientInitRecurse(VectorExpression vecExpr) throws HiveException {
+
+    // Well, don't recurse but make sure all children are initialized.
+    vecExpr.transientInit();
+    List<VectorExpression> newChildren = new ArrayList<VectorExpression>();
+    VectorExpression[] children = vecExpr.getChildExpressions();
+    if (children != null) {
+      Collections.addAll(newChildren, children);
+    }
+    while (!newChildren.isEmpty()) {
+      VectorExpression childVecExpr = newChildren.remove(0);
+      children = childVecExpr.getChildExpressions();
+      if (children != null) {
+        Collections.addAll(newChildren, children);
       }
+      childVecExpr.transientInit();
     }
   }
 
+  //------------------------------------------------------------------------------------------------
+
   /**
    * Returns the index of the output column in the array
    * of column vectors. If not applicable, -1 is returned.
    * @return Index of the output column
    */
-  public abstract int getOutputColumn();
+  public int getOutputColumnNum() {
+    return outputColumnNum;
+  }
 
   /**
    * Returns type of the output column.
    */
-  public String getOutputType() {
-    return outputType;
+  public TypeInfo getOutputTypeInfo() {
+    return outputTypeInfo;
   }
 
   /**
    * Set type of the output column.
    */
-  public void setOutputType(String type) {
-    this.outputType = type;
+  public void setOutputTypeInfo(TypeInfo outputTypeInfo) {
+    this.outputTypeInfo = outputTypeInfo;
   }
 
   /**
-   * Initialize the child expressions.
+   * Set data type read variation.
    */
-  public void setChildExpressions(VectorExpression [] ve) {
+  public void setOutputDataTypePhysicalVariation(DataTypePhysicalVariation outputDataTypePhysicalVariation) {
+    this.outputDataTypePhysicalVariation = outputDataTypePhysicalVariation;
+  }
 
-    childExpressions = ve;
+  public DataTypePhysicalVariation getOutputDataTypePhysicalVariation() {
+    return outputDataTypePhysicalVariation;
   }
 
-  public VectorExpression[] getChildExpressions() {
-    return childExpressions;
+  public ColumnVector.Type getOutputColumnVectorType() throws HiveException {
+    return
+        VectorizationContext.getColumnVectorTypeFromTypeInfo(
+            outputTypeInfo, outputDataTypePhysicalVariation);
+  }
+  /**
+   * This is the primary method to implement expression logic.
+   * @param batch
+   */
+  public abstract void evaluate(VectorizedRowBatch batch);
+
+  public void init(Configuration conf) {
+    if (childExpressions != null) {
+      for (VectorExpression child : childExpressions) {
+        child.init(conf);
+      }
+    }
   }
 
   public abstract VectorExpressionDescriptor.Descriptor getDescriptor();
@@ -135,23 +279,39 @@ public abstract class VectorExpression implements Serializable {
     }
   }
 
-  /**
-   * Set more detailed types to distinguish certain types that is represented in same
-   * {@link org.apache.hadoop.hive.ql.exec.vector.VectorExpressionDescriptor.ArgumentType}s. For example, date and
-   * timestamp will be in {@link org.apache.hadoop.hive.ql.exec.vector.LongColumnVector} but they need to be
-   * distinguished.
-   * @param inputTypes
-   */
-  public void setInputTypes(Type ... inputTypes) {
-    this.inputTypes = inputTypes;
+  protected String getColumnParamString(int typeNum, int columnNum) {
+    return "col " + columnNum + ":" + getParamTypeString(typeNum);
   }
 
-  public Type [] getInputTypes() {
-    return inputTypes;
+  protected String getLongValueParamString(int typeNum, long value) {
+    return "val " + value + ":" + getParamTypeString(typeNum);
   }
 
-  public String vectorExpressionParameters() {
-    return null;
+  protected String getDoubleValueParamString(int typeNum, double value) {
+    return "val " + value + ":" + getParamTypeString(typeNum);
+  }
+
+  protected String getParamTypeString(int typeNum) {
+    if (inputTypeInfos == null || inputDataTypePhysicalVariations == null) {
+      fake++;
+    }
+    if (typeNum >= inputTypeInfos.length || typeNum >= inputDataTypePhysicalVariations.length) {
+      fake++;
+    }
+    return getTypeName(inputTypeInfos[typeNum], inputDataTypePhysicalVariations[typeNum]);
+  }
+
+  static int fake;
+
+  public static String getTypeName(TypeInfo typeInfo, DataTypePhysicalVariation dataTypePhysicalVariation) {
+    if (typeInfo == null) {
+      fake++;
+    }
+    if (dataTypePhysicalVariation != null && dataTypePhysicalVariation != DataTypePhysicalVariation.NONE) {
+      return typeInfo.toString() + "/" + dataTypePhysicalVariation;
+    } else {
+      return typeInfo.toString();
+    }
   }
 
   @Override
@@ -177,14 +337,14 @@ public abstract class VectorExpression implements Serializable {
         }
         b.append(")");
       }
-      b.append(" -> ");
-      int outputColumn = getOutputColumn();
-      if (outputColumn != -1) {
-        b.append(outputColumn);
+
+      if (outputColumnNum != -1) {
+        b.append(" -> ");
+        b.append(outputColumnNum);
         b.append(":");
+        b.append(getTypeName(outputTypeInfo, outputDataTypePhysicalVariation));
       }
-      b.append(getOutputType());
-    }
+     }
 
     return b.toString();
   }

http://git-wip-us.apache.org/repos/asf/hive/blob/e63ebccc/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/VectorInBloomFilterColDynamicValue.java
----------------------------------------------------------------------
diff --git a/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/VectorInBloomFilterColDynamicValue.java b/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/VectorInBloomFilterColDynamicValue.java
index 25440d6..56532b0 100644
--- a/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/VectorInBloomFilterColDynamicValue.java
+++ b/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/VectorInBloomFilterColDynamicValue.java
@@ -32,27 +32,46 @@ import org.apache.hadoop.hive.ql.exec.vector.LongColumnVector;
 import org.apache.hadoop.hive.ql.exec.vector.TimestampColumnVector;
 import org.apache.hadoop.hive.ql.exec.vector.VectorExpressionDescriptor.Descriptor;
 import org.apache.hadoop.hive.ql.exec.vector.VectorExpressionDescriptor;
+import org.apache.hadoop.hive.ql.exec.vector.VectorizationContext;
 import org.apache.hadoop.hive.ql.exec.vector.VectorizedRowBatch;
+import org.apache.hadoop.hive.ql.metadata.HiveException;
 import org.apache.hadoop.hive.ql.plan.DynamicValue;
+import org.apache.hadoop.hive.serde2.objectinspector.PrimitiveObjectInspector.PrimitiveCategory;
 import org.apache.hadoop.hive.serde2.objectinspector.primitive.BinaryObjectInspector;
+import org.apache.hadoop.hive.serde2.typeinfo.PrimitiveTypeInfo;
 import org.apache.hadoop.io.IOUtils;
 import org.apache.hive.common.util.BloomKFilter;
 
 public class VectorInBloomFilterColDynamicValue extends VectorExpression {
   private static final long serialVersionUID = 1L;
 
-  protected int colNum;
-  protected DynamicValue bloomFilterDynamicValue;
+  protected final int colNum;
+  protected final DynamicValue bloomFilterDynamicValue;
+
   protected transient boolean initialized = false;
   protected transient BloomKFilter bloomFilter;
   protected transient BloomFilterCheck bfCheck;
+  protected transient ColumnVector.Type colVectorType;
 
   public VectorInBloomFilterColDynamicValue(int colNum, DynamicValue bloomFilterDynamicValue) {
+    super();
     this.colNum = colNum;
     this.bloomFilterDynamicValue = bloomFilterDynamicValue;
   }
 
   public VectorInBloomFilterColDynamicValue() {
+    super();
+
+    // Dummy final assignments.
+    colNum = -1;
+    bloomFilterDynamicValue = null;
+  }
+
+  @Override
+  public void transientInit() throws HiveException {
+    super.transientInit();
+
+    colVectorType = VectorizationContext.getColumnVectorTypeFromTypeInfo(inputTypeInfos[0]);
   }
 
   @Override
@@ -61,10 +80,8 @@ public class VectorInBloomFilterColDynamicValue extends VectorExpression {
     bloomFilterDynamicValue.setConf(conf);
 
     // Instantiate BloomFilterCheck based on input column type
-    VectorExpression.Type colType = this.getInputTypes()[0];
-    switch (colType) {
+    switch (colVectorType) {
     case LONG:
-    case DATE:
       bfCheck = new LongBloomFilterCheck();
       break;
     case DOUBLE:
@@ -73,17 +90,14 @@ public class VectorInBloomFilterColDynamicValue extends VectorExpression {
     case DECIMAL:
       bfCheck = new DecimalBloomFilterCheck();
       break;
-    case STRING:
-    case CHAR:
-    case VARCHAR:
-    case BINARY:
+    case BYTES:
       bfCheck = new BytesBloomFilterCheck();
       break;
     case TIMESTAMP:
       bfCheck = new TimestampBloomFilterCheck();
       break;
     default:
-      throw new IllegalStateException("Unsupported type " + colType);
+      throw new IllegalStateException("Unsupported type " + colVectorType);
     }
   }
 
@@ -206,24 +220,6 @@ public class VectorInBloomFilterColDynamicValue extends VectorExpression {
   }
 
   @Override
-  public int getOutputColumn() {
-    return -1;
-  }
-
-  @Override
-  public String getOutputType() {
-    return "boolean";
-  }
-
-  public int getColNum() {
-    return colNum;
-  }
-
-  public void setColNum(int colNum) {
-    this.colNum = colNum;
-  }
-
-  @Override
   public Descriptor getDescriptor() {
     VectorExpressionDescriptor.Builder b = new VectorExpressionDescriptor.Builder();
     b.setMode(VectorExpressionDescriptor.Mode.FILTER)
@@ -284,4 +280,9 @@ public class VectorInBloomFilterColDynamicValue extends VectorExpression {
       return bloomFilter.testLong(col.time[idx]);
     }
   }
+
+  @Override
+  public String vectorExpressionParameters() {
+    return null;
+  }
 }

http://git-wip-us.apache.org/repos/asf/hive/blob/e63ebccc/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/VectorUDFDateAddColCol.java
----------------------------------------------------------------------
diff --git a/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/VectorUDFDateAddColCol.java b/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/VectorUDFDateAddColCol.java
index 00e9e03..350c757 100644
--- a/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/VectorUDFDateAddColCol.java
+++ b/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/VectorUDFDateAddColCol.java
@@ -24,7 +24,10 @@ import org.apache.hadoop.hive.ql.exec.vector.LongColumnVector;
 import org.apache.hadoop.hive.ql.exec.vector.TimestampColumnVector;
 import org.apache.hadoop.hive.ql.exec.vector.VectorExpressionDescriptor;
 import org.apache.hadoop.hive.ql.exec.vector.VectorizedRowBatch;
+import org.apache.hadoop.hive.ql.metadata.HiveException;
 import org.apache.hadoop.hive.serde2.io.DateWritable;
+import org.apache.hadoop.hive.serde2.objectinspector.PrimitiveObjectInspector.PrimitiveCategory;
+import org.apache.hadoop.hive.serde2.typeinfo.PrimitiveTypeInfo;
 import org.apache.hadoop.io.Text;
 import org.apache.hive.common.util.DateParser;
 
@@ -34,23 +37,38 @@ import java.sql.Date;
 public class VectorUDFDateAddColCol extends VectorExpression {
   private static final long serialVersionUID = 1L;
 
-  private int colNum1;
-  private int colNum2;
-  private int outputColumn;
+  private final int colNum1;
+  private final int colNum2;
+
   protected boolean isPositive = true;
+
   private transient final Text text = new Text();
   private transient final Date date = new Date(0);
   private transient final DateParser dateParser = new DateParser();
 
-  public VectorUDFDateAddColCol(int colNum1, int colNum2, int outputColumn) {
-    this();
+  // Transient members initialized by transientInit method.
+  private transient PrimitiveCategory primitiveCategory;
+
+  public VectorUDFDateAddColCol(int colNum1, int colNum2, int outputColumnNum) {
+    super(outputColumnNum);
     this.colNum1 = colNum1;
     this.colNum2 = colNum2;
-    this.outputColumn = outputColumn;
   }
 
   public VectorUDFDateAddColCol() {
     super();
+
+    // Dummy final assignments.
+    colNum1 = -1;
+    colNum2 = -1;
+  }
+
+  @Override
+  public void transientInit() throws HiveException {
+    super.transientInit();
+
+    primitiveCategory =
+        ((PrimitiveTypeInfo) inputTypeInfos[0]).getPrimitiveCategory();
   }
 
   @Override
@@ -66,7 +84,7 @@ public class VectorUDFDateAddColCol extends VectorExpression {
     int n = batch.size;
     long[] vector2 = inputColVector2.vector;
 
-    LongColumnVector outV = (LongColumnVector) batch.cols[outputColumn];
+    LongColumnVector outV = (LongColumnVector) batch.cols[outputColumnNum];
     long[] outputVector = outV.vector;
     if (n <= 0) {
       // Nothing to do
@@ -76,7 +94,7 @@ public class VectorUDFDateAddColCol extends VectorExpression {
     // Handle null
     NullUtil.propagateNullsColCol(inputColVector1, inputColVector2, outV, batch.selected, batch.size, batch.selectedInUse);
 
-    switch (inputTypes[0]) {
+    switch (primitiveCategory) {
       case DATE:
         // Now disregard null in second pass.
         if ((inputColVector1.isRepeating) && (inputColVector2.isRepeating)) {
@@ -136,7 +154,7 @@ public class VectorUDFDateAddColCol extends VectorExpression {
         }
         break;
       default:
-        throw new Error("Unsupported input type " + inputTypes[0].name());
+        throw new Error("Unsupported input type " + primitiveCategory.name());
     }
   }
 
@@ -186,38 +204,8 @@ public class VectorUDFDateAddColCol extends VectorExpression {
   }
 
   @Override
-  public int getOutputColumn() {
-    return this.outputColumn;
-  }
-
-  @Override
-  public String getOutputType() {
-    return "date";
-  }
-
-  public int getColNum1() {
-    return colNum1;
-  }
-
-  public void setColNum1(int colNum1) {
-    this.colNum1 = colNum1;
-  }
-
-  public int getColNum2() {
-    return colNum2;
-  }
-
-  public void setColNum2(int colNum2) {
-    this.colNum2 = colNum2;
-  }
-
-  public void setOutputColumn(int outputColumn) {
-    this.outputColumn = outputColumn;
-  }
-
-  @Override
   public String vectorExpressionParameters() {
-    return "col " + colNum1 + ", col " + colNum2;
+    return getColumnParamString(0, colNum1) + ", " + getColumnParamString(1, colNum2);
   }
 
   @Override

http://git-wip-us.apache.org/repos/asf/hive/blob/e63ebccc/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/VectorUDFDateAddColScalar.java
----------------------------------------------------------------------
diff --git a/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/VectorUDFDateAddColScalar.java b/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/VectorUDFDateAddColScalar.java
index 730dc36..66d4fc2 100644
--- a/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/VectorUDFDateAddColScalar.java
+++ b/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/VectorUDFDateAddColScalar.java
@@ -24,7 +24,10 @@ import org.apache.hadoop.hive.ql.exec.vector.LongColumnVector;
 import org.apache.hadoop.hive.ql.exec.vector.TimestampColumnVector;
 import org.apache.hadoop.hive.ql.exec.vector.VectorExpressionDescriptor;
 import org.apache.hadoop.hive.ql.exec.vector.VectorizedRowBatch;
+import org.apache.hadoop.hive.ql.metadata.HiveException;
 import org.apache.hadoop.hive.serde2.io.DateWritable;
+import org.apache.hadoop.hive.serde2.objectinspector.PrimitiveObjectInspector.PrimitiveCategory;
+import org.apache.hadoop.hive.serde2.typeinfo.PrimitiveTypeInfo;
 import org.apache.hadoop.io.Text;
 import org.apache.hive.common.util.DateParser;
 
@@ -33,23 +36,38 @@ import java.sql.Date;
 public class VectorUDFDateAddColScalar extends VectorExpression {
   private static final long serialVersionUID = 1L;
 
-  private int colNum;
-  private int outputColumn;
-  private int numDays;
+  private final int colNum;
+  private final int numDays;
+
   protected boolean isPositive = true;
+
   private transient final Text text = new Text();
   private transient final DateParser dateParser = new DateParser();
   private transient final Date date = new Date(0);
 
-  public VectorUDFDateAddColScalar(int colNum, long numDays, int outputColumn) {
-    super();
+  // Transient members initialized by transientInit method.
+  private transient PrimitiveCategory primitiveCategory;
+
+  public VectorUDFDateAddColScalar(int colNum, long numDays, int outputColumnNum) {
+    super(outputColumnNum);
     this.colNum = colNum;
     this.numDays = (int) numDays;
-    this.outputColumn = outputColumn;
   }
 
   public VectorUDFDateAddColScalar() {
     super();
+
+    // Dummy final assignments.
+    colNum = -1;
+    numDays = 0;
+  }
+
+  @Override
+  public void transientInit() throws HiveException {
+    super.transientInit();
+
+    primitiveCategory =
+        ((PrimitiveTypeInfo) inputTypeInfos[0]).getPrimitiveCategory();
   }
 
   @Override
@@ -59,7 +77,7 @@ public class VectorUDFDateAddColScalar extends VectorExpression {
       super.evaluateChildren(batch);
     }
 
-    LongColumnVector outV = (LongColumnVector) batch.cols[outputColumn];
+    LongColumnVector outV = (LongColumnVector) batch.cols[outputColumnNum];
     ColumnVector inputCol = batch.cols[this.colNum];
     /* every line below this is identical for evaluateLong & evaluateString */
     final int n = inputCol.isRepeating ? 1 : batch.size;
@@ -74,7 +92,7 @@ public class VectorUDFDateAddColScalar extends VectorExpression {
     /* true for all algebraic UDFs with no state */
     outV.isRepeating = inputCol.isRepeating;
 
-    switch (inputTypes[0]) {
+    switch (primitiveCategory) {
       case DATE:
         if (inputCol.noNulls) {
           outV.noNulls = true;
@@ -185,7 +203,7 @@ public class VectorUDFDateAddColScalar extends VectorExpression {
         }
         break;
       default:
-          throw new Error("Unsupported input type " + inputTypes[0].name());
+          throw new Error("Unsupported input type " + primitiveCategory.name());
     }
   }
 
@@ -231,38 +249,8 @@ public class VectorUDFDateAddColScalar extends VectorExpression {
   }
 
   @Override
-  public int getOutputColumn() {
-    return this.outputColumn;
-  }
-
-  @Override
-  public String getOutputType() {
-    return "date";
-  }
-
-  public int getColNum() {
-    return colNum;
-  }
-
-  public void setColNum(int colNum) {
-    this.colNum = colNum;
-  }
-
-  public void setOutputColumn(int outputColumn) {
-    this.outputColumn = outputColumn;
-  }
-
-  public int getNumDays() {
-    return numDays;
-  }
-
-  public void setNumDay(int numDays) {
-    this.numDays = numDays;
-  }
-
-  @Override
   public String vectorExpressionParameters() {
-    return "col " + colNum + ", val " + numDays;
+    return getColumnParamString(0, colNum) + ", val " + numDays;
   }
 
   @Override


Mime
View raw message