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

Benchao Li commented on CALCITE-5568:
-------------------------------------

I guess the reason why {{Values}} stops the decorrelation is that {{Values}} 
does not have "IO", it's unnecessary to decorrelate it from {{Correlate}} to 
{{Join}}. 

But for this case, it should be decorrelated, because the {{Correlate}} is in 
the subtree of the plan, and has nothing to do with the {{Values}}.

> Decorrelate will fail. If the RelNode tree has LogicalValues
> ------------------------------------------------------------
>
>                 Key: CALCITE-5568
>                 URL: https://issues.apache.org/jira/browse/CALCITE-5568
>             Project: Calcite
>          Issue Type: Bug
>            Reporter: libopeng
>            Priority: Major
>
> Decorrelate will fail. If the RelNode tree has LogicalValues
> case:
> {code:java}
> SELECT
>    (
>    SELECT
>       ( SUM ( "tbl2"."count" ) ) AS "SUM"
>    FROM
>       (
>       SELECT
>          (
>          SELECT
>             ( COUNT ( "tbl2"."id" ) ) AS "COUNT"
>          FROM
>             "trip_order" AS "tbl2"
>          WHERE
>             "tbl1"."province" = "tbl2"."province"
>          ) AS "count",
>          ( "tbl1"."province" ) AS "province"
>       FROM
>          "trip_order" AS "tbl1"
>       ) AS "tbl2"
>    ) AS "sub_1"
>  {code}
> after decorrelate 
> (org.apache.calcite.sql2rel.RelDecorrelator#decorrelateQuery(org.apache.calcite.rel.RelNode,
>  org.apache.calcite.tools.RelBuilder))
> {code:java}
> LogicalProject(sub_1=[$1])
>   LogicalJoin(condition=[true], joinType=[left])
>     LogicalValues(tuples=[[{ 0 }]])                            <---- 
>     LogicalAggregate(group=[{}], agg#0=[SINGLE_VALUE($0)])
>       LogicalAggregate(group=[{}], SUM=[SUM($0)])
>         LogicalProject(count=[$10])
>           LogicalProject(id=[$0], gmt_create=[$1], service_begin=[$2], 
> driver_id=[$3], passenger_id=[$4], province=[$5], city=[$6], 
> service_minute=[$7], service_mileage=[$8], order_amount=[$9], $f0=[$10])
>             LogicalProject(id=[$0], gmt_create=[$1], service_begin=[$2], 
> driver_id=[$3], passenger_id=[$4], province=[$5], city=[$6], 
> service_minute=[$7], service_mileage=[$8], order_amount=[$9], $f0=[$10])
>               LogicalCorrelate(correlation=[$cor0], joinType=[left], 
> requiredColumns=[{5}])  <---- See here, the decorrelate didn't work
>                 LogicalTableScan(table=[[trip_order]])
>                 LogicalAggregate(group=[{}], agg#0=[SINGLE_VALUE($0)])
>                   LogicalAggregate(group=[{}], COUNT=[COUNT()])
>                     LogicalFilter(condition=[=($cor0.province, $5)])
>                       LogicalTableScan(table=[[trip_order]]){code}
> LogicalCorrelate will not be processed when the RelNode tree has 
> LogicalValues 
> [https://github.com/apache/calcite/blob/main/core/src/main/java/org/apache/calcite/sql2rel/RelDecorrelator.java#L491]
>  
> Is this as expected?
>  
>  
>  
>  



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to