You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@ignite.apache.org by "xtern (via GitHub)" <gi...@apache.org> on 2026/04/07 14:55:45 UTC

[PR] IGNITE-26613 Use compare() in binary comparisons for floating point types [ignite-3]

xtern opened a new pull request, #7944:
URL: https://github.com/apache/ignite-3/pull/7944

   https://issues.apache.org/jira/browse/IGNITE-26613


-- 
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: notifications-unsubscribe@ignite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] IGNITE-26613 Use compare() in binary comparisons for floating point types [ignite-3]

Posted by "xtern (via GitHub)" <gi...@apache.org>.
xtern closed pull request #7944: IGNITE-26613 Use compare() in binary comparisons for floating point types
URL: https://github.com/apache/ignite-3/pull/7944


-- 
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: notifications-unsubscribe@ignite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] IGNITE-26613 Use compare() in binary comparisons for floating point types [ignite-3]

Posted by "Copilot (via GitHub)" <gi...@apache.org>.
Copilot commented on code in PR #7944:
URL: https://github.com/apache/ignite-3/pull/7944#discussion_r3045922279


##########
modules/sql-engine/src/main/java/org/apache/ignite/internal/sql/engine/externalize/RelJson.java:
##########
@@ -420,7 +420,19 @@ private Object toJson(RexNode node) {
                 RexLiteral literal = (RexLiteral) node;
                 Object value = literal.getValue3();
                 map = map();
-                map.put("literal", toJson(value));
+                // Convert the approximate numeric negative zero (-0.0) value to a string to preserve the minus sign,
+                // otherwise due to USE_BIG_DECIMAL_FOR_FLOATS jackson will create a BigDecimal from a double (-0.0)
+                // and this will result in the loss of the minus sign.
+                // Other special values +Infinity/-Infinity/NaN are serialized by jackson as strings.
+                // The value in RexLiteral for approximate types is always of type Double (see RexLiteral#valueMatchesType).
+                if (value instanceof Double
+                        && isApproximateNumeric(node.getType())
+                        && ((Double) value == -0.0d)) {
+                    map.put("literal", "-0.0");
+                } else {
+                    map.put("literal", toJson(value));
+                }

Review Comment:
   The negative-zero detection uses `((Double) value == -0.0d)`, but `-0.0d == 0.0d` is `true`, so this branch will also match positive zero and serialize `0.0` as the string "-0.0". That would change semantics after deserialization now that comparisons distinguish +0.0 and -0.0. Use a sign-preserving check (e.g., `Double.doubleToRawLongBits((Double) value) == Double.doubleToRawLongBits(-0.0d)` or `Double.compare(...) == 0` plus raw-bits) so only negative zero is converted to the string form.



-- 
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: notifications-unsubscribe@ignite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org