You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@calcite.apache.org by "Rui Wang (Jira)" <ji...@apache.org> on 2020/02/05 21:19:00 UTC

[jira] [Commented] (CALCITE-3774) Add option to RelBuilder to prevent it from merging projects

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

Rui Wang commented on CALCITE-3774:
-----------------------------------

I am not getting why fields are counted as a part of complexity. Seems to me that only calls matter. But even if only considering calls,  the proposal of this Jira will still hold (example 1, input 15 calls, output  21 calls; example 2, input 16 calls, output 14 calls).

 

 

Could you please elaborate a bit more about the value of RelBuilder.Config.mergeBloat()? What does the integer mean?

> Add option to RelBuilder to prevent it from merging projects
> ------------------------------------------------------------
>
>                 Key: CALCITE-3774
>                 URL: https://issues.apache.org/jira/browse/CALCITE-3774
>             Project: Calcite
>          Issue Type: Bug
>            Reporter: Julian Hyde
>            Priority: Major
>
> Add option to {{RelBuilder}} to prevent it from merging projects. Currently if you call {{RelBuilder.project}} and the input is a {{Project}} it will merge the expressions. This is usually a good idea, but sometimes it creates very complex expressions.
> There is an existing method {{RelBuilder.shouldMergeProject()}} but by default it returns true, and in order to change it you have to sub-class {{RelBuilder}}, which is not easy to do.
> I propose to add a property {{RelBuilder.Config.mergeBloat}}, default 0, which would prevent creating a project that has more complexity than the two projects that went into it.
> Example 1:
> * Input 1: {{Project(a+b+c+d AS w, b+c+d+e AS x, c+d+e+f AS y, d+e+f+g AS z)}} followed by
> * Input 2: {{Project(w*x AS p, x*y AS q, y*z AS r)}} creates
> * Output: {{Project((a+b+c+d) * (b+c+d+e) AS p, (b+c+d+e) * (c+d+e+f) AS q, (c+d+e+f) * (d+e+f+g) AS r)}}.
> The expression "a+b+c+d" has complexity 7 (4 fields and 3 calls). The inputs have complexity 28 (4 expressions, each of complexity 7) and 9 (3 expressions, each with complexity 3). The output has complexity 45 (3 expressions, each with complexity 15 (8 fields and 7 calls)). 45 is greater than 37 (28 + 9), so this merge would not be allowed.
> Example 2:
> * Input 1: {{Project(a+b+c+d AS w, b+c+d+e AS x, c+d+e+f AS y, d+e+f+g AS z)}} (complexity 28)
> * Input 2: {{Project(w*x AS p, x*y AS q)}} (complexity 6) creates
> * Output: {{Project((a+b+c+d) * (b+c+d+e) AS p, (b+c+d+e) * (c+d+e+f) AS q)}} (complexity 30).
> Output complexity 30 is less than input complexity 34 (28 + 6), and therefore the merge is allowed.



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