Skip to content

feat: expose branch_identifier in python and java bindings#6360

Merged
majin1102 merged 4 commits intomainfrom
codex/add-branch_identifier-to-java-and-python-bindings
Apr 1, 2026
Merged

feat: expose branch_identifier in python and java bindings#6360
majin1102 merged 4 commits intomainfrom
codex/add-branch_identifier-to-java-and-python-bindings

Conversation

@majin1102
Copy link
Copy Markdown
Contributor

@majin1102 majin1102 commented Mar 31, 2026

Motivation

  • Surface the full branch lineage (version -> uuid mapping) from Rust BranchIdentifier into higher-level bindings so clients can inspect a branch's lineage chain.

Description

  • Update the JNI layer (java/lance-jni/src/blocking_dataset.rs) to construct and pass a List<BranchVersionMapping> when creating the Java Branch object.
  • Extend the Java model (java/src/main/java/org/lance/Branch.java) with an inner BranchVersionMapping class, add a branchIdentifier field and getter, update constructor/signature, and include it in toString, equals, and hashCode.
  • Update Java tests (java/src/test/java/org/lance/DatasetTest.java) to assert the presence and contents of branchIdentifier for created branches.
  • Add branch_identifier: List[Tuple[int, str]] to the Python Branch TypedDict (python/python/lance/dataset.py) and update the Python Rust bridge (python/src/dataset.rs) to include meta.identifier.version_mapping in the returned branch dictionaries.
  • Update Python tests (python/python/tests/test_dataset.py) to validate the branch_identifier contents in branches.list() responses.

Testing

  • Ran the modified Java unit test DatasetTest::test_branches which exercises branch creation, listing and metadata assertions, and it passed.
  • Ran the modified Python test test_branches with pytest which verifies branch_identifier in branches.list() and it passed.
  • Exercised JNI/bridge code paths while running the above tests to validate interop and serialization of the version->uuid mappings, and no failures were observed.

@github-actions
Copy link
Copy Markdown
Contributor

ACTION NEEDED
Lance follows the Conventional Commits specification for release automation.

The PR title and description are used as the merge commit message. Please update your PR title and description to match the specification.

For details on the error please inspect the "PR Title Check" action.

@majin1102 majin1102 changed the title Expose branch identifier (version->uuid lineage) in Branch metadata across Java, JNI and Python feat: expose branchidentifier in python and java bindings Mar 31, 2026
@majin1102 majin1102 changed the title feat: expose branchidentifier in python and java bindings feat: expose branch_identifier in python and java bindings Mar 31, 2026
@github-actions github-actions bot added the enhancement New feature or request label Mar 31, 2026
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 681c769755

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines 75 to +79
public Branch(
String name, String parentBranch, long parentVersion, long createAt, int manifestSize) {
String name,
String parentBranch,
List<BranchVersionMapping> branchIdentifier,
long parentVersion,
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Preserve the previous Branch constructor overload

This change removes the only public Branch(String, String, long, long, int) constructor and replaces it with a new signature that requires List<BranchVersionMapping>, which is a source/binary incompatible API break for downstream Java users who instantiate Branch directly. After upgrading, existing callers will fail to compile (or hit NoSuchMethodError when artifacts are mixed). Please keep the old constructor as an overload and delegate to the new one with a default lineage list to maintain compatibility.

Useful? React with 👍 / 👎.

&& Objects.equals(name, branch.name)
&& Objects.equals(parentBranch, branch.parentBranch);
&& Objects.equals(parentBranch, branch.parentBranch)
&& Objects.equals(branchIdentifier, branch.branchIdentifier);
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Avoid unstable lineage IDs in Branch equality

Including branchIdentifier in equals makes equality unstable for legacy branches whose refs JSON lacks identifier: Rust fills that with BranchIdentifier::none(), which generates a fresh UUID during deserialization, so the same logical branch can compare unequal across separate branches().list() calls. This can break client-side map/set lookups and cache keys for older datasets; consider excluding this field from equality (or ensuring legacy identifiers are deterministic before exposing them).

Useful? React with 👍 / 👎.

@majin1102 majin1102 removed the codex label Mar 31, 2026
Copy link
Copy Markdown
Contributor

@jackye1995 jackye1995 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good to me!

@majin1102 majin1102 merged commit 526a72f into main Apr 1, 2026
17 checks passed
@majin1102 majin1102 deleted the codex/add-branch_identifier-to-java-and-python-bindings branch April 1, 2026 06:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request java python

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants