You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@calcite.apache.org by GitBox <gi...@apache.org> on 2022/03/12 04:40:34 UTC

[GitHub] [calcite] wojustme opened a new pull request #2743: [CALCITE-5036] RelMdPredicates support to analyze constant key for the operator of IS_NOT_DISTINCT_FROM

wojustme opened a new pull request #2743:
URL: https://github.com/apache/calcite/pull/2743


   JIRA: https://issues.apache.org/jira/browse/CALCITE-5036


-- 
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: commits-unsubscribe@calcite.apache.org

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



[GitHub] [calcite] xy2953396112 commented on a change in pull request #2743: [CALCITE-5036] RelMdPredicates support to analyze constant key for the operator of IS_NOT_DISTINCT_FROM

Posted by GitBox <gi...@apache.org>.
xy2953396112 commented on a change in pull request #2743:
URL: https://github.com/apache/calcite/pull/2743#discussion_r825700693



##########
File path: core/src/main/java/org/apache/calcite/rel/metadata/RelMdPredicates.java
##########
@@ -278,11 +278,18 @@ public RelOptPredicateList getPredicates(Filter filter, RelMetadataQuery mq) {
     final RexBuilder rexBuilder = filter.getCluster().getRexBuilder();
     final RelOptPredicateList inputInfo = mq.getPulledUpPredicates(input);
 
+    // Simplify filter's condition using RexSimplify.

Review comment:
       Please not use `filter's`




-- 
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: commits-unsubscribe@calcite.apache.org

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



[GitHub] [calcite] wojustme commented on a change in pull request #2743: [CALCITE-5036] RelMdPredicates support to analyze constant key for the operator of IS_NOT_DISTINCT_FROM

Posted by GitBox <gi...@apache.org>.
wojustme commented on a change in pull request #2743:
URL: https://github.com/apache/calcite/pull/2743#discussion_r834912336



##########
File path: core/src/main/java/org/apache/calcite/rel/metadata/RelMdPredicates.java
##########
@@ -278,11 +278,18 @@ public RelOptPredicateList getPredicates(Filter filter, RelMetadataQuery mq) {
     final RexBuilder rexBuilder = filter.getCluster().getRexBuilder();
     final RelOptPredicateList inputInfo = mq.getPulledUpPredicates(input);
 
+    // Simplify filter's condition using RexSimplify.

Review comment:
       update it.




-- 
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: commits-unsubscribe@calcite.apache.org

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



[GitHub] [calcite] wojustme commented on pull request #2743: [CALCITE-5036] RelMdPredicates support to analyze constant key for the operator of IS_NOT_DISTINCT_FROM

Posted by GitBox <gi...@apache.org>.
wojustme commented on pull request #2743:
URL: https://github.com/apache/calcite/pull/2743#issuecomment-1085336883


   Hi @hsyuan @NobiGo 
   I look back the discussion for this issue and pr, there are not any divergence.
   Could you help me merge it?
   Thanks a lot.


-- 
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: commits-unsubscribe@calcite.apache.org

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



[GitHub] [calcite] wojustme commented on pull request #2743: [CALCITE-5036] RelMdPredicates support to analyze constant key for the operator of IS_NOT_DISTINCT_FROM

Posted by GitBox <gi...@apache.org>.
wojustme commented on pull request #2743:
URL: https://github.com/apache/calcite/pull/2743#issuecomment-1080577927


   @NobiGo Hi, could review and merge this pr, if you don't have any questions about these changes?
   Thanks a lot.


-- 
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: commits-unsubscribe@calcite.apache.org

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



[GitHub] [calcite] wojustme removed a comment on pull request #2743: [CALCITE-5036] RelMdPredicates support to analyze constant key for the operator of IS_NOT_DISTINCT_FROM

Posted by GitBox <gi...@apache.org>.
wojustme removed a comment on pull request #2743:
URL: https://github.com/apache/calcite/pull/2743#issuecomment-1080577927


   @NobiGo Hi, could review and merge this pr, if you don't have any questions about these changes?
   Thanks a lot.


-- 
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: commits-unsubscribe@calcite.apache.org

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



[GitHub] [calcite] wojustme commented on pull request #2743: [CALCITE-5036] RelMdPredicates support to analyze constant key for the operator of IS_NOT_DISTINCT_FROM

Posted by GitBox <gi...@apache.org>.
wojustme commented on pull request #2743:
URL: https://github.com/apache/calcite/pull/2743#issuecomment-1078617173


   Hi @asolimando Could you take a time to review this pr.
   
   Thanks a lot.


-- 
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: commits-unsubscribe@calcite.apache.org

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



[GitHub] [calcite] wojustme commented on a change in pull request #2743: [CALCITE-5036] RelMdPredicates support to analyze constant key for the operator of IS_NOT_DISTINCT_FROM

Posted by GitBox <gi...@apache.org>.
wojustme commented on a change in pull request #2743:
URL: https://github.com/apache/calcite/pull/2743#discussion_r834912551



##########
File path: core/src/test/resources/org/apache/calcite/test/RelOptRulesTest.xml
##########
@@ -6670,6 +6669,48 @@ LogicalProject(DEPTNO=[$7], EXPR$1=[+($7, 1)], EXPR$2=[+($0, $7)])
 LogicalProject(DEPTNO=[10], EXPR$1=[11], EXPR$2=[+($0, 10)])
   LogicalFilter(condition=[=($7, 10)])
     LogicalTableScan(table=[[CATALOG, SALES, EMP]])
+]]>
+    </Resource>
+  </TestCase>
+  <TestCase name="testPullConstantIntoProjectWithIsNotDistinctFrom">
+    <Resource name="sql">
+      <![CDATA[select deptno, deptno + 1, empno + deptno
+from sales.emp
+where deptno is not distinct from 10]]>
+    </Resource>
+    <Resource name="planBefore">
+      <![CDATA[
+LogicalProject(DEPTNO=[$7], EXPR$1=[+($7, 1)], EXPR$2=[+($0, $7)])
+  LogicalFilter(condition=[OR(AND(IS NULL($7), IS NULL(10)), IS TRUE(=($7, 10)))])
+    LogicalTableScan(table=[[CATALOG, SALES, EMP]])
+]]>
+    </Resource>
+    <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)))])
+    LogicalTableScan(table=[[CATALOG, SALES, EMP]])
+]]>
+    </Resource>
+  </TestCase>
+  <TestCase name="testPullConstantIntoProjectWithIsNotDistinctFromForNull">
+    <Resource name="sql">
+      <![CDATA[select empno, deptno

Review comment:
       Yes, it's my mistake.




-- 
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: commits-unsubscribe@calcite.apache.org

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



[GitHub] [calcite] wojustme closed pull request #2743: [CALCITE-5036] RelMdPredicates support to analyze constant key for the operator of IS_NOT_DISTINCT_FROM

Posted by GitBox <gi...@apache.org>.
wojustme closed pull request #2743:
URL: https://github.com/apache/calcite/pull/2743


   


-- 
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: commits-unsubscribe@calcite.apache.org

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



[GitHub] [calcite] wojustme removed a comment on pull request #2743: [CALCITE-5036] RelMdPredicates support to analyze constant key for the operator of IS_NOT_DISTINCT_FROM

Posted by GitBox <gi...@apache.org>.
wojustme removed a comment on pull request #2743:
URL: https://github.com/apache/calcite/pull/2743#issuecomment-1078615838


   > 
   
   


-- 
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: commits-unsubscribe@calcite.apache.org

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



[GitHub] [calcite] NobiGo commented on a change in pull request #2743: [CALCITE-5036] RelMdPredicates support to analyze constant key for the operator of IS_NOT_DISTINCT_FROM

Posted by GitBox <gi...@apache.org>.
NobiGo commented on a change in pull request #2743:
URL: https://github.com/apache/calcite/pull/2743#discussion_r825555915



##########
File path: core/src/test/java/org/apache/calcite/test/RelOptRulesTest.java
##########
@@ -5582,8 +5603,8 @@ private void checkSemiJoinRuleOnAntiJoin(RelOptRule rule) {
   @Test void testAggregateConstantKeyRule3() {
     final String sql = "select job\n"
         + "from sales.emp\n"
-        + "where sal is null and job = 'Clerk'\n"
-        + "group by sal, job\n"
+        + "where mgr is null and job = 'Clerk'\n"

Review comment:
       I want to know why we need to change the filter condition? 

##########
File path: core/src/test/resources/org/apache/calcite/test/RelOptRulesTest.xml
##########
@@ -6670,6 +6669,48 @@ LogicalProject(DEPTNO=[$7], EXPR$1=[+($7, 1)], EXPR$2=[+($0, $7)])
 LogicalProject(DEPTNO=[10], EXPR$1=[11], EXPR$2=[+($0, 10)])
   LogicalFilter(condition=[=($7, 10)])
     LogicalTableScan(table=[[CATALOG, SALES, EMP]])
+]]>
+    </Resource>
+  </TestCase>
+  <TestCase name="testPullConstantIntoProjectWithIsNotDistinctFrom">
+    <Resource name="sql">
+      <![CDATA[select deptno, deptno + 1, empno + deptno
+from sales.emp
+where deptno is not distinct from 10]]>
+    </Resource>
+    <Resource name="planBefore">
+      <![CDATA[
+LogicalProject(DEPTNO=[$7], EXPR$1=[+($7, 1)], EXPR$2=[+($0, $7)])
+  LogicalFilter(condition=[OR(AND(IS NULL($7), IS NULL(10)), IS TRUE(=($7, 10)))])
+    LogicalTableScan(table=[[CATALOG, SALES, EMP]])
+]]>
+    </Resource>
+    <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)))])
+    LogicalTableScan(table=[[CATALOG, SALES, EMP]])
+]]>
+    </Resource>
+  </TestCase>
+  <TestCase name="testPullConstantIntoProjectWithIsNotDistinctFromForNull">
+    <Resource name="sql">
+      <![CDATA[select empno, deptno

Review comment:
       The SQL is wrong? The plan and the SQL is inconsistent




-- 
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: commits-unsubscribe@calcite.apache.org

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



[GitHub] [calcite] wojustme commented on a change in pull request #2743: [CALCITE-5036] RelMdPredicates support to analyze constant key for the operator of IS_NOT_DISTINCT_FROM

Posted by GitBox <gi...@apache.org>.
wojustme commented on a change in pull request #2743:
URL: https://github.com/apache/calcite/pull/2743#discussion_r827573770



##########
File path: core/src/test/java/org/apache/calcite/test/RelOptRulesTest.java
##########
@@ -5582,8 +5603,8 @@ private void checkSemiJoinRuleOnAntiJoin(RelOptRule rule) {
   @Test void testAggregateConstantKeyRule3() {
     final String sql = "select job\n"
         + "from sales.emp\n"
-        + "where sal is null and job = 'Clerk'\n"
-        + "group by sal, job\n"
+        + "where mgr is null and job = 'Clerk'\n"

Review comment:
       @NobiGo Thanks for your reply.
   I wanted to submit this pr to solve [ISSUE-5038](https://issues.apache.org/jira/browse/CALCITE-5038) together。
   But, I thought about it for a while, I think I may split the changed codes into two prs to prevent ambiguity.
   Please review [PR-2742](https://github.com/apache/calcite/pull/2742) firstly.
   




-- 
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: commits-unsubscribe@calcite.apache.org

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



[GitHub] [calcite] wojustme commented on pull request #2743: [CALCITE-5036] RelMdPredicates support to analyze constant key for the operator of IS_NOT_DISTINCT_FROM

Posted by GitBox <gi...@apache.org>.
wojustme commented on pull request #2743:
URL: https://github.com/apache/calcite/pull/2743#issuecomment-1078615838


   > 
   
   


-- 
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: commits-unsubscribe@calcite.apache.org

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



[GitHub] [calcite] NobiGo merged pull request #2743: [CALCITE-5036] RelMdPredicates support to analyze constant key for the operator of IS_NOT_DISTINCT_FROM

Posted by GitBox <gi...@apache.org>.
NobiGo merged pull request #2743:
URL: https://github.com/apache/calcite/pull/2743


   


-- 
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: commits-unsubscribe@calcite.apache.org

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



[GitHub] [calcite] xy2953396112 commented on pull request #2743: [CALCITE-5036] RelMdPredicates support to analyze constant key for the operator of IS_NOT_DISTINCT_FROM

Posted by GitBox <gi...@apache.org>.
xy2953396112 commented on pull request #2743:
URL: https://github.com/apache/calcite/pull/2743#issuecomment-1066514372


   How is this PR different from `https://github.com/apache/calcite/pull/2742`?
   it should be merged in one PR.
   
   
   
   
   
   


-- 
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: commits-unsubscribe@calcite.apache.org

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