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

Mihai Budiu commented on CALCITE-7340:
--------------------------------------

I have a working PR which actually implements and enforces these invariants in 
the entire codebase.

The PR depends on CALCITE-7961 and CALCITE-7962 which aren't merged yet. I will 
submit it once these two are merged too.

With these invariants essentially each plan contains ONE definition of each 
correlation Id. This should enable us in subsequent PRs to actually simplify 
other analyses: everything that pertains to subquery substitution and 
decorrelation should become significantly simpler.

I have structured the PR as 4 commits:
 * a tool which validates the correlation ID invariants for a plan (plans are 
read-only)
 * a tool which "fixes" incorrect plans which have duplicate IDs and converts 
them to plans without duplicate IDs
 * improvements to SubQueryRemoveRule and SqlToRelConverter that generate only 
"nice" plans
 * enforce these invariants in all test fixtures 

I could also submit each of these as a separate PR if people think it's more 
appropriate.

> The rules governing the use of CorrelationId values in plans are not fully 
> specified
> ------------------------------------------------------------------------------------
>
>                 Key: CALCITE-7340
>                 URL: https://issues.apache.org/jira/browse/CALCITE-7340
>             Project: Calcite
>          Issue Type: Bug
>          Components: core
>    Affects Versions: 1.41.0
>            Reporter: Mihai Budiu
>            Assignee: Mihai Budiu
>            Priority: Minor
>
> This issue is really about the Calcite internal representation of Rel nodes.
> There have been several recent discussions about manipulating plans that 
> contain CorrelationId values, and the conclusion seems to be that the rules 
> governing the use of such variables is not clear.
> Ideally these rules should be spelled out in a specification, and there 
> should be a tool to enforce them by validating plans. The JavaDoc for this 
> tool may be the right place to write the specification. I don't expect that 
> the specification will be long or complicated.
> RelBuilder may not be the right place to enforce such rules, because it 
> usually does not have visibility over the entire plan, and some of these 
> rules have to apply globally over entire plans. 
> See CALCITE-5784, CALCITE-7045 and the discussion in github over CALCITE-7336 
> for examples.
>  



--
This message was sent by Atlassian Jira
(v10.3.26#10030026)

Reply via email to