Commit a43e725
authored
fix: implement RowIdMeta.asdict() and from_dict() for stable row ID serialization (#6405)
Fixes #6403
`FragmentMetadata.to_json()` raised `NotImplementedError` when
`row_id_meta` was present (`enable_stable_row_ids=True`), because
`PyRowIdMeta.asdict()` was stubbed out. This also broke
`FragmentMetadata.from_json()` for the round-trip, since
`RowIdMeta(**dict)` doesn't work on a PyO3 class.
### Repro
```python
import lance, pyarrow as pa
uri = "/tmp/repro.lance"
ds = lance.write_dataset(pa.table({"x": [1, 2, 3]}), uri, enable_stable_row_ids=True)
ds.get_fragments()[0].metadata.to_json() # NotImplementedError: PyRowIdMeta.asdict is not yet supported.
```
### Fix
- Implement `PyRowIdMeta.asdict()` via `pythonize` (Rust struct → Python
dict)
- Add `PyRowIdMeta.from_dict()` via `depythonize` (Python dict → Rust
struct)
- Update `FragmentMetadata.from_json()` to use `RowIdMeta.from_dict()`
instead of `RowIdMeta(**dict)`
- Add JSON round-trip test to the existing
`test_fragment_metadata_pickle` parametrized test1 parent 6199e6c commit a43e725
3 files changed
Lines changed: 20 additions & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
143 | 143 | | |
144 | 144 | | |
145 | 145 | | |
146 | | - | |
| 146 | + | |
147 | 147 | | |
148 | 148 | | |
149 | 149 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
472 | 472 | | |
473 | 473 | | |
474 | 474 | | |
475 | | - | |
476 | 475 | | |
477 | 476 | | |
| 477 | + | |
| 478 | + | |
| 479 | + | |
| 480 | + | |
| 481 | + | |
| 482 | + | |
| 483 | + | |
| 484 | + | |
478 | 485 | | |
479 | 486 | | |
480 | 487 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
627 | 627 | | |
628 | 628 | | |
629 | 629 | | |
630 | | - | |
631 | | - | |
632 | | - | |
633 | | - | |
| 630 | + | |
| 631 | + | |
| 632 | + | |
| 633 | + | |
634 | 634 | | |
635 | 635 | | |
636 | 636 | | |
| |||
650 | 650 | | |
651 | 651 | | |
652 | 652 | | |
| 653 | + | |
| 654 | + | |
| 655 | + | |
| 656 | + | |
| 657 | + | |
| 658 | + | |
| 659 | + | |
653 | 660 | | |
654 | 661 | | |
655 | 662 | | |
| |||
0 commit comments