kgyrtkirk commented on issue #1044: [CALCITE-2838] Simplification: Remove 
redundant IS TRUE/IS NOT FALSE …
URL: https://github.com/apache/calcite/pull/1044#issuecomment-463818974
 
 
   >> By the way, why don't you consider IS_TRUE+UnknownAs.TRUE and other 
Unknown.As.TRUE cases?
   
   > we are switching from `UnknownAs.TRUE` to `UnknownAs.FALSE` ; so it can't 
be removed.
   
   An alternate way to think about `UnknownAs` modes is by `IS X` operators.
   
   x | x IS TRUE | [UAF] x | x IS NOT FALSE | [UAT] x
   -|-|-|-|-
   -1|-1|-1|-1|-1
   0|-1|-1|1|1
   1|1|1|1|1
   
   Let's consider `[UAT] x IS TRUE`; to move to proper 3-valued logic, I would 
instead write:
   `(x IS TRUE) IS NOT FALSE`
   
   x | x IS TRUE | (x IS TRUE) IS NOT FALSE | F(X) IS NOT FALSE
   -|-|-|-
   -1|-1|-1|-1
   0|-1|-1|-1
   1|1|1|1
   
   Question is: is there an `F` which could satisfy the truth table?
   
   What could be used to construct `F`? 
   
   * `IS X` operators are most probably out of scope; since we are trying to 
replace one of them
   * `NOT` is good; but has no effect on "UNKNOWN"
   * `CASE`, `AND`, `OR`, `COALESCE` .... adds much more complexity
   
   I think it's not possible to give a an `F` in this case; which might be 
better.
   
   So I think the existing 4 is all what we can do right now; I'm considering 
adding something like the following as a comment:
   
   `UnknownAs.FALSE` corresponds to `x IS TRUE`
   `UnknownAs.TRUE` to `x IS NOT FALSE`
   
   Note that both `UnknownAs.TRUE` and `UnknownAs.FALSE` only changes the 
meaning of `Unknown`
   
   * if we are already in `UnknownAs.FALSE` mode; `x IS TRUE` can be 
simiplified to `x` without any side effects
   * similarily  in `UnknownAs.TRUE` mode ; `x IS NOT FALSE` can be simplified 
to `x`
   * `x IS FALSE` could be rewritten to `(NOT x) IS TRUE` and from there the 1. 
rule applies
   * `x IS NOT TRUE` can be rewritten to `(NOT x) IS NOT FALSE` and from there 
the 2. rule applies
   

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to