ranganathg commented on code in PR #1701:
URL: https://github.com/apache/phoenix/pull/1701#discussion_r1346867429


##########
phoenix-core/src/main/java/org/apache/phoenix/expression/ComparisonExpression.java:
##########
@@ -352,7 +356,139 @@ public boolean evaluate(Tuple tuple, 
ImmutableBytesWritable ptr) {
         ptr.set(ByteUtil.compare(op, comparisonResult) ? PDataType.TRUE_BYTES 
: PDataType.FALSE_BYTES);
         return true;
     }
-    
+
+    @Override
+    public boolean contains (Expression other) {
+        if (!(other instanceof ComparisonExpression || other instanceof 
IsNullExpression)) {
+                return false;
+        }
+        if (other instanceof IsNullExpression) {
+            return !((IsNullExpression) other).isNegate();
+        }
+
+        BaseTerminalExpression lhsA = 
WhereCompiler.getBaseTerminalExpression(this.getChildren().get(0));
+        BaseTerminalExpression lhsB = 
WhereCompiler.getBaseTerminalExpression(other.getChildren().get(0));
+        if (!lhsA.equals(lhsB)) {
+            return false;
+        }
+        CompareOperator opA = this.getFilterOp();
+        CompareOperator opB = ((ComparisonExpression) other).getFilterOp();
+        BaseTerminalExpression rhs = WhereCompiler.getBaseTerminalExpression(
+                this.getChildren().get(1));
+        if (rhs instanceof ColumnExpression) {
+            BaseTerminalExpression rhsB = 
WhereCompiler.getBaseTerminalExpression(
+                    other.getChildren().get(1));
+            if (!rhs.equals(rhsB)) {
+                return false;
+            }
+            switch (opA) {

Review Comment:
   may be we can merge all these:
   `              case LESS:  
                   case EQUAL:  
                   case NOT_EQUAL:  
                   case GREATER:  
                       if (opB == LESS) {
                           return true;
                       }
                       return false;
   `



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