mrhhsg opened a new pull request, #68311:
URL: https://github.com/apache/doris/pull/68311
### What problem does this PR solve?
Issue Number: None
Problem Summary:
`ngram_search('abc', 'abc', 3)` succeeds, but equivalent constant
expressions such as `1 + 2`, `CAST('3' AS INT)`, and `ABS(-3)` are rejected as
nonconstant. `NgramSearch.checkLegalityBeforeTypeCoercion()` checks for an
integer literal before the normal constant-folding stage.
Evaluate a constant `gram_num` with the existing context-free FE constant
evaluator before applying the existing integer-literal and positive-value
checks. This preserves rejection of column references,
volatile/context-dependent expressions, noninteger literals, NULL, and
nonpositive values. Pattern constness, function signatures, and BE execution
are unchanged. No new RPC or per-row evaluation is introduced.
### Release note
Allow foldable positive integer constant expressions as the third argument
of `ngram_search`.
### Check List (For Author)
- Test:
- Unit Test: `./run-fe-ut.sh --run
org.apache.doris.nereids.trees.expressions.functions.scalar.NgramSearchTest` —
8 passed. The unchanged base failed the arithmetic, cast, function, and
folded-nonpositive cases.
- Regression test: `test_ngram_search_foldable_gram` and existing
`test_string_function` — 2 suites passed on a fresh worktree-local ASAN
cluster. New golden output was generated with `-forceGenOut`, then verified in
a normal run. Both `enable_fold_constant_by_be=false` and `true` are covered.
- Build and style: `./build.sh --be --fe -j32` passed (ASAN BE); FE
Checkstyle reported zero violations; `git diff --check` passed.
- Behavior changed: Yes. Foldable positive integer gram expressions are
accepted; existing invalid-argument checks are retained.
- Does this need documentation: No.
--
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]