morrySnow commented on code in PR #15965: URL: https://github.com/apache/doris/pull/15965#discussion_r1071477134
########## fe/fe-core/src/main/java/org/apache/doris/nereids/rules/implementation/LogicalOlapScanToPhysicalOlapScan.java: ########## @@ -48,48 +45,40 @@ public class LogicalOlapScanToPhysicalOlapScan extends OneImplementationRuleFact @Override public Rule build() { return logicalOlapScan().then(olapScan -> - new PhysicalOlapScan( - olapScan.getId(), - olapScan.getTable(), - olapScan.getQualifier(), - olapScan.getSelectedIndexId(), - olapScan.getSelectedTabletIds(), - olapScan.getSelectedPartitionIds(), - convertDistribution(olapScan), - olapScan.getPreAggStatus(), - Optional.empty(), - olapScan.getLogicalProperties()) + new PhysicalOlapScan( + olapScan.getId(), + olapScan.getTable(), + olapScan.getQualifier(), + olapScan.getSelectedIndexId(), + olapScan.getSelectedTabletIds(), + olapScan.getSelectedPartitionIds(), + convertDistribution(olapScan), + olapScan.getPreAggStatus(), + Optional.empty(), + olapScan.getLogicalProperties()) ).toRule(RuleType.LOGICAL_OLAP_SCAN_TO_PHYSICAL_OLAP_SCAN_RULE); } private DistributionSpec convertDistribution(LogicalOlapScan olapScan) { OlapTable olapTable = olapScan.getTable(); DistributionInfo distributionInfo = olapTable.getDefaultDistributionInfo(); - ColocateTableIndex colocateTableIndex = Env.getCurrentColocateIndex(); - if ((colocateTableIndex.isColocateTable(olapTable.getId()) - && !colocateTableIndex.isGroupUnstable(colocateTableIndex.getGroup(olapTable.getId()))) - || olapTable.getPartitionInfo().getType() == PartitionType.UNPARTITIONED - || olapTable.getPartitions().size() == 1) { - if (!(distributionInfo instanceof HashDistributionInfo)) { - return DistributionSpecAny.INSTANCE; - } - HashDistributionInfo hashDistributionInfo = (HashDistributionInfo) distributionInfo; - List<Slot> output = olapScan.getOutput(); - List<ExprId> hashColumns = Lists.newArrayList(); - List<Column> schemaColumns = olapScan.getTable().getFullSchema(); - for (int i = 0; i < schemaColumns.size(); i++) { - for (Column column : hashDistributionInfo.getDistributionColumns()) { - if (schemaColumns.get(i).equals(column)) { - hashColumns.add(output.get(i).getExprId()); - } + + if (!(distributionInfo instanceof HashDistributionInfo)) { + return DistributionSpecAny.INSTANCE; + } + HashDistributionInfo hashDistributionInfo = (HashDistributionInfo) distributionInfo; Review Comment: we must to consider partition numbers and colocate group status when we generate DistributionSpec of OlapScan. When the partition number is not 1 and it is not in a colocate group or the colocate group is not stable, OlapScan's distribution should be random(in other words, any) -- 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...@doris.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For additional commands, e-mail: commits-h...@doris.apache.org