jerry-024 commented on code in PR #7486:
URL: https://github.com/apache/paimon/pull/7486#discussion_r2963950063
##########
paimon-common/src/main/java/org/apache/paimon/predicate/PredicateReplaceVisitor.java:
##########
@@ -37,6 +37,10 @@ default Optional<Predicate> visit(CompoundPredicate
predicate) {
return Optional.empty();
}
}
- return Optional.of(new CompoundPredicate(predicate.function(),
converted));
+ if (predicate.function() instanceof And) {
+ return Optional.of(PredicateBuilder.and(converted));
+ } else {
+ return Optional.of(PredicateBuilder.or(converted));
Review Comment:
Changing the default method of `PredicateReplaceVisitor` affects **all**
implementations (e.g. `PredicateProjectionConverter`), not just the new
`PartitionValuePredicateVisitor`. The `AlwaysTrue`/`AlwaysFalse` simplification
is only needed by `PartitionValuePredicateVisitor`.
Suggestion: revert this default method to the original `new
CompoundPredicate(predicate.function(), converted)`, and override
`visit(CompoundPredicate)` in `PartitionValuePredicateVisitor` instead:
```java
@Override
public Optional<Predicate> visit(CompoundPredicate predicate) {
List<Predicate> converted = new ArrayList<>();
for (Predicate child : predicate.children()) {
Optional<Predicate> c = child.visit(this);
if (!c.isPresent()) {
return Optional.empty();
}
converted.add(c.get());
}
if (predicate.function() instanceof And) {
return Optional.of(PredicateBuilder.and(converted));
} else {
return Optional.of(PredicateBuilder.or(converted));
}
}
```
This keeps the simplification logic scoped to where it is actually needed.
--
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]