-
Notifications
You must be signed in to change notification settings - Fork 1.3k
[python] Align Identifier with Java by encoding branch into the object field #7738
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
JingsongLi
merged 3 commits into
apache:master
from
TheR1sing3un:py-identifier-align-java
May 3, 2026
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
a035cd8
[python] Align Identifier with Java by encoding branch into the objec…
TheR1sing3un a913e14
[python] Identifier: keep backward-compat shim for the deprecated bra…
TheR1sing3un b17c946
[python] Identifier: align constructors with Java, drop deprecation s…
TheR1sing3un File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This may be a break change?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for catching that @JingsongLi — yes, you're right. Let me enumerate what changes shape so I can address each:
Identifier(database, object, branch=...)constructor kwarg removed.identifier.branchattribute removed.Identifier.create(db, object)second positional arg renamed fromobjecttotable; passing a pre-encoded object containing$now caches it as the table name rather than splitting it.SYSTEM_BRANCH_PREFIXchanged from'branch-'to'branch_'(this one is a bug-fix — Java has always usedbranch_, so anything Python wrote withbranch-was already not round-trippable through the Java REST server).branchJSON field is no longer emitted (Java@JsonIgnoreProperties(ignoreUnknown = true)was already dropping it on the wire, so this never carried information end-to-end, but the Python wire shape does change).(4) and (5) I'd defend as correctness fixes — the pre-fix behaviour was inconsistent with Java in ways that silently corrupted cross-language scenarios, and I don't see a backward-compat path that preserves the buggy behaviour while letting branched system tables work against a Java REST server.
(1) (2) (3) are the real API-shape break. I agree those need a soft-deprecation path. I'll push a follow-up commit on this PR that:
Identifier(..., branch=...)and routes it through the new encoding internally, emittingDeprecationWarning.identifier.branchas a property that delegates toget_branch_name(), also withDeprecationWarning.Identifier.create(db, object)two-arg form (detected by$in the second arg) and routes through the new constructor, withDeprecationWarning.The plan would be to remove the shim in the next minor version. Does that sound reasonable?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know why you need to introduce
_BRANCH_NOT_SET, Java also has many constructors.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're right — the sentinel was overkill, and the deprecation path it was
gating is unnecessary if we just match Java's constructor shape directly.
Pushed b17c946, which:
_BRANCH_NOT_SETand allDeprecationWarning.__init__(database, object=None, branch=None, system_table=None)mirrors Java's three public constructors in one signature: when
branch/system_tableis non-None, encode intoobject; otherwisetreat
objectas the final string (the@JsonCreatorpath).Identifier.createkeeps its existing kwargs and now just delegatesto the constructor — Java has only the 2-arg
create, but keepingthe multi-arg form here costs nothing and avoids touching every
caller introduced by the first commit.
Backward compatibility against the pre-PR public surface (the worry
from your first review) is preserved without warnings:
Identifier(db, obj, branch=...)/branch=None— accepted, encodesinto
objectso the Java REST server now actually sees the branch.identifier.branch— read+write property. The setter re-encodesobjectsoid.branch = "x"keeps working for any caller that usedto assign to the dataclass field.
Identifier.create(db, "tbl$snapshots")two-arg form — unchanged.A new
IdentifierBackwardCompatibilityTestlocks these in by asserting"the old call sites run without raising" (no warning assertions, no
shim semantics — these are first-class supported entry points now).
PTAL.