def test_retry_no_records_to_retry(test_session):
    """Test retry when no records need to be retried."""
    # Create dataset with all successful records
    source_ids = [1, 2]
    source_contents = ["first", "second"]

    dc.read_values(id=source_ids, content=source_contents, session=test_session).save(
        "source_data"
    )

    def successful_process(id: int, content: str) -> ProcessingResult:
        return ProcessingResult(
            processed_content=content.upper(),
            processed_at=datetime.now(tz=timezone.utc).isoformat(),
            error="",  # No errors
            attempt=1,
        )

    # First pass - all succeed
    first_pass = (
        dc.read_dataset("source_data", session=test_session)
        .map(result=successful_process)
        .save("successful_data")
    )

    assert first_pass.count() == 2
    assert first_pass.filter(C("result.error") != "").count() == 0

    # Retry - should not create a new version since no records need retry
    (
        dc.read_dataset(
            "source_data",
            session=test_session,
            delta=True,
            delta_on="id",
            delta_retry="result.error",
        )
        .map(result=successful_process)
        .save("successful_data")
    )

    # Should not create version 1.0.1 since no retry was needed
    with pytest.raises(DatasetVersionNotFoundError):
        dc.read_dataset("successful_data", version="1.0.1", session=test_session)
Test retry when no records need to be retried.
tests/func/test_retry.py