class CountExpression extends AbstractAggregationFunction {

    @Override
    public ExpressionResult apply(ExpressionContext context, ExpressionResult input) {
        ExpressionContext scoped = context.scoped(this);
        AtomicLong counter = scoped.computeIfAbsent(alias, AtomicLong::new);
        ExpressionResult expressionResult = expression == null ? input : expression.apply(context, input);
        if( expressionResult == null) {
            return new NumericExpressionResult(counter.get());
        }
        return new NumericExpressionResult(counter.addAndGet(expressionResult.count()));
    }

    public  CountExpression(String alias, Expression expression);

}