def METHOD_NAME(
    url: sqlalchemy.engine.url.URL,
    required_parameters: Set[str],
    optional_parameters: Set[str],
) -> None:
    """Checks that the query parameters in the URL only include the valid parameters specified."""
    query_keys = set(url.query.keys())
    errors = []
    if not query_keys.issuperset(required_parameters):
        errors.append(f"Missing required parameters {required_parameters - query_keys}")
    if not query_keys.issubset(required_parameters.union(optional_parameters)):
        errors.append(f"Found extra parameters {query_keys - required_parameters.union(optional_parameters)}")
    if errors:
        raise ValueError(f"Found errors in the URL: {url}\n" + "\n".join(errors))