You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@calcite.apache.org by "suibianwanwan (Jira)" <ji...@apache.org> on 2025/05/17 06:43:00 UTC
[jira] [Commented] (CALCITE-7024) Decorrelator does not always produce a query with the same type signature
[ https://issues.apache.org/jira/browse/CALCITE-7024?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17952323#comment-17952323 ]
suibianwanwan commented on CALCITE-7024:
----------------------------------------
I speculate the reason is: In `decorrelateRel`, when we rewrite the query as a Join, we add a `corVar` column for subsequent Joins. I noticed that in `decorrelateRel(Correlate)`, we didn't add a Project to eliminate this `corVar` (since this column might still be needed for eliminating other Correlate).
> Decorrelator does not always produce a query with the same type signature
> -------------------------------------------------------------------------
>
> Key: CALCITE-7024
> URL: https://issues.apache.org/jira/browse/CALCITE-7024
> Project: Calcite
> Issue Type: Bug
> Components: core
> Affects Versions: 1.39.0
> Reporter: Mihai Budiu
> Priority: Minor
>
> While trying to implement [CALCITE-7023] I stumbled on some examples for which the query produced by the decorrelator has a different type signature from the input query. I think this should be impossible.
> Original plan:
> {code}
> LogicalCorrelate(correlation=[$cor0], joinType=[left], requiredColumns=[{0}]), id = 161
> LogicalTableScan(table=[[schema, s]]), id = 95
> LogicalSort(fetch=[1]), id = 159
> LogicalAggregate(group=[{}], EXPR$0=[SUM($0)]), id = 157
> LogicalProject(x=[$0]), id = 155
> LogicalFilter(condition=[=($cor0.y, $1)]), id = 153
> LogicalTableScan(table=[[schema, t]]), id = 97
> {code}
> Error produced when attempting to replace this plan after decorrelating it:
> {code}
> set type is RecordType(INTEGER y, DECIMAL(28, 2) EXPR$0) NOT NULL
> expression type is RecordType(INTEGER y, DECIMAL(28, 2) EXPR$0, INTEGER z) NOT NULL
> set is rel#161:LogicalCorrelate.(left=HepRelVertex#151,right=HepRelVertex#160,correlation=$cor0,joinType=left,requiredColumns={0})
> expression is LogicalJoin(condition=[=($0, $2)], joinType=[left])
> LogicalTableScan(table=[[schema, s]])
> LogicalProject(EXPR$0=[FIRST_VALUE($1) OVER (PARTITION BY $0)], z=[$0])
> LogicalAggregate(group=[{0}], EXPR$0=[SUM($1)])
> LogicalProject(z=[$1], x=[$0])
> LogicalFilter(condition=[IS NOT NULL($1)])
> LogicalTableScan(table=[[schema, t]])
> Type mismatch: the field sizes are not equal.
> rowtype of original rel: RecordType(INTEGER y, DECIMAL(28, 2) EXPR$0) NOT NULL
> rowtype of new rel: RecordType(INTEGER y, DECIMAL(28, 2) EXPR$0, INTEGER z) NOT NULL
> {code}
--
This message was sent by Atlassian Jira
(v8.20.10#820010)