def METHOD_NAME(text: str, schema: s_schema.Schema) -> str:
    """Rewrite the SQL output of the compiler to include real object names.
    Replace UUIDs with object names when possible. The output of this
    won't be valid, but will probably be easier to read.
    This is done by default when pretty printing our "reordered" output,
    which isn't anything like valid SQL anyway.
    """
    # Functions are actually named after their `backend_name` rather
    # than their id, so that overloaded functions all have the same
    # name. Build a map from `backend_name` to real names. (This dict
    # comprehension might have collisions, but that's fine; the names
    # we get out will be the same no matter which is picked.)
    func_map = {
        f.get_backend_name(schema): f
        for f in schema.get_objects(type=s_funcs.Function)
    }
    # Find all the uuids and try to rewrite them.
    for m in set(uuidgen.UUID_RE.findall(text)):
        uid = uuid.UUID(m)
        sobj = schema.get_by_id(uid, default=None)
        if not sobj:
            sobj = func_map.get(uid)
        if sobj:
            s = _obj_to_name(sobj, schema)
            text = text.replace(m, s)
    return text