-
Notifications
You must be signed in to change notification settings - Fork 412
Feat/json serialize or expression #2565
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
Fokko
merged 8 commits into
apache:main
from
jaimeferj:feat/json-serialize-or-expression
Oct 22, 2025
+24
−4
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
c961dc3
feat: make Or json serializable via IcebergBaseModel
jaimeferj 873c022
fix: invalid creation of Or instance with multiple BooleanExpressions
jaimeferj 4f6a09e
feat: fix or instance creation for _build_balanced_tree
jaimeferj 2638c8d
revert: test_visitors
jaimeferj 4197536
fix: typo in typingliteral
jaimeferj dc7a2b4
feat: add test for Or serialization alone
jaimeferj 2a55dfb
fix: test Or serialization
jaimeferj 1b18573
fix: remove unnecessary serializer
jaimeferj 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
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 weird
__init__is to make sure that if the class has been already initialized in__new__, it is not initialized again.If this is not made, multiple things can happen:
_build_balanced_treebuild anOrinstance correctly, Python would call againOrinitializer with the original parametersleftandrightresulting inOr(left, right), ignoring the createdOrinstance from_build_balanced_treeAlwaysTrueit will get overriden and the instance will be initialized asOr(left, right)AlwaysFalseit will get overriden and the instance will be initialized asOr(left, right)I do not know why exactly but it gotta be something from Pydantic
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 spent several hours debugging this, and it is pretty weird. Pydantic seems not to work well with
__new__. I came up with the following:I see what direction you were going, but if we leave out the
obj.left = leftthen we don't have the attributes and we have an emptyOrobject. The test is still failing, but I think that's because the UnaryPredicates are not yet serializable. If you update the tests to use LiteralPredicates, then it should work 👍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 cannot test it now, but I am pretty sure that I left out
obj.left = leftbecause of how Python works with__new__. If you return a class of the same type that happens:So that is why I purposely left the object uninitialized, so that when the raw obj is returned it is initialized by
__init__.If the object has already being initialized by
_build_balanced_treeI just leave it as is.Uh oh!
There was an error while loading. Please reload this page.
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.
Another thing, the tests are passing in my implementation, as far as I know, so you know that Or is being instantiated correctly, right?
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.
Earlier today I had failing tests, but I was still at an older commit of the branch. Let me check again