| 5322 | |
| 5323 | @pytest.mark.dataset |
| 5324 | def test_dataset_join_unique_key(tempdir): |
| 5325 | t1 = pa.table({ |
| 5326 | "colA": [1, 2, 6], |
| 5327 | "col2": ["a", "b", "f"] |
| 5328 | }) |
| 5329 | ds.write_dataset(t1, tempdir / "t1", format="ipc") |
| 5330 | ds1 = ds.dataset(tempdir / "t1", format="ipc") |
| 5331 | |
| 5332 | t2 = pa.table({ |
| 5333 | "colA": [99, 2, 1], |
| 5334 | "col3": ["Z", "B", "A"] |
| 5335 | }) |
| 5336 | ds.write_dataset(t2, tempdir / "t2", format="ipc") |
| 5337 | ds2 = ds.dataset(tempdir / "t2", format="ipc") |
| 5338 | |
| 5339 | result = ds1.join(ds2, "colA") |
| 5340 | assert result.to_table() == pa.table({ |
| 5341 | "colA": [1, 2, 6], |
| 5342 | "col2": ["a", "b", "f"], |
| 5343 | "col3": ["A", "B", None] |
| 5344 | }) |
| 5345 | |
| 5346 | result = ds1.join(ds2, "colA", join_type="full outer", right_suffix="_r") |
| 5347 | assert result.to_table().sort_by("colA") == pa.table({ |
| 5348 | "colA": [1, 2, 6, 99], |
| 5349 | "col2": ["a", "b", "f", None], |
| 5350 | "col3": ["A", "B", None, "Z"] |
| 5351 | }) |
| 5352 | |
| 5353 | |
| 5354 | @pytest.mark.dataset |