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

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


  // Spot check Decimal Col-Scalar Modulo
  @Test
  public void testDecimalColModuloDecimalScalar() {
    VectorizedRowBatch b = getVectorizedRowBatch3DecimalCols();
    Decimal128 d = new Decimal128("2.00", (short) 2);
    VectorExpression expr = new DecimalColModuloDecimalScalar(0, d, 2);

    // test without nulls
    expr.evaluate(b);
    DecimalColumnVector r = (DecimalColumnVector) b.cols[2];
    assertTrue(r.vector[0].equals(new Decimal128("1.20", (short) 2)));
    assertTrue(r.vector[1].equals(new Decimal128("-1.30", (short) 2)));
    assertTrue(r.vector[2].equals(new Decimal128("0", (short) 2)));

    // try again with some different data values and divisor
    DecimalColumnVector in = (DecimalColumnVector) b.cols[0];
    in.vector[0].update("15.40", (short) 2);
    in.vector[1].update("-17.20", (short) 2);
    in.vector[2].update("70.00", (short) 2);
    d.update("4.75", (short) 2);

    expr.evaluate(b);
    assertTrue(r.vector[0].equals(new Decimal128("1.15", (short) 2)));
    assertTrue(r.vector[1].equals(new Decimal128("-2.95", (short) 2)));
    assertTrue(r.vector[2].equals(new Decimal128("3.50", (short) 2)));

    // try a zero-divide to show a repeating NULL is produced
    d.update("0", (short) 2);
    expr.evaluate(b);
    assertFalse(r.noNulls);
    assertTrue(r.isNull[0]);
    assertTrue(r.isRepeating);
  }
View Full Code Here


  // Spot check Decimal Col-Scalar Modulo
  @Test
  public void testDecimalColModuloDecimalScalar() {
    VectorizedRowBatch b = getVectorizedRowBatch3DecimalCols();
    HiveDecimal d = HiveDecimal.create("2.00");
    VectorExpression expr = new DecimalColModuloDecimalScalar(0, d, 2);

    // test without nulls
    expr.evaluate(b);
    DecimalColumnVector r = (DecimalColumnVector) b.cols[2];
    assertTrue(r.vector[0].getHiveDecimal().equals(HiveDecimal.create("1.20")));
    assertTrue(r.vector[1].getHiveDecimal().equals(HiveDecimal.create("-1.30")));
    assertTrue(r.vector[2].getHiveDecimal().equals(HiveDecimal.create("0")));

    // try again with some different data values and divisor
    DecimalColumnVector in = (DecimalColumnVector) b.cols[0];
    in.vector[0].set(HiveDecimal.create("15.40"));
    in.vector[1].set(HiveDecimal.create("-17.20"));
    in.vector[2].set(HiveDecimal.create("70.00"));
    d = HiveDecimal.create("4.75");
    expr = new DecimalColModuloDecimalScalar(0, d, 2);

    expr.evaluate(b);
    assertTrue(r.vector[0].getHiveDecimal().equals(HiveDecimal.create("1.15")));
    assertTrue(r.vector[1].getHiveDecimal().equals(HiveDecimal.create("-2.95")));
    assertTrue(r.vector[2].getHiveDecimal().equals(HiveDecimal.create("3.50")));

    // try a zero-divide to show a repeating NULL is produced
    d = HiveDecimal.create("0.00");
    expr = new DecimalColModuloDecimalScalar(0, d, 2);
    expr.evaluate(b);
    assertFalse(r.noNulls);
    assertTrue(r.isNull[0]);
    assertTrue(r.isRepeating);
  }
View Full Code Here

TOP

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

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.