@Test public void testEmptyStateOutputIsNull() { InternalAggregationFunction aggregationFunction = getInternalAggregationFunction(BIGINT, BIGINT); GroupedAccumulator groupedAccumulator = aggregationFunction.bind(Ints.asList(), Optional.empty()).createGroupedAccumulator(); BlockBuilder blockBuilder = groupedAccumulator.getFinalType().createBlockBuilder(null, 1); groupedAccumulator.evaluateFinal(0, blockBuilder); assertTrue(blockBuilder.isNull(0)); }
@Test public void testEmptyHistogramOutputsNull() { InternalAggregationFunction function = getInternalDefaultVarCharAggregationn(); GroupedAccumulator groupedAccumulator = function.bind(Ints.asList(new int[] {}), Optional.empty()) .createGroupedAccumulator(); BlockBuilder blockBuilder = groupedAccumulator.getFinalType().createBlockBuilder(null, 1000); groupedAccumulator.evaluateFinal(0, blockBuilder); assertTrue(blockBuilder.isNull(0)); }
@Test public void testEmptyStateOutputsNull() { InternalAggregationFunction bigIntAgg = metadata.getFunctionRegistry().getAggregateFunctionImplementation( new Signature("array_agg", AGGREGATE, parseTypeSignature("array(bigint)"), parseTypeSignature(StandardTypes.BIGINT))); GroupedAccumulator groupedAccumulator = bigIntAgg.bind(Ints.asList(new int[] {}), Optional.empty()) .createGroupedAccumulator(); BlockBuilder blockBuilder = groupedAccumulator.getFinalType().createBlockBuilder(null, 1000); groupedAccumulator.evaluateFinal(0, blockBuilder); assertTrue(blockBuilder.isNull(0)); }
for (int j = 0; j < blockBuilder.getPositionCount(); j++) { if (!blockBuilder.isNull(j)) { assertEquals(typedSet.positionOf(blockBuilder, j), j - nullCount + 1);