github-actions[bot] commented on code in PR #68579:
URL: https://github.com/apache/doris/pull/68579#discussion_r4121932821


##########
fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/agg/OrthogonalBitmapExprCalculate.java:
##########
@@ -64,6 +66,20 @@ private 
OrthogonalBitmapExprCalculate(AggregateFunctionParams functionParams) {
         super(functionParams);
     }
 
+    @Override
+    public boolean needFoldToLiteral(int index) {
+        // the calculation expression
+        return index == 2;
+    }

Review Comment:
   [P2] Accept STRING literals during bitmap formula reconstruction. For 
`orthogonal_bitmap_expr_calculate(to_bitmap(k), cast(k as varchar), 
concat(cast('1' as string), cast('|2' as string)))`, FE folding produces a 
`StringLiteral`. `foldLiteralArguments` then calls `withChildren` before 
coercion, but `withDistinctAndChildren` still asserts `VarcharType` for child 
2, so this query fails before the new `StringLikeLiteral` check can apply. The 
`_count` variant has the same assertion. Please allow the pre-coercion string 
literal and add both variants to the tests.



##########
fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/DateTrunc.java:
##########
@@ -62,6 +64,21 @@ private DateTrunc(ScalarFunctionParams functionParams) {
         super(functionParams);
     }
 
+    @Override
+    public boolean needFoldToLiteral(int index) {
+        // Fold a string argument only when it may be the time unit, i.e. the 
other argument is not a literal
+        // or is a string literal that is not a time unit. A string date value 
next to a literal time unit is
+        // left unfolded, because folding it would change the derived return 
type.
+        if (!getArgument(index).getDataType().isStringLikeType()) {
+            return false;
+        }
+        Expression other = getArgument(1 - index);
+        if (other instanceof StringLikeLiteral) {
+            return !LEGAL_TIME_UNIT.contains(((StringLikeLiteral) 
other).getStringValue().toLowerCase());

Review Comment:
   [P2] Identify the time-unit argument before folding. `date_trunc(DATE 
'2024-03-15', concat('mon','th'))` still fails analysis: the DATE is a typed 
literal, so this predicate skips the unit fold and the legality check rejects 
`concat`. Conversely, when both arguments are foldable strings, it folds the 
date value too. With `concat('2024-01-01 01:02:03+08:00','')` as the date, a 
literal `'month'` makes FE derive DATETIMEV2 while `concat('mon','th')` as the 
equivalent unit makes it derive TIMESTAMPTZ through the both-literals signature 
branch. Please fold the unit while preserving the date expression's type, and 
cover both shapes.



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