JingsongLi commented on code in PR #9427:
URL: https://github.com/apache/paimon/pull/9427#discussion_r3878872251


##########
paimon-flink/paimon-flink-common/src/main/java/org/apache/paimon/flink/PredicateConverter.java:
##########
@@ -74,74 +74,93 @@ public PredicateConverter(PredicateBuilder builder) {
 
     @Override
     public Predicate visit(CallExpression call) {
+        return visit(call, false);
+    }
+
+    private Predicate visit(CallExpression call, boolean negated) {
         FunctionDefinition func = call.getFunctionDefinition();
         List<Expression> children = call.getChildren();
 
         if (func == BuiltInFunctionDefinitions.AND) {
-            return PredicateBuilder.and(flattenAndConvert(children, func));
+            requireAtLeastArity(children, 2);
+            List<Predicate> predicates = flattenAndConvert(children, func, 
negated);
+            return negated ? PredicateBuilder.or(predicates) : 
PredicateBuilder.and(predicates);
         } else if (func == BuiltInFunctionDefinitions.OR) {
-            return PredicateBuilder.or(flattenAndConvert(children, func));
+            requireAtLeastArity(children, 2);
+            List<Predicate> predicates = flattenAndConvert(children, func, 
negated);
+            return negated ? PredicateBuilder.and(predicates) : 
PredicateBuilder.or(predicates);
+        } else if (func == BuiltInFunctionDefinitions.NOT) {
+            requireArity(children, 1);
+            return visit(children.get(0), !negated);
         } else if (func == BuiltInFunctionDefinitions.EQUALS) {
-            return visitBiFunction(children, builder::equal, builder::equal);
+            return negated
+                    ? visitBiFunction(children, builder::notEqual, 
builder::notEqual)
+                    : visitBiFunction(children, builder::equal, 
builder::equal);
         } else if (func == BuiltInFunctionDefinitions.NOT_EQUALS) {
-            return visitBiFunction(children, builder::notEqual, 
builder::notEqual);
+            return negated
+                    ? visitBiFunction(children, builder::equal, builder::equal)
+                    : visitBiFunction(children, builder::notEqual, 
builder::notEqual);
         } else if (func == BuiltInFunctionDefinitions.GREATER_THAN) {

Review Comment:
   [P1] Preserve Flink NaN semantics for negated comparisons
   
   For `FLOAT` and `DOUBLE`, this rewrite is not equivalent to the original 
expression. Flink numeric comparisons use Java operators, so `NOT (NaN > 1.0)` 
evaluates to true, while the Paimon `LessOrEqual` predicate orders values 
through `Double.compare` and rejects `NaN`. Because this predicate is pushed 
down before the remaining Flink filter runs, the row is discarded and the query 
returns incomplete results.
   
   Please keep negated floating-point comparisons unsupported/residual, or 
construct NaN-aware equivalents for every comparison direction and add 
row/source tests containing NaN.



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

Reply via email to