xiedeyantu commented on code in PR #4827:
URL: https://github.com/apache/calcite/pull/4827#discussion_r2929608437
##########
core/src/main/java/org/apache/calcite/plan/RelTraitSet.java:
##########
@@ -375,37 +389,86 @@ public RelTraitSet getDefaultSansConvention() {
* {@link RelDistributionTraitDef#INSTANCE}, or null if the
* {@link RelDistributionTraitDef#INSTANCE} is not registered
* in this traitSet.
+ *
+ * <p>If this trait set contains multiple distributions (a composite trait),
+ * this method throws {@link IllegalStateException}. Use
+ * {@link #getDistributions()} to handle both the single and
multi-distribution
+ * cases uniformly.
*/
@SuppressWarnings("unchecked")
public <T extends RelDistribution> @Nullable T getDistribution() {
- return (@Nullable T) getTrait(RelDistributionTraitDef.INSTANCE);
+ int index = findIndex(RelDistributionTraitDef.INSTANCE);
+ if (index < 0) {
+ return null;
+ }
+ final RelTrait trait = getTrait(index);
+ if (trait instanceof RelCompositeTrait) {
Review Comment:
The modifications have been completed as you described.
--
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]