ColinLeeo opened a new pull request, #18826: URL: https://github.com/apache/iotdb/pull/18826
## Description Closes #18792. When a CASE expression and a later output column share an aggregate or intermediate expression, CASE's short-circuit cleanup can invalidate that shared cache. Recomputing it for the later output restores its full reference count, leaving a cached column after the block has been consumed. The next TsBlock can then reuse values from the previous block, producing incorrect results or invalid result blocks. This change clears the filter, common-expression, and projection transformer DAGs before initializing each new input block. `AbstractCaseWhenThenColumnTransformer.clearCache()` also visits every WHEN, THEN, and ELSE descendant so intermediate caches inside nested CASE expressions cannot survive across blocks. All projection DAGs are cleared before evaluating any output, preserving expression reuse within a block and CASE's short-circuit behavior. ### Regression coverage - Add 10 operator unit tests covering different-sized, equal-sized, and empty input blocks; shared intermediate expressions; filter/common expressions with normal and RLE time columns; nested CASE descendants; selected THEN expressions reused by later outputs; skipped branches; and reuse within a block. - Add a table-model integration test using the issue's three-row, two-device, two-window reproducer, with CAST, arithmetic, and shared THEN-expression projections. ### Validation - All 80 calc-commons unit tests passed, including the 10 new tests. Running the new tests against the original implementation reproduced failures and errors. - `IoTDBCaseWhenThenTableIT#testCaseWhenReusesAggregationAcrossBlocks` passed with TableSimpleIT (1 ConfigNode + 1 DataNode), covering all three SQL variants. - The integration-test reactor package build passed with tests skipped. - Spotless was applied to both affected modules; `git diff --check` passed. Local integration-test verification used `-Drat.skip=true` because an unrelated pre-existing, untracked SQL file fails the repository license scan. The new test file includes the standard ASF license header. <hr> This PR has: - [x] been self-reviewed. - [x] added comments explaining the cache lifecycle and intent. - [x] added unit tests covering the changed code paths. - [x] added integration tests. - [x] been tested in a test IoTDB cluster. <hr> ##### Key changed/added classes in this PR - `FilterAndProjectOperator` - `AbstractCaseWhenThenColumnTransformer` - `FilterAndProjectOperatorTest` - `IoTDBCaseWhenThenTableIT` -- 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]
