aokolnychyi commented on code in PR #7898:
URL: https://github.com/apache/iceberg/pull/7898#discussion_r1248353665


##########
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;
+    if (isRef(leftChild(predicate)) && isLiteral(rightChild(predicate))) {
+      term = ref(SparkUtil.toColumnName(leftChild(predicate)));
+      value = convertLiteral(rightChild(predicate));
+    } else if (isRef(rightChild(predicate)) && 
isLiteral(leftChild(predicate))) {
+      term = ref(SparkUtil.toColumnName(rightChild(predicate)));
+      value = convertLiteral(leftChild(predicate));
+    } else {
+      return null;

Review Comment:
   Optional: I am not sure there is a lot of value in keeping `term` and 
`value` outside given that we have a nested return and not using them anywhere 
below. I'd probably format it like this, it up to you, though:
   
   ```
   if (isRef(leftChild(predicate)) && isLiteral(rightChild(predicate))) {
     UnboundTerm<Object> term = 
ref(SparkUtil.toColumnName(leftChild(predicate)));
     Object value = convertLiteral(rightChild(predicate));
     return Pair.of(term, value);
   
   } else if (isRef(rightChild(predicate)) && isLiteral(leftChild(predicate))) {
     UnboundTerm<Object> term = 
ref(SparkUtil.toColumnName(rightChild(predicate)));
     Object value = convertLiteral(leftChild(predicate));
     return Pair.of(term, value);
   
   } else {
     return null;
   }
   ```



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