soumyakanti3578 commented on code in PR #5196:
URL: https://github.com/apache/hive/pull/5196#discussion_r1674731262


##########
ql/src/test/org/apache/hadoop/hive/ql/optimizer/calcite/stats/TestFilterSelectivityEstimator.java:
##########
@@ -508,8 +492,19 @@ public void 
testComputeRangePredicateSelectivityBetweenWithNULLS() {
   public void testComputeRangePredicateSelectivityNotBetweenWithNULLS() {
     doReturn((double) 20).when(tableMock).getRowCount();
     
doReturn(Collections.singletonList(stats)).when(tableMock).getColStat(Collections.singletonList(0));
-    RexNode filter = REX_BUILDER.makeCall(SqlStdOperatorTable.BETWEEN, 
boolTrue, inputRef0, int1, int3);
+    RexNode filter = makeNotBetween(inputRef0, int1, int3);
     FilterSelectivityEstimator estimator = new 
FilterSelectivityEstimator(scan, mq);
     Assert.assertEquals(0.55, estimator.estimateSelectivity(filter), DELTA);
   }
+
+  private RexNode makeNotBetween(RexNode inputRef, RexNode left, RexNode 
right) {
+    RexNode withOr = REX_BUILDER.makeCall(
+        SqlStdOperatorTable.OR,
+        REX_BUILDER.makeCall(SqlStdOperatorTable.LESS_THAN, inputRef, left),
+        REX_BUILDER.makeCall(SqlStdOperatorTable.GREATER_THAN, inputRef, right)
+    );
+    RexSimplify simplify = new RexSimplify(REX_BUILDER, 
RelOptPredicateList.EMPTY, RexUtil.EXECUTOR);
+
+    return simplify.simplify(withOr);

Review Comment:
   In Calcite 1.33, `NOT SEARCH...` is simplified to `SEARCH`: 
https://github.com/apache/calcite/blob/calcite-1.33.0/core/src/main/java/org/apache/calcite/rex/RexSimplify.java#L741
   
   I have made the change that you suggested - using `NOT` and `makeBetween` to 
create `NOT BETWEEN`, however, I also had to remove a test where right value 
was lower than left, as it throws an exception.



-- 
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: gitbox-unsubscr...@hive.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


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

Reply via email to