szehon-ho commented on code in PR #7898:
URL: https://github.com/apache/iceberg/pull/7898#discussion_r1247552059


##########
spark/v3.4/spark/src/main/java/org/apache/iceberg/spark/SparkV2Filters.java:
##########
@@ -245,6 +251,22 @@ public static Expression convert(Predicate predicate) {
     return null;
   }
 
+  private static Pair<UnboundTerm<Object>, Object> predicateChildren(Predicate 
predicate) {
+    Object value;
+    UnboundTerm<Object> term;

Review Comment:
   Optional, my thought is , it would be clearer to have term be of type 
'NamedReference', instead of super class 'UnboundTerm', not sure what you think.



##########
spark/v3.4/spark/src/main/java/org/apache/iceberg/spark/SparkV2Filters.java:
##########
@@ -289,11 +311,28 @@ private static Object convertLiteral(Literal<?> literal) {
     return literal.value();
   }
 
-  private static Expression handleEqual(String attribute, Object value) {
-    if (NaNUtil.isNaN(value)) {
-      return isNaN(attribute);
+  private static UnboundPredicate<Object> 
handleEqual(Pair<UnboundTerm<Object>, Object> children) {
+    if (children.second() == null) {
+      return isNull(children.first());
+    }
+
+    if (NaNUtil.isNaN(children.second())) {
+      return isNaN(children.first());
+    } else {
+      return equal(children.first(), children.second());
+    }
+  }
+
+  private static UnboundPredicate<Object> handleNotEqual(

Review Comment:
   Sorry for not mentioning earlier, but can we make these two methods take not 
a Pair, but actual arguments, so its easier to read?
   
   Then just invoke in the caller: , handle[Not]Equal(children.first(), 
children.second())



##########
spark/v3.4/spark/src/main/java/org/apache/iceberg/spark/SparkV2Filters.java:
##########
@@ -289,11 +311,28 @@ private static Object convertLiteral(Literal<?> literal) {
     return literal.value();
   }
 
-  private static Expression handleEqual(String attribute, Object value) {
-    if (NaNUtil.isNaN(value)) {
-      return isNaN(attribute);
+  private static UnboundPredicate<Object> 
handleEqual(Pair<UnboundTerm<Object>, Object> children) {
+    if (children.second() == null) {
+      return isNull(children.first());
+    }
+
+    if (NaNUtil.isNaN(children.second())) {
+      return isNaN(children.first());
+    } else {
+      return equal(children.first(), children.second());
+    }
+  }
+
+  private static UnboundPredicate<Object> handleNotEqual(
+      Pair<UnboundTerm<Object>, Object> children) {
+    if (children.second() == null) {
+      return notNull(children.first());
+    }
+
+    if (NaNUtil.isNaN(children.second())) {
+      return notNaN(children.first());
     } else {
-      return equal(attribute, value);
+      return notEqual(children.first(), children.second());

Review Comment:
   I had a question , was this originally a bug?  it was returning 
equal(string, value), not equal(NamedReference, value)



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