def METHOD_NAME(exception):
    return errors.exception_matches(
        exception,
        classname_with_package="impala.error.OperationalError",
        exception_message_matcher_regex=".*Scratch space limit.*",
    ) or errors.exception_matches(
        exception,
        classname_with_package="impala.error.OperationalError",
        exception_message_matcher_regex=".*Memory limit exceeded.*",
    )