morrySnow opened a new pull request, #67787:
URL: https://github.com/apache/doris/pull/67787
### What problem does this PR solve?
Issue Number: DORIS-28700
Related PR: N/A
Problem Summary:
User-variable dependencies were registered in the SQL cache context only by
the late `ReplaceVariableByLiteral` rewrite. Function binding unwraps a direct
`Variable` argument to its real expression before that rewrite, so expressions
such as `ABS(@v)` lost the variable dependency. After `@v` changed, the same
SQL could therefore reuse a stale `PhysicalSqlCache` result and return the old
value.
This PR records the complete variable dependency while binding
`UnboundVariable`, then directly returns its real expression. It removes the
now-redundant `VariableToLiteral` / `ReplaceVariableByLiteral` path and the
`ExpressionTrait` variable special case. It also moves the generated-column
variable check to the parsed expression so variables inside functions remain
rejected.
### Release note
None
### Check List (For Author)
- Test
- [x] Regression test
- [x] Unit Test
- [x] Manual test (add detailed scripts or steps below)
- [ ] No need to test or manual test. Explain why:
- [ ] This is a refactor/code format and no logic has been changed.
- [ ] Previous test can cover this change.
- [ ] No code files have been changed.
- [ ] Other reason
Test details:
- `./run-fe-ut.sh --run
org.apache.doris.nereids.rules.analysis.UserVariableAnalysisTest`: 4 tests
passed; all 67 reactor modules succeeded.
- `DISABLE_BUILD_UI=ON ./build.sh --fe`: all 80 modules succeeded;
Checkstyle reported 0 violations.
- `test_generated_column_fault_tolerance_nereids`: passed, including
`ABS(@myvar)` rejection.
- SQL cache regression/manual verification: `@v=-10` missed then hit with
result 10; changing to `-20` missed then hit with result 20; switching back to
`-10` reused the original value-aware cache and returned 10.
- CTAS verification: `CREATE TABLE ... AS SELECT @v` succeeded with the
valid inferred column name `__literal_0`.
The new function-variable scenario in `parse_sql_from_sql_cache` completed
successfully. A full local run later timed out in the pre-existing, unrelated
`test_use_plan_cache33` cache-polling thread.
- Behavior changed:
- [x] No.
- [ ] Yes.
- Does this need documentation?
- [x] No.
- [ ] Yes.
### 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]