TsukiokaKogane commented on code in PR #63850:
URL: https://github.com/apache/doris/pull/63850#discussion_r3342372334


##########
fe/fe-core/src/main/java/org/apache/doris/nereids/rules/rewrite/NormalizeOlapTableStreamScan.java:
##########
@@ -72,49 +113,125 @@ public Plan 
visitLogicalOlapTableStreamScan(LogicalOlapTableStreamScan scan, Voi
                             && ((SlotReference) 
slot).getOriginalColumn().isPresent()
                             && ((SlotReference) slot).getOriginalColumn().get()
                             .equals(Column.STREAM_SEQ_VIRTUAL_COLUMN)))
-                    .collect(Collectors.toList());
+                    .collect(Collectors.toList()));
 
-            if (originSlots.equals(newSlots)) {
-                return scan;
-            }
-
-            // add delete sign column if unique base table
-            Slot deleteSlot = null;
-            for (Column column : scan.getTable().getBaseSchema(true)) {
-                if (column.getName().equals(Column.DELETE_SIGN)) {
-                    deleteSlot = 
SlotReference.fromColumn(StatementScopeIdGenerator.newExprId(), scan.getTable(),
-                            column, scan.qualified());
-                    newSlots.add(deleteSlot);
-                    break;
+            // history plan
+            if (!historicalPartitionIds.isEmpty()) {
+                List<Slot> scanSlots = new ArrayList<>(newSlots);
+                // add delete sign column if unique base table
+                Slot deleteSlot = null;
+                for (Column column : scan.getTable().getBaseSchema(true)) {
+                    if (column.getName().equals(Column.DELETE_SIGN)) {
+                        deleteSlot = 
SlotReference.fromColumn(StatementScopeIdGenerator.newExprId(), scan.getTable(),
+                                column, scan.qualified());
+                        scanSlots.add(deleteSlot);
+                        break;
+                    }
                 }
-            }
-            Plan plan = scan.withCachedOutput(newSlots);
-            if (deleteSlot != null) {
-                Expression conjunct = new EqualTo(deleteSlot, new 
TinyIntLiteral((byte) 0));
-                if (!scan.getTable().getEnableUniqueKeyMergeOnWrite()) {
-                    plan = scan.withPreAggStatus(PreAggStatus.off(
-                            Column.DELETE_SIGN + " is used as conjuncts."));
+                Plan plan = 
scan.withSelectedPartitionIds(historicalPartitionIds, true)
+                                .withCachedOutput(new ArrayList<>(scanSlots))
+                                .withNormalized(true);
+                if (deleteSlot != null) {
+                    Expression conjunct = new EqualTo(deleteSlot, new 
TinyIntLiteral((byte) 0));
+                    if (!scan.getTable().getEnableUniqueKeyMergeOnWrite()) {
+                        plan = scan.withPreAggStatus(PreAggStatus.off(

Review Comment:
   fixed



-- 
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]

Reply via email to