xtern commented on code in PR #7948:
URL: https://github.com/apache/ignite-3/pull/7948#discussion_r3046300665
##########
modules/sql-engine/src/main/java/org/apache/ignite/internal/sql/engine/exec/exp/IgniteExpressions.java:
##########
@@ -182,4 +201,25 @@ private static Type larger(Type type0, Type type1) {
return Double.TYPE;
}
}
+
+ /**
+ * Generates a comparison expression for floating-point types using {@link
Float#compare(float, float)}
+ * or {@link Double#compare(double, double)} instead of primitive
comparison operators.
+ */
+ private static @Nullable Expression compareFloatingPoint(ExpressionType
binaryType, Expression left, Expression right) {
+ Type leftType = left.getType();
+ Type rightType = right.getType();
+
+ boolean isFloat = leftType == Float.TYPE || rightType == Float.TYPE;
+ boolean isDouble = leftType == Double.TYPE || rightType == Double.TYPE;
+
+ if (!isFloat && !isDouble) {
+ return null;
+ }
+
+ Class<?> targetClass = isDouble ? Double.class : Float.class;
+ Expression cmp = Expressions.call(targetClass, "compare", left, right);
+
Review Comment:
For a nullable column, a special null check is added to the expression
before calling the comparison.
--
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]