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

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


  // Spot check decimal column-column multiply
  @Test
  public void testDecimalColMultiplyDecimalColumn() {
    VectorizedRowBatch b = getVectorizedRowBatch3DecimalCols();
    VectorExpression expr = new DecimalColMultiplyDecimalColumn(0, 1, 2);
    DecimalColumnVector r = (DecimalColumnVector) b.cols[2];

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

    // test that underflow produces NULL
    b = getVectorizedRowBatch3DecimalCols();
    DecimalColumnVector c0 = (DecimalColumnVector) b.cols[0];
    c0.vector[0].update("9999999999999999.99", (short) 2); // set to max possible value
    DecimalColumnVector c1 = (DecimalColumnVector) b.cols[1];
    c1.vector[0].update("2", (short) 2);
    r = (DecimalColumnVector) b.cols[2];
    expr.evaluate(b); // will cause overflow for result at position 0, must yield NULL
    assertTrue(!r.noNulls && r.isNull[0]);
  }
View Full Code Here


  // Spot check decimal column-column multiply
  @Test
  public void testDecimalColMultiplyDecimalColumn() {
    VectorizedRowBatch b = getVectorizedRowBatch3DecimalCols();
    VectorExpression expr = new DecimalColMultiplyDecimalColumn(0, 1, 2);
    DecimalColumnVector r = (DecimalColumnVector) b.cols[2];

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

    // test that underflow produces NULL
    b = getVectorizedRowBatch3DecimalCols();
    DecimalColumnVector c0 = (DecimalColumnVector) b.cols[0];
    c0.vector[0].update("9999999999999999.99", (short) 2); // set to max possible value
    DecimalColumnVector c1 = (DecimalColumnVector) b.cols[1];
    c1.vector[0].update("2", (short) 2);
    r = (DecimalColumnVector) b.cols[2];
    expr.evaluate(b); // will cause overflow for result at position 0, must yield NULL
    assertTrue(!r.noNulls && r.isNull[0]);
  }
View Full Code Here

  // Spot check decimal column-column multiply
  @Test
  public void testDecimalColMultiplyDecimalColumn() {
    VectorizedRowBatch b = getVectorizedRowBatch3DecimalCols();
    VectorExpression expr = new DecimalColMultiplyDecimalColumn(0, 1, 2);
    DecimalColumnVector r = (DecimalColumnVector) b.cols[2];

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

    // test that underflow produces NULL
    b = getVectorizedRowBatch3DecimalCols();
    DecimalColumnVector c0 = (DecimalColumnVector) b.cols[0];
    c0.vector[0].set(HiveDecimal.create("9999999999999999.99")); // set to max possible value
    DecimalColumnVector c1 = (DecimalColumnVector) b.cols[1];
    c1.vector[0].set(HiveDecimal.create("2.00"));
    r = (DecimalColumnVector) b.cols[2];
    expr.evaluate(b); // will cause overflow for result at position 0, must yield NULL
    assertTrue(!r.noNulls && r.isNull[0]);
  }
View Full Code Here

  // Spot check decimal column-column multiply
  @Test
  public void testDecimalColMultiplyDecimalColumn() {
    VectorizedRowBatch b = getVectorizedRowBatch3DecimalCols();
    VectorExpression expr = new DecimalColMultiplyDecimalColumn(0, 1, 2);
    DecimalColumnVector r = (DecimalColumnVector) b.cols[2];

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

    // test that underflow produces NULL
    b = getVectorizedRowBatch3DecimalCols();
    DecimalColumnVector c0 = (DecimalColumnVector) b.cols[0];
    c0.vector[0].set(HiveDecimal.create("9999999999999999.99")); // set to max possible value
    DecimalColumnVector c1 = (DecimalColumnVector) b.cols[1];
    c1.vector[0].set(HiveDecimal.create("2.00"));
    r = (DecimalColumnVector) b.cols[2];
    expr.evaluate(b); // will cause overflow for result at position 0, must yield NULL
    assertTrue(!r.noNulls && r.isNull[0]);
  }
View Full Code Here

TOP

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

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.