github-actions[bot] commented on code in PR #67748:
URL: https://github.com/apache/doris/pull/67748#discussion_r4055785461


##########
fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/literal/NumericLiteral.java:
##########
@@ -65,7 +65,10 @@ public int compareTo(ComparableLiteral other) {
                     || other instanceof DecimalLiteral || other instanceof 
DecimalV3Literal) {
                 return this.getBigDecimalValue().compareTo(((NumericLiteral) 
other).getBigDecimalValue());

Review Comment:
   [P1] Use SQL numeric equivalence for constant IN folding
   
   `NumericLiteral.compareTo` now treats `+0.0` and `-0.0` as equal, but 
`FoldConstantRuleOnFE.visitInPredicate` still decides membership with 
`value.equals(item)`. `Literal.equals` delegates to boxed 
`Double`/`Float.equals`, which distinguishes the two signed zeros, so 
`CAST('-0.0' AS DOUBLE) IN (CAST('0.0' AS DOUBLE))` is folded to `FALSE` (and 
`NOT IN` to `TRUE`) even though Doris/BE equality uses `left == right` and SQL 
should return `TRUE`/`FALSE`. Make constant IN/NOT IN use the same numeric 
comparison relation and add signed-zero IN coverage.



##########
fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/literal/NumericLiteral.java:
##########
@@ -65,7 +65,10 @@ public int compareTo(ComparableLiteral other) {
                     || other instanceof DecimalLiteral || other instanceof 
DecimalV3Literal) {
                 return this.getBigDecimalValue().compareTo(((NumericLiteral) 
other).getBigDecimalValue());
             }

Review Comment:
   [P1] Keep RangeInference set algebra consistent with signed-zero equality
   
   This comparator change makes signed zeros compare-equal, but 
`RangeInference` still stores `DiscreteValue`/`NotDiscreteValue` in 
`HashSet`/`LinkedHashSet` and uses `retainAll`/`contains`, which call 
sign-sensitive `Literal.equals`. For example, `D IN (-0.0) AND D IN (0.0)` is 
treated as an empty intersection and rewritten to `D IS NULL AND NULL`/`FALSE`, 
dropping rows where D is zero; `D NOT IN (-0.0) OR D NOT IN (0.0)` can become 
`TRUE` and admit those rows. Use comparator-equivalent membership (or 
canonicalize signed zeros) throughout the range set operations and add compound 
IN/NOT IN tests.



-- 
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]

Reply via email to