-
Notifications
You must be signed in to change notification settings - Fork 369
Make SetPredicate and Subclasses JSON Serializable with Pydantic #2557
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
base: main
Are you sure you want to change the base?
Make SetPredicate and Subclasses JSON Serializable with Pydantic #2557
Conversation
Co-authored-by: Fokko Driesprong <fokko@apache.org>
Co-authored-by: Fokko Driesprong <fokko@apache.org>
@Fokko Thanks, for the feedback and correction . Please let me know if I need to do further improvements. |
@Aniketsy I've left a few more, but I think that should be it. We're super close! |
Co-authored-by: Fokko Driesprong <fokko@apache.org>
Co-authored-by: Fokko Driesprong <fokko@apache.org>
Co-authored-by: Fokko Driesprong <fokko@apache.org>
@Fokko Thanks! I’ve committed the suggested changes. |
Co-authored-by: Fokko Driesprong <fokko@apache.org>
Co-authored-by: Fokko Driesprong <fokko@apache.org>
Co-authored-by: Fokko Driesprong <fokko@apache.org>
Co-authored-by: Fokko Driesprong <fokko@apache.org>
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.
@Aniketsy Thanks for the quick turnaround, the changes I've just suggested fix all the mypy errors for me locally. You still need to check out the branch locally and run make lint
to fix all the formatting issues.
@Fokko Thanks! Will run |
Co-authored-by: Fokko Driesprong <fokko@apache.org>
Co-authored-by: Fokko Driesprong <fokko@apache.org>
Co-authored-by: Fokko Driesprong <fokko@apache.org>
Co-authored-by: Fokko Driesprong <fokko@apache.org>
@Fokko I noticed the |
Co-authored-by: Fokko Driesprong <fokko@apache.org>
def __invert__(self) -> In[L]: | ||
"""Transform the Expression into its negated version.""" | ||
return In[L](self.term, self.literals) | ||
return NotIn[L](self.term, self.literals) |
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 should be reverted:
return NotIn[L](self.term, self.literals) | |
return In[L](self.term, self.literals) |
|
||
class SetPredicate(UnboundPredicate[L], ABC): | ||
literals: Set[Literal[L]] | ||
class SetPredicate(UnboundPredicate[L], IcebergBaseModel, ABC): |
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.
The class and init should be:
class SetPredicate(IcebergBaseModel, UnboundPredicate[L], ABC):
model_config = ConfigDict(arbitrary_types_allowed=True)
type: TypingLiteral["in", "not-in"] = Field(default="in")
literals: Set[Literal[L]] = Field(alias="items")
def __init__(self, term: Union[str, UnboundTerm[Any]], literals: Union[Iterable[L], Iterable[Literal[L]]]):
super().__init__(term=_to_unbound_term(term), items=_to_literal_set(literals))
@Aniketsy The suggestions above work on my end. Sorry for this issue, it is more complicated than I anticipated |
Thanks @Fokko , I’ve committed the changes based on your suggestions. Do I need to check ruff format from my end . |
I've just kicked off the CI. I think we also need to merge #2564 first |
Got it, thanks for triggering the CI. I’ll wait for #2564 to be merged. |
#2564 is merged, do you mind rebasing this PR? |
sure, i will do that. |
0cd1fb3
to
f922d17
Compare
@Fokko Could you please guide me on what I should do to get the test passing? |
perhaps this is an import issue. can you try |
#2524
This PR addresses issue by making the
SetPredicate
class and its subclasses (In, NotIn) JSON serializable using Pydantic.In
andNotIn
predicates.Please let me know if my approach or fix needs any improvements . I’m open to feedback and happy to make changes based on suggestions.
Thank you !