/** * True if the partition exprs and ordering elements and the window of analyticExpr match ours. */ public boolean isCompatible(AnalyticExpr analyticExpr) { if (requiresIndependentEval(analyticExprs.get(0)) || requiresIndependentEval(analyticExpr)) { return false; } if (!Expr.equalSets(analyticExpr.getPartitionExprs(), partitionByExprs)) { return false; } if (!analyticExpr.getOrderByElements().equals(orderByElements)) return false; if ((window == null) != (analyticExpr.getWindow() == null)) return false; if (window == null) return true; return analyticExpr.getWindow().equals(window); }
/** * 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; }
/** * True if the partition exprs of sortGroup are compatible with ours. For now that means * equality. */ public boolean isCompatible(SortGroup sortGroup) { return Expr.equalSets(sortGroup.partitionByExprs, partitionByExprs); }
/** True if the partition and ordering exprs of windowGroup match ours. */ public boolean isCompatible(WindowGroup windowGroup) { return Expr.equalSets(windowGroup.partitionByExprs, partitionByExprs) && windowGroup.orderByElements.equals(orderByElements); }