@Override
  public void evaluate(VectorizedRowBatch batch) throws HiveException {

    Preconditions.checkState(
        ((PrimitiveTypeInfo) inputTypeInfos[0]).getPrimitiveCategory() == PrimitiveCategory.TIMESTAMP);

    if (childExpressions != null) {
        super.evaluateChildren(batch);
      }

    LongColumnVector outV = (LongColumnVector) batch.cols[outputColumnNum];
    ColumnVector inputColVec = batch.cols[this.inputColumnNum[0]];

    /* every line below this is identical for evaluateLong & evaluateString */
    final int n = inputColVec.isRepeating ? 1 : batch.size;
    int[] sel = batch.selected;
    final boolean selectedInUse = (inputColVec.isRepeating == false) && batch.selectedInUse;

    if(batch.size == 0) {
      /* n != batch.size when isRepeating */
      return;
    }

    // We do not need to do a column reset since we are carefully changing the output.
    outV.isRepeating = false;

    TimestampColumnVector timestampColVector = (TimestampColumnVector) inputColVec;

    if (inputColVec.isRepeating) {
      if (inputColVec.noNulls || !inputColVec.isNull[0]) {
        outV.isNull[0] = false;
        outV.vector[0] = getTimestampField(timestampColVector, 0);
      } else {
        outV.isNull[0] = true;
        outV.noNulls = false;
      }
      outV.isRepeating = true;
      return;
    }

    if (inputColVec.noNulls) {
      if (selectedInUse) {
        for(int j=0; j < n; j++) {
          int i = sel[j];
          outV.isNull[i] = false;
          outV.vector[i] = getTimestampField(timestampColVector, i);
        }
      } else {
        Arrays.fill(outV.isNull, 0, n, false);
        for(int i = 0; i < n; i++) {
          outV.vector[i] = getTimestampField(timestampColVector, i);
        }
      }
    } else /* there are nulls in the inputColVector */ {

      // Carefully handle NULLs...
      outV.noNulls = false;

      if (selectedInUse) {
        for(int j=0; j < n; j++) {
          int i = sel[j];
          outV.isNull[i] = inputColVec.isNull[i];
          if (!inputColVec.isNull[i]) {
            outV.vector[i] = getTimestampField(timestampColVector, i);
          }
        }
      } else {
        for(int i = 0; i < n; i++) {
          outV.isNull[i] = inputColVec.isNull[i];
          if (!inputColVec.isNull[i]) {
            outV.vector[i] = getTimestampField(timestampColVector, i);
          }
        }
      }
    }
  }
Abstract class to return various fields from a Timestamp.
ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/VectorUDFTimestampFieldTimestamp.java