silundong commented on code in PR #4827:
URL: https://github.com/apache/calcite/pull/4827#discussion_r2992148833
##########
core/src/main/java/org/apache/calcite/plan/RelTraitSet.java:
##########
@@ -577,8 +620,22 @@ public boolean contains(RelTrait trait) {
*/
public boolean containsIfApplicable(RelTrait trait) {
// Note that '==' is sufficient, because trait should be canonized.
- final RelTrait trait1 = getTrait(trait.getTraitDef());
- return trait1 == null || trait1 == trait;
+ int index = findIndex(trait.getTraitDef());
+ if (index < 0) {
+ // TraitDef not registered in this set → treat as "not applicable" → true
+ return true;
+ }
+ final RelTrait stored = getTrait(index);
+ if (stored instanceof RelCompositeTrait) {
Review Comment:
If `stored` is `RelCompositeTrait`, `getTrait(index)` already throws an
error. Based on the original logic, this might be enough:
```
final RelTrait stored = get(index);
return stored == trait;
```
--
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]