Search in sources :

Example 1 with FuncRoundDoubleToDouble

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

the class TestVectorMathFunctions method testVectorRound.

@Test
public void testVectorRound() throws HiveException {
    VectorizedRowBatch b = getVectorizedRowBatchDoubleInDoubleOut();
    VectorExpression expr = new FuncRoundDoubleToDouble(0, 1);
    DoubleColumnVector resultV = (DoubleColumnVector) b.cols[1];
    b.cols[0].noNulls = true;
    expr.evaluate(b);
    Assert.assertEquals(-2d, resultV.vector[0], Double.MIN_VALUE);
    Assert.assertEquals(-1d, resultV.vector[1], Double.MIN_VALUE);
    Assert.assertEquals(0d, resultV.vector[2], Double.MIN_VALUE);
    Assert.assertEquals(0d, resultV.vector[3], Double.MIN_VALUE);
    Assert.assertEquals(1d, resultV.vector[4], Double.MIN_VALUE);
    Assert.assertEquals(1d, resultV.vector[5], Double.MIN_VALUE);
    Assert.assertEquals(2d, resultV.vector[6], Double.MIN_VALUE);
    // spot check null propagation
    b.cols[0].noNulls = false;
    b.cols[0].isNull[3] = true;
    resultV.noNulls = true;
    expr.evaluate(b);
    Assert.assertEquals(true, resultV.isNull[3]);
    Assert.assertEquals(false, resultV.noNulls);
    // check isRepeating propagation
    b.cols[0].isRepeating = true;
    resultV.isRepeating = false;
    expr.evaluate(b);
    Assert.assertEquals(-2d, resultV.vector[0], Double.MIN_VALUE);
    Assert.assertEquals(true, resultV.isRepeating);
    resultV.isRepeating = false;
    b.cols[0].noNulls = true;
    expr.evaluate(b);
    Assert.assertEquals(-2d, resultV.vector[0], Double.MIN_VALUE);
    Assert.assertEquals(true, resultV.isRepeating);
}
Also used : VectorizedRowBatch(org.apache.hadoop.hive.ql.exec.vector.VectorizedRowBatch) DoubleColumnVector(org.apache.hadoop.hive.ql.exec.vector.DoubleColumnVector) FuncRoundDoubleToDouble(org.apache.hadoop.hive.ql.exec.vector.expressions.gen.FuncRoundDoubleToDouble) Test(org.junit.Test)

Aggregations

DoubleColumnVector (org.apache.hadoop.hive.ql.exec.vector.DoubleColumnVector)1 VectorizedRowBatch (org.apache.hadoop.hive.ql.exec.vector.VectorizedRowBatch)1 FuncRoundDoubleToDouble (org.apache.hadoop.hive.ql.exec.vector.expressions.gen.FuncRoundDoubleToDouble)1 Test (org.junit.Test)1