rdblue commented on code in PR #18629:
URL: https://github.com/apache/iceberg/pull/18629#discussion_r4746034743
##########
api/src/main/java/org/apache/iceberg/expressions/Predicate.java:
##########
@@ -30,12 +30,30 @@ public abstract class Predicate<T, C extends Term>
implements Expression {
this.term = term;
}
+ Predicate(Operation op) {
+ this.op = op;
+ this.term = null;
+ }
+
@Override
public Operation op() {
return op;
}
+ /**
+ * Returns the term tested by this predicate.
+ *
+ * <p>Returns null when the predicate's operands are value expressions
rather than a term.
+ */
public C term() {
return term;
}
+
+ C requireTerm() {
+ if (term == null) {
+ throw new UnsupportedOperationException("Predicate does not have a term:
" + this);
+ }
+
+ return term;
Review Comment:
We typically avoid validations that are used inline like this.
I am also not sure why this is needed. It looks like the intended behavior
is to make `term` and `ref` throw an exception when they are accessed, but then
this is called from `BoundPredicate#eval` and `BoundPredicate#test`, both of
which do not require a term since a predicate could be created using a
`ValueExpression` instead.
I think that `BoundPredicate` (and probably `Predicate`) needs to be updated
so to use a term replacement (maybe `child`) natively, then implement `term`
when possible.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]