@Test
  public void testCastTimestampToDecimal() throws HiveException {

    // The input timestamps are stored as long values
    // measured in nanoseconds from the epoch.
    HiveDecimal[] hiveDecimalValues = new HiveDecimal[500];
    VectorizedRowBatch b = getBatchTimestampDecimal(hiveDecimalValues);
    VectorExpression expr = new CastTimestampToDecimal(0, 1);

    expr.evaluate(b);
    DecimalColumnVector r = (DecimalColumnVector) b.cols[1];
    for (int i = 0; i < hiveDecimalValues.length; i++) {
      HiveDecimal hiveDecimal = r.vector[i].getHiveDecimal();
      HiveDecimal expectedHiveDecimal = hiveDecimalValues[i];
      if (!hiveDecimal.equals(expectedHiveDecimal)) {
        assertTrue(false);
      }
    }

    // Try again with a value that won't fit in 5 digits, to make
    // sure that NULL is produced.
    b.cols[1] = r = new DecimalColumnVector(hiveDecimalValues.length, 5, 2);
    expr.evaluate(b);
    r = (DecimalColumnVector) b.cols[1];
    for (int i = 0; i < hiveDecimalValues.length; i++) {
      HiveDecimal hiveDecimal = r.vector[i].getHiveDecimal();
      HiveDecimal expectedHiveDecimal = hiveDecimalValues[i];
      if (HiveDecimal.enforcePrecisionScale(expectedHiveDecimal, 5, 2) == null) {
        assertTrue(r.isNull[i]);
      } else {
        assertTrue(!r.isNull[i]);
        if (!hiveDecimal.equals(expectedHiveDecimal)) {
          assertTrue(false);
        }
      }
    }
  }
Just spot check the basic case because code path is the same as
for cast of decimal to long due to inheritance.
ql/src/test/org/apache/hadoop/hive/ql/exec/vector/expressions/TestVectorTypeCasts.java