kasakrisz commented on code in PR #5196: URL: https://github.com/apache/hive/pull/5196#discussion_r1665678749
########## 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: What happens if somehow we end up with an expression like ``` NOT(SEARCH($0, Sarg[[<lower>...<upper>]])) ``` in one of the query plans ? Maybe I'm missing something but in case of `NOT(<expr_a>)` I would expect a recursive call something like ``` case NOT: return 1 - estimate(<expr_a>); ``` I found that handling `NOT` was added by https://issues.apache.org/jira/browse/HIVE-8768 but description is missing. -- 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