Skip to content

Commit 8999446

Browse files
committed
fix: address tag metadata review feedback
1 parent a080281 commit 8999446

4 files changed

Lines changed: 18 additions & 2 deletions

File tree

docs/src/format/table/branch_tag.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,5 +121,5 @@ Each tag file is a JSON file with the following fields:
121121
| `version` | number | | Version number being tagged within that branch. |
122122
| `createdAt` | string | Yes | RFC 3339 timestamp for when the tag was first created. |
123123
| `updatedAt` | string | Yes | RFC 3339 timestamp for the latest tag reference update. |
124-
| `manifest_size` | number | | Size of the manifest file in bytes. Used for efficient manifest loading. |
124+
| `manifestSize` | number | | Size of the manifest file in bytes. Used for efficient manifest loading. |
125125
| `metadata` | object | Yes | String key/value metadata map. If absent, it is treated as an empty object. |

python/python/lance/dataset.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5824,6 +5824,11 @@ def update(
58245824
def replace_metadata(self, tag: str, metadata: Dict[str, str]) -> None:
58255825
"""
58265826
Replace metadata for an existing tag.
5827+
5828+
This replaces the entire metadata map rather than merging with existing
5829+
keys. It does not change the tag's referenced branch/version, and it
5830+
does not update ``updated_at``. The ``updated_at`` timestamp only
5831+
changes when :meth:`update` moves the tag to a different reference.
58275832
"""
58285833
self._ds.replace_tag_metadata(tag, metadata)
58295834

python/python/tests/test_dataset.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -521,7 +521,14 @@ def test_tag(tmp_path: Path):
521521
ds.tags.replace_metadata("tag1", {"description": "updated tag"})
522522
ds = lance.dataset(base_dir, "tag1")
523523
assert ds.version == 1
524-
assert ds.tags.list()["tag1"]["metadata"] == {"description": "updated tag"}
524+
replaced_tag1_meta = ds.tags.list()["tag1"]
525+
assert replaced_tag1_meta["metadata"] == {"description": "updated tag"}
526+
assert replaced_tag1_meta["updated_at"] == tag1_updated_at
527+
528+
ds.tags.replace_metadata("tag1", {"owner": "ml-team"})
529+
replaced_again_tag1_meta = ds.tags.list()["tag1"]
530+
assert replaced_again_tag1_meta["metadata"] == {"owner": "ml-team"}
531+
assert replaced_again_tag1_meta["updated_at"] == tag1_updated_at
525532

526533
ds.tags.update("tag1", 2)
527534
updated_tag1_meta = ds.tags.list()["tag1"]
@@ -5266,10 +5273,13 @@ def test_branches(tmp_path: Path):
52665273
branch1.tags.create("main_latest", (None, None))
52675274
branch1.tags.create("main_latest2", ("main", None))
52685275
branch1.create_branch("branch_from_main", ("main", None))
5276+
ordered_tags = dict(branch1.tags.list_ordered())
52695277
branches_with_main = branch1.branches.list()
52705278
assert branch1.tags.list()["branch1_latest"]["branch"] == "branch1"
52715279
assert branch1.tags.list()["main_latest"]["branch"] is None
52725280
assert branch1.tags.list()["main_latest2"]["branch"] is None
5281+
assert ordered_tags["branch1_latest"]["branch"] == "branch1"
5282+
assert ordered_tags["main_latest"]["branch"] is None
52735283
assert branches_with_main["branch_from_main"]["parent_branch"] is None
52745284
assert branches_with_main["branch_from_main"]["branch_identifier"][0][0] == 1
52755285
assert isinstance(

python/src/dataset.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1608,6 +1608,7 @@ impl Dataset {
16081608

16091609
for (tag_name, tag_content) in tags {
16101610
let dict = PyDict::new(py);
1611+
dict.set_item("branch", tag_content.branch.clone())?;
16111612
dict.set_item("version", tag_content.version)?;
16121613
dict.set_item("created_at", tag_content.created_at)?;
16131614
dict.set_item("updated_at", tag_content.updated_at)?;

0 commit comments

Comments
 (0)