[
https://issues.apache.org/jira/browse/CALCITE-7024?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Mihai Budiu reassigned CALCITE-7024:
------------------------------------
Assignee: Mihai Budiu
> 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
> Assignee: 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)