Vladimir Ozerov created CALCITE-4515:
----------------------------------------

             Summary: Do not generate the new join tree from commute/associate 
rules if it contains "always true" condition
                 Key: CALCITE-4515
                 URL: https://issues.apache.org/jira/browse/CALCITE-4515
             Project: Calcite
          Issue Type: Improvement
          Components: core
    Affects Versions: 1.27.0
            Reporter: Vladimir Ozerov
            Assignee: Vladimir Ozerov


{{JoinCommuteRule}} and {{JoinAssociateRule}} are the complete ruleset to 
generate all bushy trees (plus join-project transposes to counter new projects 
created during commute).

These rules do not check whether the new join trees contain an always {{TRUE}} 
condition which is a cross-product. Such join trees are not optimal in the 
majority of cases, and practical optimizers might want to suppress them.

In this ticket, I propose to add a configuration property to 
{{JoinCommuteRule}} and {{JoinAssociateRule}} to disable the creation of trees 
with always {{TRUE}} condition:
 # The property should be disabled by default because sometimes cross-products 
might be present in the query on purpose (e.g., see 
[https://dl.acm.org/doi/10.5555/645916.671976], page 315)
 # We consider the "always {{TRUE}}" condition only, even though they represent 
only part of cross-products. The reason is that it might be difficult and 
expensive to understand whether the condition is cross-join or not (e.g., for 
hypergraphs). On the other hand, the check for "always true" is cheap and 
robust. We assume that the user might need to do some pre-processing (e.g., 
filter push-down) to take advantage of the new property. 
# We do not extend the {{JoinPushThroughJoinRule}} for now, since the [commute 
+ associate] ruleset already explores all bushy trees and testing of the new 
property for {{JoinPushThroughJoinRule}} is difficult. We may extend this rule 
in a separate ticket if needed.
 



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

Reply via email to