rohityadav1993 commented on code in PR #19121:
URL: https://github.com/apache/pinot/pull/19121#discussion_r3815196913
##########
pinot-query-planner/src/main/java/org/apache/pinot/query/planner/logical/PlanFragmenter.java:
##########
@@ -230,6 +261,103 @@ private boolean isPlanFragmentSplitter(PlanNode node) {
return ((ExchangeNode) node).getExchangeType() !=
PinotRelExchangeType.SUB_PLAN;
}
+ /**
+ * Returns {@code true} if the given sender fragment root represents a
<i>leaf selection ORDER BY</i> over a single
+ * physical table, i.e. a {@link SortNode} whose single-input chain down to
the leaf consists solely of
+ * {@link ProjectNode} and {@link TableScanNode} nodes, bottoms out at a
{@link TableScanNode}, and that scan resolves
+ * to exactly one physical table (see {@link
#resolvesToSinglePhysicalTable}).
+ *
+ * <p>Any branching node (input count != 1 that is not the leaf scan) or any
node that breaks the single-table leaf
+ * shape (Join, Aggregate, MailboxReceive/Exchange, Window, SetOp, etc.)
makes this return {@code false}. This is the
+ * shape for which the k-way merge in {@code SortedMailboxReceiveOperator}
can be safely auto-activated.
+ */
+ private boolean isLeafSelectionOrderBy(PlanNode root) {
+ if (!(root instanceof SortNode)) {
+ return false;
+ }
+ PlanNode current = root;
+ while (true) {
+ if (current instanceof TableScanNode) {
+ return resolvesToSinglePhysicalTable(((TableScanNode)
current).getTableName());
+ }
+ // Only SortNode (root), ProjectNode and TableScanNode are allowed in
the chain.
+ if (!(current instanceof SortNode) && !(current instanceof ProjectNode))
{
Review Comment:
Self review: Handle for filter node as well.
--
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]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]