Search in sources :

Example 1 with DecimalColSubtractDecimalColumn

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

the class TestVectorArithmeticExpressions method testDecimalColSubtractDecimalColumn.

// Spot check decimal column-column subtract
@Test
public void testDecimalColSubtractDecimalColumn() {
    VectorizedRowBatch b = getVectorizedRowBatch3DecimalCols();
    VectorExpression expr = new DecimalColSubtractDecimalColumn(0, 1, 2);
    DecimalColumnVector r = (DecimalColumnVector) b.cols[2];
    // test without nulls
    expr.evaluate(b);
    assertTrue(r.vector[0].getHiveDecimal().equals(HiveDecimal.create("0.20")));
    assertTrue(r.vector[1].getHiveDecimal().equals(HiveDecimal.create("-4.30")));
    assertTrue(r.vector[2].getHiveDecimal().equals(HiveDecimal.create("-1.00")));
    // test that underflow produces NULL
    b = getVectorizedRowBatch3DecimalCols();
    DecimalColumnVector c0 = (DecimalColumnVector) b.cols[0];
    // set to min possible value
    c0.vector[0].set(HiveDecimal.create("-9999999999999999.99"));
    r = (DecimalColumnVector) b.cols[2];
    // will cause underflow for result at position 0, must yield NULL
    expr.evaluate(b);
    assertTrue(!r.noNulls && r.isNull[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) DecimalColSubtractDecimalColumn(org.apache.hadoop.hive.ql.exec.vector.expressions.gen.DecimalColSubtractDecimalColumn) 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 DecimalColSubtractDecimalColumn (org.apache.hadoop.hive.ql.exec.vector.expressions.gen.DecimalColSubtractDecimalColumn)1 Test (org.junit.Test)1