Package org.apache.hadoop.hive.ql.exec.vector.expressions.gen

Examples of org.apache.hadoop.hive.ql.exec.vector.expressions.gen.DecimalScalarModuloDecimalColumn


  // Spot check decimal scalar-column modulo
  @Test
  public void testDecimalScalarModuloDecimalColumn() {
    VectorizedRowBatch b = getVectorizedRowBatch3DecimalCols();
    Decimal128 d = new Decimal128("2.00", (short) 2);
    VectorExpression expr = new DecimalScalarModuloDecimalColumn(d, 0, 2);

    // test without nulls
    expr.evaluate(b);
    DecimalColumnVector r = (DecimalColumnVector) b.cols[2];
    assertTrue(r.vector[0].equals(new Decimal128("0.80", (short) 2)));
    assertTrue(r.vector[1].equals(new Decimal128("2.00", (short) 2)));
    assertFalse(r.noNulls); // entry 2 will be null due to zero-divide
    assertTrue(r.isNull[2]);

    // try again with some different data values
    DecimalColumnVector in = (DecimalColumnVector) b.cols[0];
    in.vector[0].update("0.50", (short) 2);
    in.vector[1].update("0.80", (short) 2);
    in.vector[2].update("0.70", (short) 2);

    expr.evaluate(b);
    assertTrue(r.vector[0].equals(new Decimal128("0.00", (short) 2)));
    assertTrue(r.vector[1].equals(new Decimal128("0.40", (short) 2)));
    assertTrue(r.vector[2].equals(new Decimal128("0.60", (short) 2)));
  }
View Full Code Here


  // Spot check decimal scalar-column modulo
  @Test
  public void testDecimalScalarModuloDecimalColumn() {
    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")));
    assertFalse(r.noNulls); // entry 2 will be null due to zero-divide
    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")));
  }
View Full Code Here

TOP

Related Classes of org.apache.hadoop.hive.ql.exec.vector.expressions.gen.DecimalScalarModuloDecimalColumn

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.