-
Notifications
You must be signed in to change notification settings - Fork 3k
More Python Expressions #5258
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
More Python Expressions #5258
Conversation
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 @CircArgs for working on this, much appreciated! I do have some suggestions below 👍🏻
Co-authored-by: Fokko Driesprong <fokko@apache.org>
|
@Fokko please have another look when you get a chance. Thanks! |
| return self._literals | ||
|
|
||
| def __str__(self) -> str: | ||
| return f"{self.__class__.__name__}({str(self.term)}{self.literals and ', '+str(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.
When I test this and literals is an empty list, I get x[] (where x is the term)
|
|
||
| def __str__(self) -> str: | ||
| return f"({self.left} and {self.right})" | ||
| return f"And({str(self.left)}, {str(self.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.
I don't think this is correct. This is basically just repr output. I think this should match what Java produces, which is a readable infix string.
| raise AttributeError("Null is a unary predicate and takes no Literals.") | ||
|
|
||
| def bind(self, schema: Schema, case_sensitive: bool) -> BoundIsNull[T]: | ||
| bound_ref = self.term.bind(schema, case_sensitive) |
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.
A better name would be bound_term since this is not necessarily a ref.
| return BoundNotEq(self.term, *self.literals) | ||
|
|
||
|
|
||
| class Eq(UnboundPredicate[T]): |
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.
Since we are using expression classes directly, rather than using factory methods, I think that these classes should use full names, like Equals and LessThan (or BoundEqual and BoundLessThan).
|
Thanks, @CircArgs! I think there are some changes that would help readability, but those are minor. I merged this so that other work can continue in parallel. |
Adding EQ, LT, GT, Null, NaN - bound and unbound versions
Predicate literals validation e.g. ensure predicates that take a single literal ultimately end up as tuple of literals as
.literals, make sure unary predicates have no literals.