Search in sources :

Example 1 with DecimalColModuloDecimalColumn

use of org.apache.hadoop.hive.ql.exec.vector.expressions.gen.DecimalColModuloDecimalColumn in project hive by apache.

the class TestVectorArithmeticExpressions method testDecimalColModuloDecimalColumn.

// Spot check decimal column modulo decimal column
@Test
public void testDecimalColModuloDecimalColumn() {
    VectorizedRowBatch b = getVectorizedRowBatch3DecimalCols();
    DecimalColumnVector in1 = (DecimalColumnVector) b.cols[1];
    for (int i = 0; i < 3; i++) {
        in1.vector[i].set(HiveDecimal.create("0.50"));
    }
    VectorExpression expr = new DecimalColModuloDecimalColumn(0, 1, 2);
    expr.evaluate(b);
    DecimalColumnVector r = (DecimalColumnVector) b.cols[2];
    assertTrue(r.vector[0].getHiveDecimal().equals(HiveDecimal.create("0.20")));
    assertTrue(r.vector[1].getHiveDecimal().equals(HiveDecimal.create("-0.30")));
    assertTrue(r.vector[2].getHiveDecimal().equals(HiveDecimal.create("0")));
}
Also used : VectorizedRowBatch(org.apache.hadoop.hive.ql.exec.vector.VectorizedRowBatch) TestVectorizedRowBatch(org.apache.hadoop.hive.ql.exec.vector.TestVectorizedRowBatch) DecimalColumnVector(org.apache.hadoop.hive.ql.exec.vector.DecimalColumnVector) DecimalColModuloDecimalColumn(org.apache.hadoop.hive.ql.exec.vector.expressions.gen.DecimalColModuloDecimalColumn) Test(org.junit.Test)

Aggregations

DecimalColumnVector (org.apache.hadoop.hive.ql.exec.vector.DecimalColumnVector)1 TestVectorizedRowBatch (org.apache.hadoop.hive.ql.exec.vector.TestVectorizedRowBatch)1 VectorizedRowBatch (org.apache.hadoop.hive.ql.exec.vector.VectorizedRowBatch)1 DecimalColModuloDecimalColumn (org.apache.hadoop.hive.ql.exec.vector.expressions.gen.DecimalColModuloDecimalColumn)1 Test (org.junit.Test)1