mihaibudiu commented on code in PR #4745:
URL: https://github.com/apache/calcite/pull/4745#discussion_r2691399945
##########
linq4j/src/main/java/org/apache/calcite/linq4j/function/Functions.java:
##########
@@ -718,8 +718,16 @@ private static class NullsLastReverseComparator
if (o2 == null) {
return -1;
}
- //noinspection unchecked
- return -o1.compareTo(o2);
+ if (o1 instanceof Comparable && o2 instanceof Comparable) {
+ //noinspection unchecked
+ return -((Comparable) o1).compareTo(o2);
+ } else if (o1 instanceof List && o2 instanceof List) {
+ return -compareLists((List<?>) o1, (List<?>) o2);
+ } else if (o1 instanceof Object[] && o2 instanceof Object[]) {
+ return -compareObjectArrays((Object[]) o1, (Object[]) o2);
+ } else {
+ throw new IllegalArgumentException();
Review Comment:
Please add here a descriptive error message; if this is ever hit, it will
make debugging easier.
##########
core/src/main/java/org/apache/calcite/plan/RelTraitSet.java:
##########
@@ -389,7 +389,14 @@ public RelTraitSet getDefaultSansConvention() {
*/
@SuppressWarnings("unchecked")
public <T extends RelCollation> @Nullable T getCollation() {
- return (@Nullable T) getTrait(RelCollationTraitDef.INSTANCE);
+ RelTrait trait = getTrait(RelCollationTraitDef.INSTANCE);
+ if (trait instanceof RelCompositeTrait) {
+ // If the trait is a composite trait, we return the first one as a
+ // representative trait. If RelCompositeTrait contain [[a, b], [a]].
+ // Selects [a,b] as it implies [a]; preserves the strongest ordering.
+ return (T) ((RelCompositeTrait) trait).trait(0);
Review Comment:
is the first one always the most general?
--
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]