Fix Exception when using subscript operator in aggregation query