Code review comment: according to the silimar code in `computeFragmentExecParams`, this code block is to want to decide how to shuffle data to dest by whether it is broadcast join's right child. Since `MultiCastFragment` will never be broadcast join's right child. I think the right way to fix this problem is removing if branch.

Code before review:
private void computeMultiCastFragmentParams() throws Exception {
for (FragmentExecParams params : fragmentExecParamsMap.values()) {
if (!(params.fragment instanceof MultiCastPlanFragment)) {
continue;
}
MultiCastPlanFragment multi = (MultiCastPlanFragment) params.fragment;
Preconditions.checkState(multi.getSink() instanceof MultiCastDataSink);
MultiCastDataSink multiSink = (MultiCastDataSink) multi.getSink();
for (int i = 0; i < multi.getDestFragmentList().size(); i++) {
PlanFragment destFragment = multi.getDestFragmentList().get(i);
DataStreamSink sink = multiSink.getDataStreamSinks().get(i);
if (destFragment == null) {
continue;
}
FragmentExecParams destParams = fragmentExecParamsMap.get(destFragment.getFragmentId());
multi.getDestFragmentList().get(i).setOutputPartition(params.fragment.getOutputPartition());
PlanNodeId exchId = sink.getExchNodeId();
Preconditions.checkState(!destParams.perExchNumSenders.containsKey(exchId.asInt()));
if (destParams.perExchNumSenders.get(exchId.asInt()) == null) {
destParams.perExchNumSenders.put(exchId.asInt(), params.instanceExecParams.size());
} else {
destParams.perExchNumSenders.put(exchId.asInt(),
params.instanceExecParams.size() + destParams.perExchNumSenders.get(exchId.asInt()));
}
List<TPlanFragmentDestination> destinations = multiSink.getDestinations().get(i);
if (enablePipelineEngine && enableShareHashTableForBroadcastJoin
&& destFragment.isRightChildOfBroadcastHashJoin()) {
Map<TNetworkAddress, FInstanceExecParam> destHosts = new HashMap<>();
destParams.instanceExecParams.forEach(param -> {
if (destHosts.containsKey(param.host)) {
destHosts.get(param.host).instancesSharingHashTable.add(param.instanceId);
} else {
destHosts.put(param.host, param);
param.buildHashTableForBroadcastJoin = true;
TPlanFragmentDestination dest = new TPlanFragmentDestination();
dest.fragment_instance_id = param.instanceId;
try {
dest.server = toRpcHost(param.host);
dest.setBrpcServer(toBrpcHost(param.host));
} catch (Exception e) {
throw new RuntimeException(e);
}
destinations.add(dest);
}
});
} else {
for (int j = 0; j < destParams.instanceExecParams.size(); ++j) {
TPlanFragmentDestination dest = new TPlanFragmentDestination();
dest.fragment_instance_id = destParams.instanceExecParams.get(j).instanceId;
dest.server = toRpcHost(destParams.instanceExecParams.get(j).host);
dest.brpc_server = toBrpcHost(destParams.instanceExecParams.get(j).host);
destinations.add(dest);
}
}
}
}
}

Line under review: && destFragment.isRightChildOfBroadcastHashJoin()) {

Code after addressing the review:
private void computeMultiCastFragmentParams() throws Exception {
for (FragmentExecParams params : fragmentExecParamsMap.values()) {
if (!(params.fragment instanceof MultiCastPlanFragment)) {
continue;
}
MultiCastPlanFragment multi = (MultiCastPlanFragment) params.fragment;
Preconditions.checkState(multi.getSink() instanceof MultiCastDataSink);
MultiCastDataSink multiSink = (MultiCastDataSink) multi.getSink();
for (int i = 0; i < multi.getDestFragmentList().size(); i++) {
PlanFragment destFragment = multi.getDestFragmentList().get(i);
DataStreamSink sink = multiSink.getDataStreamSinks().get(i);
if (destFragment == null) {
continue;
}
FragmentExecParams destParams = fragmentExecParamsMap.get(destFragment.getFragmentId());
multi.getDestFragmentList().get(i).setOutputPartition(params.fragment.getOutputPartition());
PlanNodeId exchId = sink.getExchNodeId();
PlanNode exchNode = PlanNode.findPlanNodeFromPlanNodeId(destFragment.getPlanRoot(), exchId);
Preconditions.checkState(!destParams.perExchNumSenders.containsKey(exchId.asInt()));
Preconditions.checkState(exchNode != null, "exchNode is null");
Preconditions.checkState(exchNode instanceof ExchangeNode,
"exchNode is not ExchangeNode" + exchNode.getId().toString());
if (destParams.perExchNumSenders.get(exchId.asInt()) == null) {
destParams.perExchNumSenders.put(exchId.asInt(), params.instanceExecParams.size());
} else {
destParams.perExchNumSenders.put(exchId.asInt(),
params.instanceExecParams.size() + destParams.perExchNumSenders.get(exchId.asInt()));
}
List<TPlanFragmentDestination> destinations = multiSink.getDestinations().get(i);
if (enablePipelineEngine && enableShareHashTableForBroadcastJoin
&& ((ExchangeNode) exchNode).isRightChildOfBroadcastHashJoin()) {
Map<TNetworkAddress, FInstanceExecParam> destHosts = new HashMap<>();
destParams.instanceExecParams.forEach(param -> {
if (destHosts.containsKey(param.host)) {
destHosts.get(param.host).instancesSharingHashTable.add(param.instanceId);
} else {
destHosts.put(param.host, param);
param.buildHashTableForBroadcastJoin = true;
TPlanFragmentDestination dest = new TPlanFragmentDestination();
dest.fragment_instance_id = param.instanceId;
try {
dest.server = toRpcHost(param.host);
dest.setBrpcServer(toBrpcHost(param.host));
} catch (Exception e) {
throw new RuntimeException(e);
}
destinations.add(dest);
}
});
} else {
for (int j = 0; j < destParams.instanceExecParams.size(); ++j) {
TPlanFragmentDestination dest = new TPlanFragmentDestination();
dest.fragment_instance_id = destParams.instanceExecParams.get(j).instanceId;
dest.server = toRpcHost(destParams.instanceExecParams.get(j).host);
dest.brpc_server = toBrpcHost(destParams.instanceExecParams.get(j).host);
destinations.add(dest);
}
}
}
}
}