[GitHub] [incubator-iceberg] jun-he commented on a change in pull request #357: Add in and not in predicates

2019-08-10 Thread GitBox
jun-he commented on a change in pull request #357: Add in and not in predicates
URL: https://github.com/apache/incubator-iceberg/pull/357#discussion_r312723407
 
 

 ##
 File path: api/src/main/java/org/apache/iceberg/expressions/Predicate.java
 ##
 @@ -62,10 +95,10 @@ public String toString() {
 return String.valueOf(ref()) + " == " + literal();
   case NOT_EQ:
 return String.valueOf(ref()) + " != " + literal();
-//  case IN:
-//break;
-//  case NOT_IN:
-//break;
+  case IN:
+return String.valueOf(ref()) + " in " + literalSet();
 
 Review comment:
   Good point. Will update it accordingly. Thanks.
   


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.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

-
To unsubscribe, e-mail: issues-unsubscr...@iceberg.apache.org
For additional commands, e-mail: issues-h...@iceberg.apache.org



[GitHub] [incubator-iceberg] jun-he commented on a change in pull request #357: Add in and not in predicates

2019-08-10 Thread GitBox
jun-he commented on a change in pull request #357: Add in and not in predicates
URL: https://github.com/apache/incubator-iceberg/pull/357#discussion_r312723380
 
 

 ##
 File path: 
api/src/main/java/org/apache/iceberg/expressions/ExpressionVisitors.java
 ##
 @@ -89,11 +91,11 @@ public R or(R leftResult, R rightResult) {
   return null;
 }
 
-public  R in(BoundReference ref, Literal lit) {
+public  R in(BoundReference ref, Set> lits) {
   return null;
 
 Review comment:
   Yeah, I agree. 
   Although I went through all concrete classes and fixed them (as I changed 
the signature), it is better to throw exception instead of returning `null`.
   It seems better to throw `UnsupportedOperationException` for default 
implementations for all operations. I can make those changes if there is no 
specific reason to `return null`.
   Let me know your comments. Thanks.
   


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.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

-
To unsubscribe, e-mail: issues-unsubscr...@iceberg.apache.org
For additional commands, e-mail: issues-h...@iceberg.apache.org



[GitHub] [incubator-iceberg] jun-he commented on a change in pull request #357: Add in and not in predicates

2019-08-10 Thread GitBox
jun-he commented on a change in pull request #357: Add in and not in predicates
URL: https://github.com/apache/incubator-iceberg/pull/357#discussion_r312720963
 
 

 ##
 File path: api/src/main/java/org/apache/iceberg/expressions/Evaluator.java
 ##
 @@ -134,13 +135,13 @@ public Boolean or(Boolean leftResult, Boolean 
rightResult) {
 }
 
 @Override
-public  Boolean in(BoundReference ref, Literal lit) {
-  throw new UnsupportedOperationException("In is not supported yet");
+public  Boolean in(BoundReference ref, Set> lits) {
+  return lits.contains(Literals.from(ref.get(struct)));
 
 Review comment:
   Thanks for the comment! 
   Taking a quick look at the literal's `comparator`s and seems all of them are 
`consistent with equals` of the underlying values. 
   So it seems to be safe to just put the values into the `Set` instead of 
putting literals.
   I will make a change to avoid the unnecessary literal cast.


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.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

-
To unsubscribe, e-mail: issues-unsubscr...@iceberg.apache.org
For additional commands, e-mail: issues-h...@iceberg.apache.org



[GitHub] [incubator-iceberg] jun-he commented on a change in pull request #357: Add in and not in predicates

2019-08-10 Thread GitBox
jun-he commented on a change in pull request #357: Add in and not in predicates
URL: https://github.com/apache/incubator-iceberg/pull/357#discussion_r312720963
 
 

 ##
 File path: api/src/main/java/org/apache/iceberg/expressions/Evaluator.java
 ##
 @@ -134,13 +135,13 @@ public Boolean or(Boolean leftResult, Boolean 
rightResult) {
 }
 
 @Override
-public  Boolean in(BoundReference ref, Literal lit) {
-  throw new UnsupportedOperationException("In is not supported yet");
+public  Boolean in(BoundReference ref, Set> lits) {
+  return lits.contains(Literals.from(ref.get(struct)));
 
 Review comment:
   Thanks for the comment! 
   Taking a quick look at the literal's `comparator`s and seems all of them are 
consistent with `equals` of the underlying values. 
   So it seems to be safe to just put the values into the `Set` instead of 
putting literals.
   I will make a change to avoid the unnecessary literal cast.


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.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

-
To unsubscribe, e-mail: issues-unsubscr...@iceberg.apache.org
For additional commands, e-mail: issues-h...@iceberg.apache.org