postgresql average function using with phalcon

Hello, I am keep getting this error

SQLSTATE[42883]: Undefined function: 7 ERROR: function avg() does not exist LINE 1: SELECT AVG(*) AS "average" FROM "system"."user_rating" ^ HINT: No function matches the given name and argument types. You might need to add explicit type casts.

My model function looks like:

public function countAverage()
{
     $rating=User_Rating::average(array(
        [
            'columns' => 'rating'
        ]
    ));

     return $rating;
}

I call it from controller: $rating = new \Models\User; $avgUser = $rating->countAverage();

    $this -> view -> users = $avgUser;

    var_dump($avgUser);
    die;

My rating column is real type, phalcon function average returns and takes double value. What I am doing wrong?

Okey, I found a problem it is because sql looks like SELECT AVG(*) AS "average" FROM "system"."user_rating".

It would work, if it would build like: SELECT AVG("rating") AS "average" FROM "system"."user_rating".

But I can't get the right query.