@Test public void testMixedNullAndNonNullPositions() { // if there are no parameters skip this test List<Type> parameterTypes = getFunction().getParameterTypes(); if (parameterTypes.isEmpty()) { return; } Block[] alternatingNullsBlocks = createAlternatingNullsBlock(parameterTypes, getSequenceBlocks(0, 10)); testAggregation(getExpectedValueIncludingNulls(0, 10, 20), alternatingNullsBlocks); }
@Test public void testNoPositions() { testAggregation(getExpectedValue(0, 0), getSequenceBlocks(0, 0)); }
@Test public void testAllPositionsNull() { // if there are no parameters skip this test List<Type> parameterTypes = getFunction().getParameterTypes(); if (parameterTypes.isEmpty()) { return; } Block[] blocks = new Block[parameterTypes.size()]; for (int i = 0; i < parameterTypes.size(); i++) { blocks[i] = RunLengthEncodedBlock.create(parameterTypes.get(0), null, 10); } testAggregation(getExpectedValueIncludingNulls(0, 0, 10), blocks); }
protected final InternalAggregationFunction getFunction() { Signature signature = functionRegistry.resolveFunction(QualifiedName.of(getFunctionName()), Lists.transform(getFunctionParameterTypes(), TypeSignature::parseTypeSignature), isApproximate()); return functionRegistry.getAggregateFunctionImplementation(signature); }
protected final InternalAggregationFunction getFunction() { List<TypeSignatureProvider> parameterTypes = fromTypeSignatures(Lists.transform(getFunctionParameterTypes(), TypeSignature::parseTypeSignature)); Signature signature = functionRegistry.resolveFunction(QualifiedName.of(getFunctionName()), parameterTypes); return functionRegistry.getAggregateFunctionImplementation(signature); }
protected void testAggregation(Object expectedValue, Block... blocks) { assertAggregation(getFunction(), getConfidence(), expectedValue, blocks); } }
public Object getExpectedValueIncludingNulls(int start, int length, int lengthIncludingNulls) { return getExpectedValue(start, length); }
protected void testAggregation(Object expectedValue, Block... blocks) { assertAggregation(getFunction(), expectedValue, blocks); } }
@Test public void testAllPositionsNull() throws Exception { // if there are no parameters skip this test List<Type> parameterTypes = getFunction().getParameterTypes(); if (parameterTypes.isEmpty()) { return; } Block[] blocks = new Block[parameterTypes.size()]; for (int i = 0; i < parameterTypes.size(); i++) { Block nullValueBlock = parameterTypes.get(0).createBlockBuilder(new BlockBuilderStatus(), 1) .appendNull() .build(); blocks[i] = new RunLengthEncodedBlock(nullValueBlock, 10); } testAggregation(getExpectedValueIncludingNulls(0, 0, 10), blocks); }
public Object getExpectedValueIncludingNulls(int start, int length, int lengthIncludingNulls) { return getExpectedValue(start, length); }
@Test public void testSinglePosition() { testAggregation(getExpectedValue(0, 1), getSequenceBlocks(0, 1)); }
@Test public void testMixedNullAndNonNullPositions() { // if there are no parameters skip this test List<Type> parameterTypes = getFunction().getParameterTypes(); if (parameterTypes.isEmpty()) { return; } Block[] alternatingNullsBlocks = createAlternatingNullsBlock(parameterTypes, getSequenceBlocks(0, 10)); testAggregation(getExpectedValueIncludingNulls(0, 10, 20), alternatingNullsBlocks); }
@Test public void testPositiveOnlyValues() { testAggregation(getExpectedValue(2, 4), getSequenceBlocks(2, 4)); }
@Test public void testMultiplePositions() { testAggregation(getExpectedValue(0, 5), getSequenceBlocks(0, 5)); }
@Test public void testNegativeOnlyValues() { testAggregation(getExpectedValue(-10, 5), getSequenceBlocks(-10, 5)); }
@Test public void testMultiplePositions() { testAggregation(getExpectedValue(0, 5), getSequenceBlocks(0, 5)); }
@Test public void testSinglePosition() { testAggregation(getExpectedValue(0, 1), getSequenceBlocks(0, 1)); }
@Test public void testNegativeOnlyValues() { testAggregation(getExpectedValue(-10, 5), getSequenceBlocks(-10, 5)); }
@Test public void testNoPositions() { testAggregation(getExpectedValue(0, 0), getSequenceBlocks(0, 0)); }
@Test public void testPositiveOnlyValues() { testAggregation(getExpectedValue(2, 4), getSequenceBlocks(2, 4)); }