yashmayya commented on code in PR #14495: URL: https://github.com/apache/pinot/pull/14495#discussion_r1851411034
########## pinot-query-planner/src/main/java/org/apache/pinot/query/planner/plannode/MailboxReceiveNode.java: ########## @@ -93,6 +96,10 @@ public MailboxSendNode getSender() { return _sender; } + public void setSender(MailboxSendNode sender) { + _sender = sender; + } Review Comment: Why not also update `_senderStageId`? Seems like it'd be good to avoid mismatches between `_sender` and `_senderStageId`. ########## pinot-query-planner/src/test/java/org/apache/pinot/query/planner/logical/EquivalentStagesFinderTest.java: ########## @@ -68,6 +69,34 @@ public void sharedJoin() { assertEquals(result.toString(), "[[0], [1, 2]]"); } + @Test + void sameBroadcastKeepEquivalence() { + when( + join( + exchange(1, tableScan("T1")) + .withDistributionType(RelDistribution.Type.RANDOM_DISTRIBUTED), + exchange(2, tableScan("T1")) + .withDistributionType(RelDistribution.Type.RANDOM_DISTRIBUTED) + ) + ); + GroupedStages groupedStages = EquivalentStagesFinder.findEquivalentStages(stage(0)); + assertEquals(groupedStages.toString(), "[[0], [1, 2]]"); + } + + @Test + void differentBroadcastBreakEquivalence() { Review Comment: ```suggestion void differentDistributionBreakEquivalence() { ``` nit ########## pinot-query-planner/src/test/java/org/apache/pinot/query/planner/logical/EquivalentStagesFinderTest.java: ########## @@ -68,6 +69,34 @@ public void sharedJoin() { assertEquals(result.toString(), "[[0], [1, 2]]"); } + @Test + void sameBroadcastKeepEquivalence() { Review Comment: ```suggestion void sameDistributionKeepEquivalence() { ``` nit ########## pinot-query-planner/src/test/java/org/apache/pinot/query/planner/logical/EquivalentStagesReplacerTest.java: ########## @@ -0,0 +1,146 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.pinot.query.planner.logical; + +import org.apache.pinot.query.planner.plannode.MailboxSendNode; +import org.testng.annotations.Test; + +import static org.testng.Assert.*; + + +public class EquivalentStagesReplacerTest extends StagesTestBase { Review Comment: The new code in `StagesTestBase` is pretty hard to read and understand but I think the complexity there is worth it considering how readable it makes these tests :) ########## pinot-query-planner/src/test/java/org/apache/pinot/query/planner/logical/StagesTestBase.java: ########## @@ -229,4 +260,127 @@ default P build(int stageId) { return build(stageId, null, null); } } + + public class Spool { + private final int _senderStageId; + private final Set<SpoolReceiverBuilder> _receiverBuilder = Collections.newSetFromMap(new IdentityHashMap<>()); + private MailboxSendNode _sender; + private final SimpleChildBuilder<? extends PlanNode> _childBuilder; + + public Spool(int senderStageId, SimpleChildBuilder<? extends PlanNode> childBuilder) { + _senderStageId = senderStageId; + _childBuilder = childBuilder; Review Comment: This is the builder for the input node to the sender node that is being spooled right? ########## pinot-query-planner/src/test/java/org/apache/pinot/query/planner/logical/StagesTestBase.java: ########## @@ -229,4 +260,127 @@ default P build(int stageId) { return build(stageId, null, null); } } + + public class Spool { + private final int _senderStageId; + private final Set<SpoolReceiverBuilder> _receiverBuilder = Collections.newSetFromMap(new IdentityHashMap<>()); + private MailboxSendNode _sender; + private final SimpleChildBuilder<? extends PlanNode> _childBuilder; + + public Spool(int senderStageId, SimpleChildBuilder<? extends PlanNode> childBuilder) { + _senderStageId = senderStageId; + _childBuilder = childBuilder; + } + + public MailboxSendNode getSender() { + return _sender; + } + + public SimpleChildBuilder<MailboxReceiveNode> newReceiver( + Function<SimpleChildBuilder<MailboxReceiveNode>, SimpleChildBuilder<MailboxReceiveNode>> customize) { Review Comment: What's the use case for this customization function? ########## pinot-query-planner/src/test/java/org/apache/pinot/query/planner/logical/EquivalentStagesFinderTest.java: ########## @@ -89,7 +118,7 @@ public void sameHintsDontBreakEquivalence() { } @Test - public void differentHintsImplyNotEquivalent() { + public void differentHintsBreakEquivalent() { Review Comment: ```suggestion public void differentHintsBreakEquivalence() { ``` nit (similarly below) ########## pinot-query-planner/src/test/java/org/apache/pinot/query/planner/logical/StagesTestBase.java: ########## @@ -229,4 +260,127 @@ default P build(int stageId) { return build(stageId, null, null); } } + + public class Spool { Review Comment: nit: should be static? -- 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