Skip to content

Commit

Permalink
Revert [CALCITE-5036] RelMetadataQuery#getPulledUpPredicates suppor…
Browse files Browse the repository at this point in the history
…t to analyze constant key for the operator of IS_NOT_DISTINCT_FROM
  • Loading branch information
NobiGo committed Dec 23, 2024
1 parent 0badcce commit e681096
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -308,18 +308,11 @@ public RelOptPredicateList getPredicates(Filter filter, RelMetadataQuery mq) {
final RexBuilder rexBuilder = filter.getCluster().getRexBuilder();
final RelOptPredicateList inputInfo = mq.getPulledUpPredicates(input);

// Simplify condition using RexSimplify.
final RexNode condition = filter.getCondition();
final RexExecutor executor =
Util.first(filter.getCluster().getPlanner().getExecutor(), RexUtil.EXECUTOR);
final RexSimplify simplify = new RexSimplify(rexBuilder, RelOptPredicateList.EMPTY, executor);
final RexNode simplifiedCondition = simplify.simplify(condition);

return Util.first(inputInfo, RelOptPredicateList.EMPTY)
.union(rexBuilder,
RelOptPredicateList.of(rexBuilder,
RexUtil.retainDeterministic(
RelOptUtil.conjunctions(simplifiedCondition))));
RelOptUtil.conjunctions(filter.getCondition()))));
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5854,6 +5854,7 @@ private HepProgram getTransitiveProgram() {
+ "where deptno is not distinct from 10";
sql(sql).withPre(getTransitiveProgram())
.withRule(CoreRules.JOIN_PUSH_TRANSITIVE_PREDICATES,
CoreRules.FILTER_REDUCE_EXPRESSIONS,
CoreRules.PROJECT_REDUCE_EXPRESSIONS)
.check();
}
Expand All @@ -5864,6 +5865,7 @@ private HepProgram getTransitiveProgram() {
+ "where mgr is not distinct from null";
sql(sql).withPre(getTransitiveProgram())
.withRule(CoreRules.JOIN_PUSH_TRANSITIVE_PREDICATES,
CoreRules.FILTER_REDUCE_EXPRESSIONS,
CoreRules.PROJECT_REDUCE_EXPRESSIONS)
.check();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5165,8 +5165,9 @@ LogicalProject(EMPNO=[$0], ENAME=[$1], JOB=[$2], MGR=[$3], HIREDATE=[$4], SAL=[$
<![CDATA[
LogicalProject(EMPNO=[$0], ENAME=[$1], JOB=[$2], MGR=[$3], HIREDATE=[$4], SAL=[$5], COMM=[$6], DEPTNO=[$7], SLACKER=[$8], EMPNO0=[$9], ENAME0=[$10], JOB0=[$11], MGR0=[$12], HIREDATE0=[$13], SAL0=[$14], COMM0=[$15], DEPTNO0=[$16], SLACKER0=[$17])
LogicalJoin(condition=[=($16, $7)], joinType=[inner])
LogicalFilter(condition=[NOT(OR(=($7, 4), =($7, 6)))])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
LogicalFilter(condition=[SEARCH($7, Sarg[(-∞..4), (4..6), (6..+∞)])])
LogicalFilter(condition=[NOT(OR(=($7, 4), =($7, 6)))])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
LogicalFilter(condition=[SEARCH($7, Sarg[(-∞..4), (4..6), (6..+∞)])])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
]]>
Expand Down Expand Up @@ -8920,7 +8921,7 @@ LogicalProject(DEPTNO=[$7], EXPR$1=[+($7, 1)], EXPR$2=[+($0, $7)])
<Resource name="planAfter">
<![CDATA[
LogicalProject(DEPTNO=[10], EXPR$1=[11], EXPR$2=[+($0, 10)])
LogicalFilter(condition=[OR(AND(IS NULL($7), IS NULL(10)), IS TRUE(=($7, 10)))])
LogicalFilter(condition=[=($7, 10)])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
]]>
</Resource>
Expand Down Expand Up @@ -8957,7 +8958,7 @@ LogicalProject(MGR=[$3], DEPTNO=[$7])
<Resource name="planAfter">
<![CDATA[
LogicalProject(MGR=[null:INTEGER], DEPTNO=[$7])
LogicalFilter(condition=[OR(AND(IS NULL($3), IS NULL(null:INTEGER)), IS TRUE(=($3, null)))])
LogicalFilter(condition=[IS NULL($3)])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
]]>
</Resource>
Expand Down

0 comments on commit e681096

Please sign in to comment.