morrySnow commented on code in PR #67888:
URL: https://github.com/apache/doris/pull/67888#discussion_r4043482861


##########
fe/fe-core/src/main/java/org/apache/doris/nereids/rules/expression/rules/OneRangePartitionEvaluator.java:
##########
@@ -748,49 +735,38 @@ private List<Map<Slot, PartitionSlotInput>> 
computeSinglePartitionValueInputs()
     private List<Map<Slot, PartitionSlotInput>> 
commonComputeOnePartitionInputs() {
         List<Map<Slot, PartitionSlotInput>> onePartitionInputs = 
Lists.newArrayListWithCapacity(inputs.size());
         for (List<Expression> input : inputs) {
-            boolean previousIsLowerBoundLiteral = true;
-            boolean previousIsUpperBoundLiteral = true;
+            LexicographicBoundState lowerState = new LexicographicBoundState(
+                    lowers, true, partitionSlots.size());
+            LexicographicBoundState upperState = new LexicographicBoundState(
+                    uppers, false, partitionSlots.size());
             Builder<Slot, PartitionSlotInput> slotToInputs = 
ImmutableMap.builderWithExpectedSize(16);
             for (int i = 0; i < partitionSlots.size(); ++i) {
                 Slot partitionSlot = partitionSlots.get(i);
                 // partitionSlot will be replaced to this expression
                 Expression expression = input.get(i);
-                ColumnRange slotRange = null;
+                ColumnRange slotRange;
                 PartitionSlotType partitionSlotType = 
partitionSlotTypes.get(i);
                 if (expression instanceof Literal) {
                     // const or expanded range
                     slotRange = ColumnRange.singleton((Literal) expression);
-                    if (!expression.equals(lowers.get(i))) {
-                        previousIsLowerBoundLiteral = false;
-                    }
-                    if (!expression.equals(uppers.get(i))) {
-                        previousIsUpperBoundLiteral = false;
-                    }
+                    lowerState.observeLiteral(expression, i);
+                    upperState.observeLiteral(expression, i);
                 } else {
-                    // un expanded range
+                    // The first unresolved column carries every still-active 
lexicographic bound.
+                    // Once that column can diverge, every suffix column must 
remain unbounded.
                     switch (partitionSlotType) {
                         case RANGE:
-                            boolean isLastPartitionColumn = i + 1 == 
partitionSlots.size();
-                            BoundType rightBoundType = isLastPartitionColumn
-                                    ? BoundType.OPEN : BoundType.CLOSED;
-                            slotRange = ColumnRange.range(
-                                    lowers.get(i), BoundType.CLOSED, 
uppers.get(i), rightBoundType);
-                            break;
                         case OTHER:
-                            if (previousIsLowerBoundLiteral) {
-                                slotRange = ColumnRange.atLeast(lowers.get(i));
-                            } else if (previousIsUpperBoundLiteral) {
-                                slotRange = 
ColumnRange.lessThen(uppers.get(i));
-                            } else {
-                                // unknown range
-                                slotRange = ColumnRange.all();
-                            }
+                            slotRange = 
lowerState.constrainFirstUnresolvedColumn(ColumnRange.all(), i);
+                            slotRange = 
upperState.constrainFirstUnresolvedColumn(slotRange, i);
                             break;
+                        case CONST:
                         default:
-                            throw new AnalysisException("Unknown partition 
slot type: " + partitionSlotType);
+                            // A CONST input should always be a literal. Keep 
an unexpected shape conservative.

Review Comment:
   Addressed in fa0753858e8 with an explicit FE-debug policy. A nonliteral 
`CONST`, an unknown slot type, or another invalid evaluator state now calls 
`SessionVariable.throwAnalysisExceptionWhenFeDebug`: with `fe_debug=true` it 
throws `AnalysisException` and exposes the broken invariant; in normal 
production mode it logs a warning, marks the evaluator as pruning-disabled, and 
returns the original predicate so every candidate partition is retained and 
planning can continue safely. Added `testInvalidConstInputUsesFeDebugPolicy` to 
verify both modes.



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