public function formatFunction(Func $func) {
        $arguments = [];

        foreach ($func->getArguments() as $arg) {
            $type = $arg['type'];
            $value = $arg['value'];

            if ($value instanceof Func) {
                $value = $this->formatFunction($value);

            } else if ($value instanceof SubQuery) {
                $value = $this->formatSubQuery($value);

            } else if ($type === Func::FIELD) {
                $value = $this->quote($value);

            } else if ($type === Func::LITERAL) {
                // Do nothing

            } else if (is_string($value) || $value === null) {
                $value = $this->getDriver()->escape($value);
            }

            $arguments[] = $value;
        }

        $output = sprintf($this->getClause(self::FUNC),
            $func->getName(),
            implode($func->getSeparator(), $arguments)
        );

        if ($alias = $func->getAlias()) {
            $output = sprintf($this->getClause(self::AS_ALIAS), $output, $this->quote($alias));
        }

        return $output;
    }