[ 
https://issues.apache.org/jira/browse/CALCITE-4764?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Xurenhe updated CALCITE-4764:
-----------------------------
    Description: 
I run an example in `RexImplicationChecker`, but it throw ex.
{code:sql}
col is a field of Java type "Integer"
rexnode1: cast(col as char) > '10'
rexnode2: cast(col as char) > '20'
{code}
I debug it, found some unclear code in 
`org.apache.calcite.plan.RexImplicationChecker.InputUsageFinder#updateBinaryOpUsage`.
 I found `InputUsageFinder` will discard `CAST`, as screenshot

!image-2021-09-05-17-02-58-266.png!
----
Should we enchane code here?
 And, it may be root reason of 
[CALCITE-4736|https://issues.apache.org/jira/projects/CALCITE/issues/CALCITE-4736]
----
Complete test:
{code:java}
  @Test void testSimple() {
    final Fixture f = new Fixture();
    final RexNode xGeB = f.ge(f.cast(f.charDataType, f.i), f.charLiteral("20"));
    final RexNode xGeA = f.ge(f.cast(f.charDataType, f.i), f.charLiteral("10"));

    f.checkImplies(xGeB, xGeA);
  }
{code}
----
I will follow and improve it, If it's a deficiency.
 Thanks a lot.

  was:
I run an example in `RexImplicationChecker`, but it throw ex.
{code:sql}
col is a field of Java type "Integer"
rexnode1: cast(col as char) > '10'
rexnode2: cast(col as char) > '20'
{code}
I debug it, found some unclear code in 
`org.apache.calcite.plan.RexImplicationChecker.InputUsageFinder#updateBinaryOpUsage`.
 I found `InputUsageFinder` will discard `CAST`, as screenshot

!image-2021-09-05-17-02-58-266.png!
----
Should we enchane code here?
 And, it may be root reason of 
[CALCITE-4736|https://issues.apache.org/jira/projects/CALCITE/issues/CALCITE-4736]
----
Complete test:
{code:java}
  @Test void testSimple() {
    final Fixture f = new Fixture();
    final RexNode xGeB = f.ge(f.cast(f.charDataType, f.i), f.charLiteral("10"));
    final RexNode xGeA = f.ge(f.cast(f.charDataType, f.i), f.charLiteral("20"));

    f.checkImplies(xGeB, xGeA);
  }
{code}
----
I will follow and improve it, If it's a deficiency.
 Thanks a lot.


> Executing `RexImplicationChecker#implies` discard operator of `CAST`.
> ---------------------------------------------------------------------
>
>                 Key: CALCITE-4764
>                 URL: https://issues.apache.org/jira/browse/CALCITE-4764
>             Project: Calcite
>          Issue Type: Bug
>          Components: core
>            Reporter: Xurenhe
>            Priority: Major
>         Attachments: image-2021-09-05-17-02-58-266.png
>
>
> I run an example in `RexImplicationChecker`, but it throw ex.
> {code:sql}
> col is a field of Java type "Integer"
> rexnode1: cast(col as char) > '10'
> rexnode2: cast(col as char) > '20'
> {code}
> I debug it, found some unclear code in 
> `org.apache.calcite.plan.RexImplicationChecker.InputUsageFinder#updateBinaryOpUsage`.
>  I found `InputUsageFinder` will discard `CAST`, as screenshot
> !image-2021-09-05-17-02-58-266.png!
> ----
> Should we enchane code here?
>  And, it may be root reason of 
> [CALCITE-4736|https://issues.apache.org/jira/projects/CALCITE/issues/CALCITE-4736]
> ----
> Complete test:
> {code:java}
>   @Test void testSimple() {
>     final Fixture f = new Fixture();
>     final RexNode xGeB = f.ge(f.cast(f.charDataType, f.i), 
> f.charLiteral("20"));
>     final RexNode xGeA = f.ge(f.cast(f.charDataType, f.i), 
> f.charLiteral("10"));
>     f.checkImplies(xGeB, xGeA);
>   }
> {code}
> ----
> I will follow and improve it, If it's a deficiency.
>  Thanks a lot.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to