Doris-Breakwater commented on issue #68714: URL: https://github.com/apache/doris/issues/68714#issuecomment-5976926015
**Triage: confirmed code-level FE/BE wrong-result mismatch; high priority because a constant `WHERE` condition can discard rows.** The issue has no labels in the captured GitHub metadata. The supplied SQL, versions, and EXPLAIN are sufficient to identify the primary cause; I did not run a Doris cluster. At the reported master commit (`0c29961f45ee976ef61c6a5dfe7b38b40a6ec131`), [FE `FractionalLiteral.uncheckedCastTo(BooleanType)`](https://github.com/apache/doris/blob/0c29961f45ee976ef61c6a5dfe7b38b40a6ec131/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/literal/FractionalLiteral.java#L89-L97) calls `floatValue()` for both `Float` and `Double` before comparing with zero. A nonzero DOUBLE such as `Double.MIN_VALUE` (`5e-324` when parsed) becomes `0.0f`, yielding `FALSE`. [FE cast folding](https://github.com/apache/doris/blob/0c29961f45ee976ef61c6a5dfe7b38b40a6ec131/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/expression/rules/FoldConstantRuleOnFE.java#L496-L530) calls the literal's `checkedCastTo`, which reaches this conversion. [BE `Float64`→BOOLEAN](https://github.com/apache/doris/blob/0c29961f45ee976ef61c6a5dfe7b38b40a6ec131/be/src/exprs/function/cast/cast_to_boolean.h#L74-L78) tests the original value against zero. This explains the reported co nstant/column difference. The precise round-to-zero cutoff is about **half** the smallest positive float32 subnormal (~`7e-46`), rather than the smallest subnormal itself. **Suggested fix and verification:** compare the FE value in double precision (e.g. `((Number) value).doubleValue() == 0`), preserving exact Float and Double values for this check. Add regression coverage for explicit casts and implicit predicates (`IF`, `CASE`, `AND`, `WHERE`) using positive and negative tiny nonzero DOUBLEs, `0.0`, and values on both sides of the float32 rounding boundary. Compare literal and column paths, and check plans so a true constant predicate does not eliminate rows. Verify on the reported 4.1 builds before choosing backports. No additional logs are needed for the primary triage; the reported release results still need maintainer reproduction after a fix. **Separate finding:** At the same commit, [FE `asinh`/`acosh` folding](https://github.com/apache/doris/blob/0c29961f45ee976ef61c6a5dfe7b38b40a6ec131/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/executable/NumericArithmetic.java#L669-L689) uses Commons Math `FastMath`; that commit pins 3.6.1, and I verified locally that both calls return `Infinity` for `Double.MAX_VALUE`. [BE uses `std::asinh`/`std::acosh`](https://github.com/apache/doris/blob/0c29961f45ee976ef61c6a5dfe7b38b40a6ec131/be/src/exprs/function/math.cpp#L61-L79). The reporter's finite column result is consistent with a distinct FE folding mismatch. Please track/test this separately and make folded results match BE for extreme finite inputs; the exact Commons Math overflow step has not been established here. Breakwater-GitHub-Analysis-Slot: slot_2fe6adc9c538 -- 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]
