cambyzju commented on code in PR #37361: URL: https://github.com/apache/doris/pull/37361#discussion_r1668531439
########## fe/fe-core/src/main/java/org/apache/doris/nereids/util/JoinUtils.java: ########## @@ -300,12 +301,42 @@ public static boolean couldColocateJoin(DistributionSpecHash leftHashSpec, Distr boolean noNeedCheckColocateGroup = hitSameIndex && (leftTablePartitions.equals(rightTablePartitions)) && (leftTablePartitions.size() <= 1); ColocateTableIndex colocateIndex = Env.getCurrentColocateIndex(); - if (noNeedCheckColocateGroup - || (colocateIndex.isSameGroup(leftTableId, rightTableId) - && !colocateIndex.isGroupUnstable(colocateIndex.getGroup(leftTableId)))) { + if (noNeedCheckColocateGroup) { return true; } - return false; + if (!colocateIndex.isSameGroup(leftTableId, rightTableId) + || colocateIndex.isGroupUnstable(colocateIndex.getGroup(leftTableId))) { + return false; + } + + Set<Integer> equalIndices = new HashSet<>(); + for (Expression expr : conjuncts) { + // only simple equal predicate can use colocate join + if (!(expr instanceof EqualPredicate)) { + return false; + } + Expression leftChild = ((EqualPredicate) expr).left(); + Expression rightChild = ((EqualPredicate) expr).right(); + if (!(leftChild instanceof Slot) || !(rightChild instanceof Slot)) { + return false; + } + + // on conditions must keep same order as distributed columns + Integer leftIndex = leftHashSpec.getExprIdToEquivalenceSet().get(((Slot) leftChild).getExprId()); + Integer rightIndex = rightHashSpec.getExprIdToEquivalenceSet().get(((Slot) rightChild).getExprId()); + if (leftIndex != rightIndex) { Review Comment: Got, I will fix it later -- 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: commits-unsubscr...@doris.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For additional commands, e-mail: commits-h...@doris.apache.org