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