Search in sources :

Example 1 with CeilDecimalExpression

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);
}
Also used : RoundDateExpression(org.apache.phoenix.expression.function.RoundDateExpression) RoundDecimalExpression(org.apache.phoenix.expression.function.RoundDecimalExpression) FloorDateExpression(org.apache.phoenix.expression.function.FloorDateExpression) CeilDateExpression(org.apache.phoenix.expression.function.CeilDateExpression) CeilDecimalExpression(org.apache.phoenix.expression.function.CeilDecimalExpression) FloorDecimalExpression(org.apache.phoenix.expression.function.FloorDecimalExpression) Test(org.junit.Test)

Example 2 with CeilDecimalExpression

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);
}
Also used : ImmutableBytesWritable(org.apache.hadoop.hbase.io.ImmutableBytesWritable) RoundDateExpression(org.apache.phoenix.expression.function.RoundDateExpression) RoundDecimalExpression(org.apache.phoenix.expression.function.RoundDecimalExpression) FloorDateExpression(org.apache.phoenix.expression.function.FloorDateExpression) CeilDateExpression(org.apache.phoenix.expression.function.CeilDateExpression) CeilDecimalExpression(org.apache.phoenix.expression.function.CeilDecimalExpression) FloorDecimalExpression(org.apache.phoenix.expression.function.FloorDecimalExpression) BigDecimal(java.math.BigDecimal) Test(org.junit.Test)

Aggregations

CeilDateExpression (org.apache.phoenix.expression.function.CeilDateExpression)2 CeilDecimalExpression (org.apache.phoenix.expression.function.CeilDecimalExpression)2 FloorDateExpression (org.apache.phoenix.expression.function.FloorDateExpression)2 FloorDecimalExpression (org.apache.phoenix.expression.function.FloorDecimalExpression)2 RoundDateExpression (org.apache.phoenix.expression.function.RoundDateExpression)2 RoundDecimalExpression (org.apache.phoenix.expression.function.RoundDecimalExpression)2 Test (org.junit.Test)2 BigDecimal (java.math.BigDecimal)1 ImmutableBytesWritable (org.apache.hadoop.hbase.io.ImmutableBytesWritable)1