morrySnow opened a new pull request, #67890: URL: https://github.com/apache/doris/pull/67890
## Problem Time-field simplification could bypass an explicit DATETIMEV2 precision conversion around FROM_UNIXTIME. For example, extracting MICROSECOND after casting a decimal timestamp through DATETIMEV2(3) should return 123000, but the specialized rewrite operated on the original value and returned 123456. The same mismatch could change predicate results. ## Root cause The rewrite helper removed every Cast whose target was a datetime type. It did not distinguish analysis-inserted coercions from explicit casts, strict casts, or TRY_CAST, even though those nodes carry precision and failure semantics. ## Reproduction Use a DECIMAL(18,6) value of 1.123456 and evaluate MICROSECOND(CAST(FROM_UNIXTIME(value) AS DATETIMEV2(3))) in both a projection and a WHERE predicate. The explicit cast must round or truncate to millisecond precision before extraction, producing 123000, and the plan must not replace the expression with microsecond_from_unixtime. ## Fix Only remove an ordinary datetime Cast when it is both implicit and non-strict. Preserve explicit casts, strict casts, and TRY_CAST. The normal optimization remains enabled for analysis-inserted non-strict datetime coercions. ## Tests - ./run-fe-ut.sh --run org.apache.doris.nereids.rules.expression.SimplifyTimeFieldFromUnixtimeTest (5 tests, 0 failures/errors) - DISABLE_BUILD_UI=ON ./build.sh --fe (BUILD SUCCESS, including checkstyle) - ./run-regression-test.sh --conf /tmp/env2-range-regression-conf.groovy --run -f regression-test/suites/datatype_p0/date/test_from_unixtime.groovy (1/1 suite passed) -- 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]
