morrySnow opened a new pull request, #67893: URL: https://github.com/apache/doris/pull/67893
## Problem Narrow numeric casts can return NULL for out-of-range values even when the source slot is NOT NULL. A range simplification that uses only the source-slot nullability can incorrectly replace a nullable comparison with a non-null Boolean constant. Existing coverage did not permanently exercise the INT-to-DECIMALV3(2, 0) path end to end. ## Root cause The production fix already preserves a cast that may introduce NULL as the nullability witness for range-derived constants. The remaining gap was test coverage: the focused unit test used BIGINT-to-TINYINT, and there was no permanent SQL regression proving that positive and negative decimal overflow stay NULL in both projections and filters. ## Reproduction Use a NOT NULL INT column containing -100, -99, 0, 99, and 100. Cast it to DECIMALV3(2, 0) and compare it with 99 or -99. The values outside the decimal range cast to NULL, so every comparison on those rows must remain NULL and WHERE must filter those rows out. The same semantics apply to TryCast. ## Fix - Add exact rewrite assertions for Cast and TryCast from a non-null INT to DECIMALV3(2, 0), covering both true-or-null and false-or-null results at the upper and lower bounds. - Add a safe TinyInt-to-DECIMALV3(3, 0) widening control to ensure non-null Boolean simplification remains enabled when the conversion is total. - Add a permanent regression suite covering projection results, WHERE behavior, positive and negative overflow, and enabled-versus-disabled rule results. - Assert the optimized project retains the complete Cast/TryCast expression inside the null-aware form. ## Tests - `./run-fe-ut.sh --run org.apache.doris.nereids.rules.expression.rules.SimplifyComparisonPredicateTest` — 14 tests, 0 failures, 0 errors, 0 skipped. - `DISABLE_BUILD_UI=ON ./build.sh --fe` — full FE reactor build passed; checkstyle reported 0 violations. - Generated the new expected output with `-forceGenOut` against the rebuilt sandbox — 1 suite passed. - Ran the new regression normally against the rebuilt sandbox — 1 suite passed, 0 failed/fatal/skipped. -- 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]
