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


##########
fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/NgramSearch.java:
##########
@@ -57,11 +58,14 @@ private NgramSearch(ScalarFunctionParams functionParams) {
 
     @Override
     public void checkLegalityBeforeTypeCoercion() {
-        if (!child(1).isConstant()) {
+        if (!getArgument(1).isConstant()) {
             throw new AnalysisException(
                     "ngram_search(text,pattern,gram_num): pattern support 
const value only.");
         }
-        Expression gramNum = child(2);
+        Expression gramNum = getArgument(2);
+        if (gramNum.isConstant()) {
+            gramNum = FoldConstantRuleOnFE.evaluateWithoutContext(gramNum);

Review Comment:
   [P2] Do not use FE-evaluator coverage as the constness check
   
   A deterministic constant tree can remain nonliteral here solely because the 
context-free FE evaluator does not implement its function. For example, 
`ngram_search('abc', 'abc', crc32('abc') % 3 + 1)` has a constant gram 
expression that is always 1-3 and is supported by the BE execution/folding 
path, but `ExpressionEvaluator` has no `crc32` implementation. This call 
therefore leaves the tree unchanged and the next check reports `gram_num 
support const value only`, even with BE folding enabled. Please validate 
through a folding path that covers the executable constant-expression contract 
(and add this case in both fold modes), rather than treating an unchanged 
FE-evaluator result as proof that the argument is not a valid constant.



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