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

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


   */
  @Test
  public void testDecimalColSubtractDecimalScalar() {
    VectorizedRowBatch b = getVectorizedRowBatch3DecimalCols();
    Decimal128 d = new Decimal128(1);
    VectorExpression expr = new DecimalColSubtractDecimalScalar(0, d, 2);

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

    // test that underflow produces null
    b = getVectorizedRowBatch3DecimalCols();
    DecimalColumnVector in = (DecimalColumnVector) b.cols[0];
    in.vector[0].update("-9999999999999999.99", (short) 2); // set to min possible value
    expr.evaluate(b);
    r = (DecimalColumnVector) b.cols[2];
    assertFalse(r.noNulls);
    assertTrue(r.isNull[0]);
  }
View Full Code Here


   */
  @Test
  public void testDecimalColSubtractDecimalScalar() {
    VectorizedRowBatch b = getVectorizedRowBatch3DecimalCols();
    Decimal128 d = new Decimal128(1);
    VectorExpression expr = new DecimalColSubtractDecimalScalar(0, d, 2);

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

    // test that underflow produces null
    b = getVectorizedRowBatch3DecimalCols();
    DecimalColumnVector in = (DecimalColumnVector) b.cols[0];
    in.vector[0].update("-9999999999999999.99", (short) 2); // set to min possible value
    expr.evaluate(b);
    r = (DecimalColumnVector) b.cols[2];
    assertFalse(r.noNulls);
    assertTrue(r.isNull[0]);
  }
View Full Code Here

   */
  @Test
  public void testDecimalColSubtractDecimalScalar() {
    VectorizedRowBatch b = getVectorizedRowBatch3DecimalCols();
    HiveDecimal d = HiveDecimal.create(1);
    VectorExpression expr = new DecimalColSubtractDecimalScalar(0, d, 2);

    // test without nulls
    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("-4.30")));
    assertTrue(r.vector[2].getHiveDecimal().equals(HiveDecimal.create("-1")));

    // test that underflow produces null
    b = getVectorizedRowBatch3DecimalCols();
    DecimalColumnVector in = (DecimalColumnVector) b.cols[0];
    in.vector[0].set(HiveDecimal.create("-9999999999999999.99")); // set to min possible value
    expr.evaluate(b);
    r = (DecimalColumnVector) b.cols[2];
    assertFalse(r.noNulls);
    assertTrue(r.isNull[0]);
  }
View Full Code Here

   */
  @Test
  public void testDecimalColSubtractDecimalScalar() {
    VectorizedRowBatch b = getVectorizedRowBatch3DecimalCols();
    HiveDecimal d = HiveDecimal.create(1);
    VectorExpression expr = new DecimalColSubtractDecimalScalar(0, d, 2);

    // test without nulls
    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("-4.30")));
    assertTrue(r.vector[2].getHiveDecimal().equals(HiveDecimal.create("-1")));

    // test that underflow produces null
    b = getVectorizedRowBatch3DecimalCols();
    DecimalColumnVector in = (DecimalColumnVector) b.cols[0];
    in.vector[0].set(HiveDecimal.create("-9999999999999999.99")); // set to min possible value
    expr.evaluate(b);
    r = (DecimalColumnVector) b.cols[2];
    assertFalse(r.noNulls);
    assertTrue(r.isNull[0]);
  }
View Full Code Here

TOP

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

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.