### Question:
DecimalSumAggregation extends SqlAggregationFunction { public static void outputLongDecimal(DecimalType type, LongDecimalWithOverflowState state, BlockBuilder out) { if (state.getLongDecimal() == null) { out.appendNull(); } else { if (state.getOverflow() != 0) { throwOverflowException(); } throwIfOverflows(state.getLongDecimal()); type.writeSlice(out, state.getLongDecimal()); } } DecimalSumAggregation(); @Override List<TypeSignature> getIntermediateTypes(FunctionBinding functionBinding); @Override InternalAggregationFunction specialize(FunctionBinding functionBinding); static void inputShortDecimal(Type type, LongDecimalWithOverflowState state, Block block, int position); static void inputLongDecimal(Type type, LongDecimalWithOverflowState state, Block block, int position); static void combine(LongDecimalWithOverflowState state, LongDecimalWithOverflowState otherState); static void outputLongDecimal(DecimalType type, LongDecimalWithOverflowState state, BlockBuilder out); static final DecimalSumAggregation DECIMAL_SUM_AGGREGATION; }### Answer:
@Test(expectedExceptions = ArithmeticException.class) public void testOverflowOnOutput() { addToState(state, TWO.pow(126)); addToState(state, TWO.pow(126)); assertEquals(state.getOverflow(), 1); DecimalSumAggregation.outputLongDecimal(TYPE, state, new VariableWidthBlockBuilder(null, 10, 100)); }