feiniaofeiafei commented on code in PR #47608:
URL: https://github.com/apache/doris/pull/47608#discussion_r1981281037


##########
fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/literal/Literal.java:
##########
@@ -302,6 +303,23 @@ public static Literal fromLegacyLiteral(LiteralExpr 
literalExpr, Type type) {
                 org.apache.doris.analysis.DateLiteral dateLiteral = 
(org.apache.doris.analysis.DateLiteral) literalExpr;
                 return new DateLiteral(dateLiteral.getYear(), 
dateLiteral.getMonth(), dateLiteral.getDay());
             }
+            case DATETIME: {
+                org.apache.doris.analysis.DateLiteral dateLiteral = 
(org.apache.doris.analysis.DateLiteral) literalExpr;

Review Comment:
   slow path DATETIME and DATETIMEV2 branch can be removed?



##########
fe/fe-core/src/main/java/org/apache/doris/nereids/rules/expression/rules/OneListPartitionEvaluator.java:
##########
@@ -58,23 +64,71 @@ public K getPartitionIdent() {
 
     @Override
     public List<Map<Slot, PartitionSlotInput>> getOnePartitionInputs() {
+        if (partitionSlots.size() == 1) {
+            // fast path
+            return getInputsByOneSlot();
+        } else {
+            // slow path
+            return getInputsByMultiSlots();
+        }
+    }
+
+    private List<Map<Slot, PartitionSlotInput>> getInputsByOneSlot() {
+        ImmutableList.Builder<Map<Slot, PartitionSlotInput>> inputs
+                = 
ImmutableList.builderWithExpectedSize(partitionItem.getItems().size());
+        Slot slot = partitionSlots.get(0);
+        for (PartitionKey item : partitionItem.getItems()) {
+            LiteralExpr legacy = item.getKeys().get(0);
+            inputs.add(ImmutableMap.of(
+                    slot,
+                    new PartitionSlotInput(Literal.fromLegacyLiteral(legacy, 
legacy.getType()), ImmutableMap.of()))
+            );
+        }
+        return inputs.build();
+    }
+
+    private List<Map<Slot, PartitionSlotInput>> getInputsByMultiSlots() {
         return partitionItem.getItems().stream()
-            .map(keys -> {
-                List<Literal> literals = keys.getKeys()
-                        .stream()
-                        .map(literal -> Literal.fromLegacyLiteral(literal, 
literal.getType()))
-                        .collect(ImmutableList.toImmutableList());
-
-                return IntStream.range(0, partitionSlots.size())
-                        .mapToObj(index -> {
-                            Slot partitionSlot = partitionSlots.get(index);
-                            // partitionSlot will be replaced to this literal
-                            Literal literal = literals.get(index);
-                            // list partition don't need to compute the slot's 
range,
-                            // so we pass through an empty map
-                            return Pair.of(partitionSlot, new 
PartitionSlotInput(literal, ImmutableMap.of()));
-                        }).collect(ImmutableMap.toImmutableMap(Pair::key, 
Pair::value));
-            }).collect(ImmutableList.toImmutableList());
+                .map(keys -> {
+                    List<Literal> literals = keys.getKeys()
+                            .stream()
+                            .map(literal -> Literal.fromLegacyLiteral(literal, 
literal.getType()))
+                            .collect(ImmutableList.toImmutableList());
+
+                    return IntStream.range(0, partitionSlots.size())
+                            .mapToObj(index -> {
+                                Slot partitionSlot = partitionSlots.get(index);
+                                // partitionSlot will be replaced to this 
literal
+                                Literal literal = literals.get(index);
+                                // list partition don't need to compute the 
slot's range,
+                                // so we pass through an empty map
+                                return Pair.of(partitionSlot, new 
PartitionSlotInput(literal, ImmutableMap.of()));
+                            }).collect(ImmutableMap.toImmutableMap(Pair::key, 
Pair::value));
+                }).collect(ImmutableList.toImmutableList());
+    }
+
+    @Override
+    public Expression visitInPredicate(InPredicate inPredicate, Map<Slot, 
PartitionSlotInput> context) {
+        if (!inPredicate.optionsAreLiterals()) {
+            return super.visitInPredicate(inPredicate, context);
+        }
+
+        if (inPredicate.optionsContainsNullLiteral()) {

Review Comment:
   why return NullLiteral?



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

Reply via email to