use of org.apache.phoenix.expression.function.CeilDecimalExpression in project phoenix by apache.
the class RoundFloorCeilExpressionsTest method testCeilDecimalExpressionNoop.
@Test
public void testCeilDecimalExpressionNoop() throws Exception {
LiteralExpression decimalLiteral = LiteralExpression.newConstant(5, PInteger.INSTANCE);
Expression ceilDecimalExpression = CeilDecimalExpression.create(decimalLiteral, 3);
assertEquals(ceilDecimalExpression, decimalLiteral);
}
use of org.apache.phoenix.expression.function.CeilDecimalExpression in project phoenix by apache.
the class RoundFloorCeilExpressionsTest method testCeilDecimalExpression.
@Test
public void testCeilDecimalExpression() throws Exception {
LiteralExpression decimalLiteral = LiteralExpression.newConstant(1.23898, PDecimal.INSTANCE);
Expression ceilDecimalExpression = CeilDecimalExpression.create(decimalLiteral, 3);
ImmutableBytesWritable ptr = new ImmutableBytesWritable();
ceilDecimalExpression.evaluate(null, ptr);
Object result = ceilDecimalExpression.getDataType().toObject(ptr);
assertTrue(result instanceof BigDecimal);
BigDecimal resultDecimal = (BigDecimal) result;
assertEquals(BigDecimal.valueOf(1.239), resultDecimal);
}
Aggregations