/**
  * Return true if 'this' and other have compatible partition exprs and our orderByElements are a
  * prefix of other's.
  */
 public boolean isPrefixOf(SortGroup other) {
   if (other.orderByElements.size() > orderByElements.size()) return false;
   if (!Expr.equalSets(partitionByExprs, other.partitionByExprs)) return false;
   for (int i = 0; i < other.orderByElements.size(); ++i) {
     OrderByElement ob = orderByElements.get(i);
     OrderByElement otherOb = other.orderByElements.get(i);
     // TODO: compare equiv classes by comparing each equiv class's placeholder
     // slotref
     if (!ob.getExpr().equals(otherOb.getExpr())) return false;
     if (ob.isAsc() != otherOb.isAsc()) return false;
     if (ob.nullsFirst() != otherOb.nullsFirst()) return false;
   }
   return true;
 }