xiangfu0 commented on code in PR #20344:
URL: https://github.com/apache/pinot/pull/20344#discussion_r4675515462
##########
pinot-query-planner/src/main/java/org/apache/pinot/calcite/rel/rules/PinotJoinExchangeNodeInsertRule.java:
##########
@@ -102,7 +108,13 @@ public void onMatch(RelOptRuleCall call) {
}
validateDistributionTypes(leftDistributionType, rightDistributionType,
isReplicatedTableScan(left),
isReplicatedTableScan(right), joinInfo, join.getJoinType());
- newLeft = createExchangeForHashJoin(leftDistributionType,
joinInfo.leftKeys, left, prePartitioned);
+ boolean fuseProbe = join.getJoinType() == JoinRelType.INNER &&
prePartitioned == null
+ && !joinInfo.leftKeys.isEmpty() && joinInfo.isEqui()
+ && leftDistributionType == PinotHintOptions.DistributionType.RANDOM
+ && rightDistributionType ==
PinotHintOptions.DistributionType.BROADCAST
+ && fusionEnabled(call, joinHintOptions) &&
isBroadcastJoinOutput(left);
+ newLeft = fuseProbe ? left
+ : createExchangeForHashJoin(leftDistributionType, joinInfo.leftKeys,
left, prePartitioned);
Review Comment:
Fixed in 09672dd3bc. Forced spooling now keeps the exchange between the
joins even when fusion is requested by a hint or query option. This also covers
a broker default of ON. With the new upstream AUTO default, a planner test
confirms the joins can still fuse while the guard rejects sharing the dependent
producer. Under forced ON the same test observes separate joins and one shared
producer. The H2-backed runtime case executes the shared-dimension query and
checks its result rows.
##########
pinot-query-planner/src/test/java/org/apache/pinot/query/routing/WorkerManagerTest.java:
##########
@@ -569,6 +570,47 @@ private static void validatePrunableFilter(@Nullable
Expression expression) {
}
}
+ @DataProvider
+ public Object[][] leafFanoutOptions() {
+ return new Object[][]{
+ {"", 1},
+ {"SET leafStageWorkersPerServer=4;", 4},
+ {"SET leafStageWorkersPerServer=16;", 7},
+ {"SET leafStageWorkersPerServer=4; SET multiStageLeafLimit=100;", 1}
+ };
+ }
+
+ @Test(dataProvider = "leafFanoutOptions")
+ public void testOptInFanoutWithFusedBroadcastJoins(String options, int
factWorkers) {
+ Schema schema = getSchemaBuilder("testTable").build();
+ ServerInstance server = getServerInstance("localhost", 1);
+ List<String> segments = IntStream.range(0,
7).mapToObj(Integer::toString).toList();
+ RoutingTable routing = new RoutingTable(Map.of(server, new
SegmentsToQuery(segments, List.of())), List.of(), 0);
+ QueryEnvironment env = newQueryEnvironment(schema,
+ new CapturingRoutingManager(Map.of(server.getInstanceId(), server),
Map.of("testTable_OFFLINE", routing)));
+ String query = options + " SET fuseBroadcastJoins=true; "
+ + "SELECT /*+
joinOptions(left_distribution_type='random',right_distribution_type='broadcast')
*/ "
+ + "f.col3,c.col2,p.col2 FROM testTable f JOIN testTable c ON
f.col1=c.col1 "
+ + "JOIN testTable p ON f.col2=p.col2";
+ try (QueryEnvironment.CompiledQuery compiled = env.compile(query)) {
+ DispatchableSubPlan subPlan = compiled.planQuery(0).getQueryPlan();
Review Comment:
Added the runtime matrix in 09672dd3bc. Seven native OFFLINE fact segments
live on one server, each contributing a distinct result group. For 1, 4 and 16
requested workers, with fusion both off and on, the executed leaf-stage
statistics report 1, 4 and 7 workers. All six runs match the independent H2
reference for every group, count and sum.
--
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]