61yao commented on code in PR #9870: URL: https://github.com/apache/pinot/pull/9870#discussion_r1035482458
########## pinot-query-planner/src/main/java/org/apache/pinot/query/planner/logical/ShuffleRewriteVisitor.java: ########## @@ -189,4 +172,27 @@ private static boolean canSkipShuffle(Set<Integer> partitionKeys, KeySelector<Ob } return false; } + + private static Set<Integer> deriveNewPartitionKeysFromRexExpressions(List<RexExpression> rexExpressionList, + Set<Integer> oldPartitionKeys) { + Map<Integer, Integer> partitionKeyMap = new HashMap<>(); + for (int i = 0; i < rexExpressionList.size(); i++) { + RexExpression rex = rexExpressionList.get(i); + if (rex instanceof RexExpression.InputRef) { + // put the old-index to new-index mapping + // TODO: it doesn't handle duplicate references. e.g. if the same old partition key is referred twice. it will + // only keep the second one. (see JOIN handling on left/right as another example) + partitionKeyMap.put(((RexExpression.InputRef) rex).getIndex(), i); Review Comment: Is there any other case except join this duplicate reference can happen? -- 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...@pinot.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@pinot.apache.org For additional commands, e-mail: commits-h...@pinot.apache.org