[ 
https://issues.apache.org/jira/browse/CALCITE-739?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18116776#comment-18116776
 ] 

Yu Xu commented on CALCITE-739:
-------------------------------

Fixed in 
[https://github.com/apache/calcite/commit/51e6cb170bbcf7c6d2dd3a33999ba19d0749acfe]

Thank you reported the Jira [~jcamacho] 

Thank you for the review [~mbudiu] 

> Extend RexUtil.pullFactors to recognize additional common factors
> -----------------------------------------------------------------
>
>                 Key: CALCITE-739
>                 URL: https://issues.apache.org/jira/browse/CALCITE-739
>             Project: Calcite
>          Issue Type: Bug
>            Reporter: Jesús Camacho Rodríguez
>            Assignee: Yu Xu
>            Priority: Major
>              Labels: pull-request-available
>
> RexUtil.pullFactors canonizes at the term level (i.e. "a or b or a" becomes 
> "a or b" but does not attempt to recognize terms that are equivalent). 
> Further, it does not exploit the symmetry of '=' (i.e. a = b iff b = a).
> - A first extension would be to normalize comparisons between field 
> references and literals so that the lower field reference is always on the 
> left. So, "$6 = $3" becomes "$3 = $6"; "$6 > $3" becomes "$3< $6". And 
> "literal <= $5" becomes "$5 >= literal". This would not damage performance, 
> and would improve a few plans.
> - Another possible extension. Given the predicate "(a or b) and ((x and a) or 
> (y and b))", the first factor can be removed so the expression consists only 
> of "(x and a) or (y and b)".
> One possible way to recognize such cases is to transform the second factor to 
> CNF i.e. "(x or y) and (x or b) and (a or y) and (a or b)", and as it 
> contains "(a or b)", we would know that we can discard it. Then we could just 
> use the original expression i.e. "(x and a) or (y and b)" in the predicate, 
> once we have done the check.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to