From 45f6cba837d1e6222c15d231e65a3f07c7d7de4a Mon Sep 17 00:00:00 2001 From: xy Date: Mon, 22 Jan 2024 15:10:46 +0800 Subject: [PATCH] [fix](Nereids) Fixed a bug where the execution plan was incorrect after ddl (#30107) should only compare column name when generate data dist info of PhysicalOlapScan Co-authored-by: xingying01 --- .../LogicalOlapScanToPhysicalOlapScan.java | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/implementation/LogicalOlapScanToPhysicalOlapScan.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/implementation/LogicalOlapScanToPhysicalOlapScan.java index 6bcf22a9ad..43436355ae 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/implementation/LogicalOlapScanToPhysicalOlapScan.java +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/implementation/LogicalOlapScanToPhysicalOlapScan.java @@ -94,7 +94,10 @@ public class LogicalOlapScanToPhysicalOlapScan extends OneImplementationRuleFact if (hashColumns.size() != hashDistributionInfo.getDistributionColumns().size()) { for (Slot slot : baseOutput) { for (Column column : hashDistributionInfo.getDistributionColumns()) { - if (((SlotReference) slot).getColumn().get().equals(column)) { + // If the length of the column in the bucket key changes after DDL, the length cannot be + // determined. As a result, some bucket fields are lost in the query execution plan. + // So here we use the column name to avoid this problem + if (((SlotReference) slot).getColumn().get().getName().equalsIgnoreCase(column.getName())) { hashColumns.add(slot.getExprId()); } } @@ -108,7 +111,10 @@ public class LogicalOlapScanToPhysicalOlapScan extends OneImplementationRuleFact List hashColumns = Lists.newArrayList(); for (Slot slot : output) { for (Column column : hashDistributionInfo.getDistributionColumns()) { - if (((SlotReference) slot).getColumn().get().equals(column)) { + // If the length of the column in the bucket key changes after DDL, the length cannot be + // determined. As a result, some bucket fields are lost in the query execution plan. + // So here we use the column name to avoid this problem + if (((SlotReference) slot).getColumn().get().getName().equalsIgnoreCase(column.getName())) { hashColumns.add(slot.getExprId()); } }