use of org.apache.phoenix.expression.function.ScalarFunction in project phoenix by apache.
the class RoundFloorCeilExpressionsTest method testCeilDecimalExpressionKeyRangeCoverage.
@Test
public void testCeilDecimalExpressionKeyRangeCoverage() throws Exception {
for (int scale : SCALES) {
ScalarFunction ceilDecimalExpression = (ScalarFunction) CeilDecimalExpression.create(DUMMY_DECIMAL, scale);
KeyPart keyPart = ceilDecimalExpression.newKeyPart(null);
verifyKeyPart(RoundingType.CEIL, scale, keyPart);
}
}
use of org.apache.phoenix.expression.function.ScalarFunction in project phoenix by apache.
the class RoundFloorCeilExpressionsTest method testFloorDecimalExpressionKeyRangeSimple.
@Test
public void testFloorDecimalExpressionKeyRangeSimple() throws Exception {
ScalarFunction floorDecimalExpression = (ScalarFunction) FloorDecimalExpression.create(DUMMY_DECIMAL, 3);
byte[] upperBound = PDecimal.INSTANCE.toBytes(new BigDecimal("1.239"));
byte[] lowerBound = PDecimal.INSTANCE.toBytes(new BigDecimal("1.238"));
KeyRange expectedKeyRange = KeyRange.getKeyRange(lowerBound, true, upperBound, false);
KeyPart keyPart = floorDecimalExpression.newKeyPart(null);
assertEquals(expectedKeyRange, keyPart.getKeyRange(CompareOp.EQUAL, LiteralExpression.newConstant(new BigDecimal("1.238"), PDecimal.INSTANCE)));
}
use of org.apache.phoenix.expression.function.ScalarFunction in project phoenix by apache.
the class RoundFloorCeilExpressionsTest method testRoundDecimalExpressionKeyRangeCoverage.
// KeyRange complex / generated tests
@Test
public void testRoundDecimalExpressionKeyRangeCoverage() throws Exception {
for (int scale : SCALES) {
ScalarFunction roundDecimalExpression = (ScalarFunction) RoundDecimalExpression.create(DUMMY_DECIMAL, scale);
KeyPart keyPart = roundDecimalExpression.newKeyPart(null);
verifyKeyPart(RoundingType.ROUND, scale, keyPart);
}
}
use of org.apache.phoenix.expression.function.ScalarFunction in project phoenix by apache.
the class RoundFloorCeilExpressionsTest method testFloorDecimalExpressionKeyRangeCoverage.
@Test
public void testFloorDecimalExpressionKeyRangeCoverage() throws Exception {
for (int scale : SCALES) {
ScalarFunction floorDecimalExpression = (ScalarFunction) FloorDecimalExpression.create(DUMMY_DECIMAL, scale);
KeyPart keyPart = floorDecimalExpression.newKeyPart(null);
verifyKeyPart(RoundingType.FLOOR, scale, keyPart);
}
}
use of org.apache.phoenix.expression.function.ScalarFunction in project phoenix by apache.
the class RoundFloorCeilExpressionsTest method testCeilDecimalExpressionKeyRangeSimple.
@Test
public void testCeilDecimalExpressionKeyRangeSimple() throws Exception {
ScalarFunction ceilDecimalExpression = (ScalarFunction) CeilDecimalExpression.create(DUMMY_DECIMAL, 3);
byte[] upperBound = PDecimal.INSTANCE.toBytes(new BigDecimal("1.238"));
byte[] lowerBound = PDecimal.INSTANCE.toBytes(new BigDecimal("1.237"));
KeyRange expectedKeyRange = KeyRange.getKeyRange(lowerBound, false, upperBound, true);
KeyPart keyPart = ceilDecimalExpression.newKeyPart(null);
assertEquals(expectedKeyRange, keyPart.getKeyRange(CompareOp.EQUAL, LiteralExpression.newConstant(new BigDecimal("1.238"), PDecimal.INSTANCE)));
}
Aggregations