mrhhsg commented on code in PR #68311:
URL: https://github.com/apache/doris/pull/68311#discussion_r4059981648
##########
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:
Addressed in ea279c48e7afa83cced00ac357230482bb7a87ce.
Constness and integer type are now checked independently of FE evaluator
coverage. FE-evaluable invalid values still fail early; otherwise normal BE
execution evaluates the argument and checks that the size is positive before
entering the ngram algorithm. The BE check is at the batch execution entry
rather than only in `open()`, since CSE can materialize the constant into an
intermediate slot.
Added the exact `crc32('abc') % 3 + 1` case, an explicit cast,
multi-row/nullable cases, and BE-only zero/negative expressions under both
`enable_fold_constant_by_be=false` and `true`.
Validation: 9 FE UTs, 4 ASAN BE UTs, ASAN BE+FE build, and both the focused
and existing string-function regression suites passed. Golden output was
generated and then verified normally. The PR body records the pre-existing
clang-tidy header blocker separately. Please re-review this revision.
--
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]