kbendick commented on a change in pull request #2062:
URL: https://github.com/apache/iceberg/pull/2062#discussion_r559263109
##########
File path: api/src/main/java/org/apache/iceberg/expressions/Evaluator.java
##########
@@ -151,5 +151,10 @@ public Boolean or(Boolean leftResult, Boolean rightResult)
{
public <T> Boolean startsWith(Bound<T> valueExpr, Literal<T> lit) {
return ((String) valueExpr.eval(struct)).startsWith((String)
lit.value());
}
+
+ @Override
+ public <T> Boolean notStartsWith(Bound<T> valueExpr, Literal<T> lit) {
+ return !((String) valueExpr.eval(struct)).startsWith((String)
lit.value());
Review comment:
Update
For `ResidualEvaluator`, it can't be `!startsWith(ref, lit)` as
`ResidualEvaluator` returns an expression, so it would have to be
`startsWith(ref, lit).negate()`. This works since we're returning
`alwaysTrue()` or `alwaysFalse()`, but it is a little confusing (and
potentially error prone in my opinion in the longer term). Also, in the same
file, we don't define `notIn` by using `in` in this way. I personally think
`ResidualEvaluator` should be left as is.
Additionally, `BoundLiteralPredicate` cannot be defined in terms of
`STARTS_WITH` as the function signature is just `test(T value)` and then the
operation is caught in a switch statement and the operation is stored as a
value on `this` (the `BoundLiteralPredicate` instance). So we'd have to return
`negate().test(value)` which is also pretty confusing and likely error prone.
I'm going to close this conversation as it seems that the instances where we
can easily and simply replace `notStartsWith` with `!starsWith` have all been
covered. Feel free to reopen it or comment further if you disagree.
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]