import fnmatch


def _table_matches_any_pattern(schema, table, patterns):
    """Test if the table `<schema>.<table>` matches any of the provided patterns.

    Will attempt to match both `schema.table` and just `table` against each pattern.

    Params:
        - schema.      Name of the schema the table belongs to.
        - table.       Name of the table.
        - patterns.    The patterns to try.
    """
    qual_name = '{}.{}'.format(schema, table)
    return any(fnmatch.fnmatch(qual_name, each) or fnmatch.fnmatch(table, each)
               for each in patterns)