use of org.apache.hadoop.hive.ql.exec.vector.expressions.gen.DecimalScalarModuloDecimalColumn in project hive by apache.
the class TestVectorArithmeticExpressions method testDecimalScalarModuloDecimalColumn.
// Spot check decimal scalar-column modulo
@Test
public void testDecimalScalarModuloDecimalColumn() throws HiveException {
VectorizedRowBatch b = getVectorizedRowBatch3DecimalCols();
HiveDecimal d = HiveDecimal.create("2.00");
VectorExpression expr = new DecimalScalarModuloDecimalColumn(d, 0, 2);
// test without nulls
expr.evaluate(b);
DecimalColumnVector r = (DecimalColumnVector) b.cols[2];
assertTrue(r.vector[0].getHiveDecimal().equals(HiveDecimal.create("0.80")));
assertTrue(r.vector[1].getHiveDecimal().equals(HiveDecimal.create("2.00")));
// entry 2 will be null due to zero-divide
assertFalse(r.noNulls);
assertTrue(r.isNull[2]);
// try again with some different data values
DecimalColumnVector in = (DecimalColumnVector) b.cols[0];
expr = new DecimalScalarModuloDecimalColumn(d, 0, 2);
in.vector[0].set(HiveDecimal.create("0.50"));
in.vector[1].set(HiveDecimal.create("0.80"));
in.vector[2].set(HiveDecimal.create("0.70"));
expr.evaluate(b);
assertTrue(r.vector[0].getHiveDecimal().equals(HiveDecimal.create("0.00")));
assertTrue(r.vector[1].getHiveDecimal().equals(HiveDecimal.create("0.40")));
assertTrue(r.vector[2].getHiveDecimal().equals(HiveDecimal.create("0.60")));
}
Aggregations