use of org.apache.phoenix.expression.function.ScalarFunction in project phoenix by apache.
the class RoundFloorCeilExpressionsTest method testRoundDecimalExpressionKeyRangeSimple.
// KeyRange explicit simple / sanity tests
@Test
public void testRoundDecimalExpressionKeyRangeSimple() throws Exception {
ScalarFunction roundDecimalExpression = (ScalarFunction) RoundDecimalExpression.create(DUMMY_DECIMAL, 3);
byte[] upperBound = PDecimal.INSTANCE.toBytes(new BigDecimal("1.2385"));
byte[] lowerBound = PDecimal.INSTANCE.toBytes(new BigDecimal("1.2375"));
KeyRange expectedKeyRange = KeyRange.getKeyRange(lowerBound, upperBound);
KeyPart keyPart = roundDecimalExpression.newKeyPart(null);
assertEquals(expectedKeyRange, keyPart.getKeyRange(CompareOp.EQUAL, LiteralExpression.newConstant(new BigDecimal("1.238"), PDecimal.INSTANCE)));
}
Aggregations