@Override public KeyPart newKeyPart(KeyPart childPart) { return udfFunction.newKeyPart(childPart); }
private KeySlots newScalarFunctionKeyPart(KeySlot slot, ScalarFunction node) { if (isDegenerate(slot.getKeyRanges())) { return EMPTY_KEY_SLOTS; } KeyPart part = node.newKeyPart(slot.getKeyPart()); if (part == null) { return null; } // Scalar function always returns primitive and never a row value constructor, so span is always 1 return new SingleKeySlot(part, slot.getPKPosition(), slot.getKeyRanges(), node.preservesOrder()); }
@Test public void testFloorDecimalExpressionKeyRangeCoverage() throws Exception { KeyPart baseKeyPart = getDecimalKeyPart(); for(int scale : SCALES) { ScalarFunction floorDecimalExpression = (ScalarFunction) FloorDecimalExpression.create(DUMMY_DECIMAL, scale); KeyPart keyPart = floorDecimalExpression.newKeyPart(baseKeyPart); verifyKeyPart(RoundingType.FLOOR, scale, keyPart); } }
@Test public void testRoundDecimalExpressionKeyRangeCoverage() throws Exception { KeyPart baseKeyPart = getDecimalKeyPart(); for(int scale : SCALES) { ScalarFunction roundDecimalExpression = (ScalarFunction) RoundDecimalExpression.create(DUMMY_DECIMAL, scale); KeyPart keyPart = roundDecimalExpression.newKeyPart(baseKeyPart); verifyKeyPart(RoundingType.ROUND, scale, keyPart); } }
@Test public void testCeilDecimalExpressionKeyRangeCoverage() throws Exception { KeyPart baseKeyPart = getDecimalKeyPart(); for(int scale : SCALES) { ScalarFunction ceilDecimalExpression = (ScalarFunction) CeilDecimalExpression.create(DUMMY_DECIMAL, scale); KeyPart keyPart = ceilDecimalExpression.newKeyPart(baseKeyPart); verifyKeyPart(RoundingType.CEIL, scale, keyPart); } }
@Test public void testFloorDecimalExpressionKeyRangeSimple() throws Exception { KeyPart baseKeyPart = getDecimalKeyPart(); 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(baseKeyPart); assertEquals(expectedKeyRange, keyPart.getKeyRange(CompareOp.EQUAL, LiteralExpression.newConstant(new BigDecimal("1.238"), PDecimal.INSTANCE))); }
@Test public void testCeilDecimalExpressionKeyRangeSimple() throws Exception { KeyPart baseKeyPart = getDecimalKeyPart(); 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(baseKeyPart); assertEquals(expectedKeyRange, keyPart.getKeyRange(CompareOp.EQUAL, LiteralExpression.newConstant(new BigDecimal("1.238"), PDecimal.INSTANCE))); }
@Test public void testRoundDecimalExpressionKeyRangeSimple() throws Exception { KeyPart baseKeyPart = getDecimalKeyPart(); 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(baseKeyPart); assertEquals(expectedKeyRange, keyPart.getKeyRange(CompareOp.EQUAL, LiteralExpression.newConstant(new BigDecimal("1.238"), PDecimal.INSTANCE))); }
@Override public KeyPart newKeyPart(KeyPart childPart) { return udfFunction.newKeyPart(childPart); }
@Override public KeyPart newKeyPart(KeyPart childPart) { return udfFunction.newKeyPart(childPart); }
private KeySlots newScalarFunctionKeyPart(KeySlot slot, ScalarFunction node) { if (isDegenerate(slot.getKeyRanges())) { return EMPTY_KEY_SLOTS; } KeyPart part = node.newKeyPart(slot.getKeyPart()); if (part == null) { return null; } // Scalar function always returns primitive and never a row value constructor, so span is always 1 return new SingleKeySlot(part, slot.getPKPosition(), slot.getKeyRanges(), node.preservesOrder()); }
private KeySlots newScalarFunctionKeyPart(KeySlot slot, ScalarFunction node) { if (isDegenerate(slot.getKeyRanges())) { return EMPTY_KEY_SLOTS; } KeyPart part = node.newKeyPart(slot.getKeyPart()); if (part == null) { return null; } // Scalar function always returns primitive and never a row value constructor, so span is always 1 return new SingleKeySlot(part, slot.getPKPosition(), slot.getKeyRanges(), node.preservesOrder()); }