Repository: pola-rs/polars
File: py-polars/tests/unit/io/test_multiscan.py (Python)

Code before:
        scan(g, row_index_name="ri", row_index_offset=start).slice(3, 3).collect(),
        pl.DataFrame(
            [
                pl.Series("ri", range(start + 3, start + 6), get_index_type()),
                col.slice(3, 3),
            ]
        ),
    )

    start = 42
    assert_frame_equal(
        scan(g, row_index_name="ri", row_index_offset=start)
        .filter(pl.col("col") < 15)
        .collect(),
        pl.DataFrame(
            [
                pl.Series("ri", [start + 0, start + 1, start + 4], get_index_type()),
                pl.Series("col", [5, 10, 13]),
            ]
        ),
    )

    with pytest.raises(
        pl.exceptions.DuplicateError, match="'index' has more than one occurrence"
    ):
        scan(g).with_row_index().with_row_index().collect()
    assert_frame_equal(
        scan(g)
        .with_row_index()
        .with_row_index("index_1", offset=1)
        .with_row_index("index_2", offset=2)
        .collect(),
        pl.DataFrame(
            [
                pl.Series("index_2", [2, 3, 4, 5, 6, 7], get_index_type()),
                pl.Series("index_1", [1, 2, 3, 4, 5, 6], get_index_type()),
                pl.Series("index", [0, 1, 2, 3, 4, 5], get_index_type()),
                col,
            ]
        ),
    )


@pytest.mark.parametrize(
    ("scan", "write", "ext"),
    [
        (pl.scan_ipc, pl.DataFrame.write_ipc, "ipc"),
        (pl.scan_parquet, pl.DataFrame.write_parquet, "parquet"),
        pytest.param(
            pl.scan_csv,
            pl.DataFrame.write_csv,

Review comment (suggestion):
```suggestion
        scan(g).with_row_index().with_row_index().collect()

```

Code after:
        scan(g, row_index_name="ri", row_index_offset=start).slice(3, 3).collect(),
        pl.DataFrame(
            [
                pl.Series("ri", range(start + 3, start + 6), get_index_type()),
                col.slice(3, 3),
            ]
        ),
    )

    start = 42
    assert_frame_equal(
        scan(g, row_index_name="ri", row_index_offset=start)
        .filter(pl.col("col") < 15)
        .collect(),
        pl.DataFrame(
            [
                pl.Series("ri", [start + 0, start + 1, start + 4], get_index_type()),
                pl.Series("col", [5, 10, 13]),
            ]
        ),
    )

    with pytest.raises(
        pl.exceptions.DuplicateError, match="'index' has more than one occurrence"
    ):
        scan(g).with_row_index().with_row_index().collect()

    assert_frame_equal(
        scan(g)
        .with_row_index()
        .with_row_index("index_1", offset=1)
        .with_row_index("index_2", offset=2)
        .collect(),
        pl.DataFrame(
            [
                pl.Series("index_2", [2, 3, 4, 5, 6, 7], get_index_type()),
                pl.Series("index_1", [1, 2, 3, 4, 5, 6], get_index_type()),
                pl.Series("index", [0, 1, 2, 3, 4, 5], get_index_type()),
                col,
            ]
        ),
    )


@pytest.mark.parametrize(
    ("scan", "write", "ext"),
    [
        (pl.scan_ipc, pl.DataFrame.write_ipc, "ipc"),
        (pl.scan_parquet, pl.DataFrame.write_parquet, "parquet"),
        pytest.param(
            pl.scan_csv,