mrhhsg opened a new pull request, #71413:
URL: https://github.com/apache/doris/pull/71413
### What problem does this PR solve?
Issue Number: None
Related PR: #68579
Backport #68579 to `branch-4.1`.
Functions that require constant arguments can reject constant expressions
before they are folded. Some BE implementations also assume that a constant
value is available during `open()` or represented by `ColumnConst`, which is
not necessarily true for expressions evaluated by BE.
This backport:
- Adds a preparation hook before type coercion for arguments whose values
determine the function signature, with context-free FE folding where needed.
- Accepts constant expressions in the affected scalar, aggregate, and AI
functions while retaining their type, resource, and value constraints.
- Reads BE-evaluated constant arguments during execution, handles
constant/full-column combinations, and preserves nullable result types and NULL
propagation.
- Validates invalid patterns, formulas, counts, time units, and tokenize
properties consistently, including nullable aggregate inputs and `_state`
functions.
- Adapts the implementation to the existing 4.1 aggregate and regexp
interfaces without importing unrelated master changes.
### Compatibility
Upgrade BE before FE: newly accepted expressions may require the updated BE
execution paths. Datetime/time precision remains within the existing 4.1 range
of 0–6. Mixed-version rolling upgrades were not tested locally.
### Release note
Fixes rejection of constant-expression arguments in affected functions and
makes invalid-argument validation consistent between FE and BE.
### Check List (For Author)
- Test:
- [x] Regression test
- [x] Unit Test
- [ ] Manual test
- Behavior changed:
- [ ] No.
- [x] Yes. Affected functions accept constant expressions rather than
requiring literal arguments; invalid argument values are still rejected.
- Does this need documentation?
- [x] No.
- [ ] Yes.
### Testing
All checks below passed:
- FE and BE Release build: `FE_MAVEN_THREADS=8 ./build.sh --be --fe -j 48`.
- BE unit tests: 222 tests across 10 suites:
```bash
BUILD_TYPE_UT=Release ./run-be-ut.sh -j 48 --run \
--filter='FunctionConstantArgumentTest.*:AggregateFunctionOrthogonalBitmapTest.*:VSequenceMatchTest.*:*AggregateFunctionTopN*.*:FunctionTokenizeTest.*:FunctionLikeTest.*:MathFunctionTest.*:VTimestampFunctionsTest.*'
```
- FE unit tests: 163 tests, with no failures, errors, or skipped tests:
```bash
(cd fe && mvn test -pl fe-common,fe-core -am \
-Dskip.clean=true -Dcheckstyle.skip=true -DfailIfNoTests=false \
-Dtest=ConstantFunctionArgumentTest,FoldConstantTest,MergeDateTruncTest,PushIntoCaseWhenBranchTest,TypeCoercionUtilsTest,ExpressionAnalyzerTest,PartitionColumnTraceTest,MaterializedViewUtilsTest,CastMonotonicityTest,AggregateFunctionVisitorTest)
```
- Regression framework compilation and its 35 unit tests:
`./run-regression-test.sh --compile`.
- Two local fixture suites loaded successfully, followed by a non-generation
comparison run of all six selected SQL suites: 6 passed, 0 failed/fatal/skipped:
```bash
./run-regression-test.sh \
--conf output/local-regression/regression-conf-41900.groovy \
--run -w -d nereids_function_p0,query_p0 \
-s
fold_literal_arguments,nereids_scalar_fn_U,test_digest,test_split_by_regexp,test_query_sys,test_orthogonal_bitmap_expr_calculate
\
-parallel 1
```
- FE Checkstyle: `(cd fe && mvn validate -pl fe-common,fe-core -am
-Dcheckstyle.skip=false -DskipTests)`.
- Full C++ formatting check: `bash build-support/check-format.sh`.
- Whitespace check of the complete committed backport diff.
### Check List (For Reviewer who merge this PR)
- [ ] Confirm the release note
- [ ] Confirm test cases
- [ ] Confirm document
- [ ] Add branch pick label
--
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]