[jira] [Commented] (CALCITE-5544) SCALAR_QUERY is nested within SCALAR_QUERY, and the inner SCALAR_QUERY is an associative subquery that references a variable of the external query, sql to rel will ma

2023-02-26 Thread libopeng (Jira)


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

libopeng commented on CALCITE-5544:
---

[~libenchao] I see. I'll try to fix it

> SCALAR_QUERY is nested within SCALAR_QUERY, and the inner SCALAR_QUERY is an 
> associative subquery that references a variable of the external query, sql to 
> rel will make mistakes
> -
>
> Key: CALCITE-5544
> URL: https://issues.apache.org/jira/browse/CALCITE-5544
> Project: Calcite
>  Issue Type: Bug
>Reporter: libopeng
>Priority: Major
>
>  
> {code:java}
> SELECT
>     *,
>     (
>     SELECT SUM
>         ( (SELECT SUM ( order_amt ) FROM tb_order t2 WHERE t2.product_id = 
> t0.product_id ) )
>     FROM
>         tb_order t1 
>     WHERE
>         t1.product_id = t0.product_id 
>     ) 
> FROM
>     tb_order t0{code}
> to rel
> {code:java}
> LogicalProject(order_id=[$0], order_amt=[$1], order_date=[$2], desc=[$3], 
> buyer_id=[$4], seller_id=[$5], product_id=[$6], express_id=[$7], EXPR$8=[$9])
>   LogicalJoin(condition=[=($6, $8)], joinType=[left])
>     LogicalTableScan(table=[[tb_order]])
>     LogicalAggregate(group=[{0}], EXPR$0=[SUM($1)])
>       LogicalProject(product_id0=[$8], EXPR$0=[$9])
>         LogicalJoin(condition=[true], joinType=[left])
>           LogicalFilter(condition=[IS NOT NULL($6)])
>             LogicalTableScan(table=[[tb_order]])
>           LogicalAggregate(group=[{0}], EXPR$0=[SUM($1)])
>             LogicalProject(product_id=[$6], order_amt=[$1])
>               LogicalFilter(condition=[IS NOT NULL($6)])
>                 LogicalTableScan(table=[[tb_order]]) {code}
> line 6, "LogicalJoin condition=[true]" is going to create a Cartesian product
>  
>  



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


[jira] [Commented] (CALCITE-5544) SCALAR_QUERY is nested within SCALAR_QUERY, and the inner SCALAR_QUERY is an associative subquery that references a variable of the external query, sql to rel will ma

2023-02-26 Thread Benchao Li (Jira)


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

Benchao Li commented on CALCITE-5544:
-

[~leepb] Yes, there are two ways to handle sub-queries now, the old one is in 
{{SqlToRelConverter}} and the new one is in {{SubQueryRemoveRule}}, they both 
expand sub-queries to {{Join}} or {{Correlate}}. 

The new one deserves more priority for bug fixes, but it does not mean we don't 
want to fix bugs for old one. 

Are you going to fix this or CALCITE-5418? Or you just noticed and reported 
this bug, and would leave it for other contributors to get it fixed?

> SCALAR_QUERY is nested within SCALAR_QUERY, and the inner SCALAR_QUERY is an 
> associative subquery that references a variable of the external query, sql to 
> rel will make mistakes
> -
>
> Key: CALCITE-5544
> URL: https://issues.apache.org/jira/browse/CALCITE-5544
> Project: Calcite
>  Issue Type: Bug
>Reporter: libopeng
>Priority: Major
>
>  
> {code:java}
> SELECT
>     *,
>     (
>     SELECT SUM
>         ( (SELECT SUM ( order_amt ) FROM tb_order t2 WHERE t2.product_id = 
> t0.product_id ) )
>     FROM
>         tb_order t1 
>     WHERE
>         t1.product_id = t0.product_id 
>     ) 
> FROM
>     tb_order t0{code}
> to rel
> {code:java}
> LogicalProject(order_id=[$0], order_amt=[$1], order_date=[$2], desc=[$3], 
> buyer_id=[$4], seller_id=[$5], product_id=[$6], express_id=[$7], EXPR$8=[$9])
>   LogicalJoin(condition=[=($6, $8)], joinType=[left])
>     LogicalTableScan(table=[[tb_order]])
>     LogicalAggregate(group=[{0}], EXPR$0=[SUM($1)])
>       LogicalProject(product_id0=[$8], EXPR$0=[$9])
>         LogicalJoin(condition=[true], joinType=[left])
>           LogicalFilter(condition=[IS NOT NULL($6)])
>             LogicalTableScan(table=[[tb_order]])
>           LogicalAggregate(group=[{0}], EXPR$0=[SUM($1)])
>             LogicalProject(product_id=[$6], order_amt=[$1])
>               LogicalFilter(condition=[IS NOT NULL($6)])
>                 LogicalTableScan(table=[[tb_order]]) {code}
> line 6, "LogicalJoin condition=[true]" is going to create a Cartesian product
>  
>  



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


[jira] [Commented] (CALCITE-5544) SCALAR_QUERY is nested within SCALAR_QUERY, and the inner SCALAR_QUERY is an associative subquery that references a variable of the external query, sql to rel will ma

2023-02-26 Thread libopeng (Jira)


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

libopeng commented on CALCITE-5544:
---

[~libenchao] I probably see what you mean, the "expand" ability will all 
migrate to SubQueryRemoveRule, so just fix the SubQueryRemoveRule bug?

> SCALAR_QUERY is nested within SCALAR_QUERY, and the inner SCALAR_QUERY is an 
> associative subquery that references a variable of the external query, sql to 
> rel will make mistakes
> -
>
> Key: CALCITE-5544
> URL: https://issues.apache.org/jira/browse/CALCITE-5544
> Project: Calcite
>  Issue Type: Bug
>Reporter: libopeng
>Priority: Major
>
>  
> {code:java}
> SELECT
>     *,
>     (
>     SELECT SUM
>         ( (SELECT SUM ( order_amt ) FROM tb_order t2 WHERE t2.product_id = 
> t0.product_id ) )
>     FROM
>         tb_order t1 
>     WHERE
>         t1.product_id = t0.product_id 
>     ) 
> FROM
>     tb_order t0{code}
> to rel
> {code:java}
> LogicalProject(order_id=[$0], order_amt=[$1], order_date=[$2], desc=[$3], 
> buyer_id=[$4], seller_id=[$5], product_id=[$6], express_id=[$7], EXPR$8=[$9])
>   LogicalJoin(condition=[=($6, $8)], joinType=[left])
>     LogicalTableScan(table=[[tb_order]])
>     LogicalAggregate(group=[{0}], EXPR$0=[SUM($1)])
>       LogicalProject(product_id0=[$8], EXPR$0=[$9])
>         LogicalJoin(condition=[true], joinType=[left])
>           LogicalFilter(condition=[IS NOT NULL($6)])
>             LogicalTableScan(table=[[tb_order]])
>           LogicalAggregate(group=[{0}], EXPR$0=[SUM($1)])
>             LogicalProject(product_id=[$6], order_amt=[$1])
>               LogicalFilter(condition=[IS NOT NULL($6)])
>                 LogicalTableScan(table=[[tb_order]]) {code}
> line 6, "LogicalJoin condition=[true]" is going to create a Cartesian product
>  
>  



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


[jira] [Commented] (CALCITE-5544) SCALAR_QUERY is nested within SCALAR_QUERY, and the inner SCALAR_QUERY is an associative subquery that references a variable of the external query, sql to rel will ma

2023-02-26 Thread libopeng (Jira)


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

libopeng commented on CALCITE-5544:
---

I think these two cases are not the same, although they can be grouped into one 
kind of problem, but this kind of problem is a little broad, I doubt that these 
two can be solved together

> SCALAR_QUERY is nested within SCALAR_QUERY, and the inner SCALAR_QUERY is an 
> associative subquery that references a variable of the external query, sql to 
> rel will make mistakes
> -
>
> Key: CALCITE-5544
> URL: https://issues.apache.org/jira/browse/CALCITE-5544
> Project: Calcite
>  Issue Type: Bug
>Reporter: libopeng
>Priority: Major
>
>  
> {code:java}
> SELECT
>     *,
>     (
>     SELECT SUM
>         ( (SELECT SUM ( order_amt ) FROM tb_order t2 WHERE t2.product_id = 
> t0.product_id ) )
>     FROM
>         tb_order t1 
>     WHERE
>         t1.product_id = t0.product_id 
>     ) 
> FROM
>     tb_order t0{code}
> to rel
> {code:java}
> LogicalProject(order_id=[$0], order_amt=[$1], order_date=[$2], desc=[$3], 
> buyer_id=[$4], seller_id=[$5], product_id=[$6], express_id=[$7], EXPR$8=[$9])
>   LogicalJoin(condition=[=($6, $8)], joinType=[left])
>     LogicalTableScan(table=[[tb_order]])
>     LogicalAggregate(group=[{0}], EXPR$0=[SUM($1)])
>       LogicalProject(product_id0=[$8], EXPR$0=[$9])
>         LogicalJoin(condition=[true], joinType=[left])
>           LogicalFilter(condition=[IS NOT NULL($6)])
>             LogicalTableScan(table=[[tb_order]])
>           LogicalAggregate(group=[{0}], EXPR$0=[SUM($1)])
>             LogicalProject(product_id=[$6], order_amt=[$1])
>               LogicalFilter(condition=[IS NOT NULL($6)])
>                 LogicalTableScan(table=[[tb_order]]) {code}
> line 6, "LogicalJoin condition=[true]" is going to create a Cartesian product
>  
>  



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


[jira] [Commented] (CALCITE-5544) SCALAR_QUERY is nested within SCALAR_QUERY, and the inner SCALAR_QUERY is an associative subquery that references a variable of the external query, sql to rel will ma

2023-02-24 Thread Benchao Li (Jira)


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

Benchao Li commented on CALCITE-5544:
-

[~leepb] Is this duplicated with CALCITE-5418?

> SCALAR_QUERY is nested within SCALAR_QUERY, and the inner SCALAR_QUERY is an 
> associative subquery that references a variable of the external query, sql to 
> rel will make mistakes
> -
>
> Key: CALCITE-5544
> URL: https://issues.apache.org/jira/browse/CALCITE-5544
> Project: Calcite
>  Issue Type: Bug
>Reporter: libopeng
>Priority: Major
>
>  
> {code:java}
> SELECT
>     *,
>     (
>     SELECT SUM
>         ( (SELECT SUM ( order_amt ) FROM tb_order t2 WHERE t2.product_id = 
> t0.product_id ) )
>     FROM
>         tb_order t1 
>     WHERE
>         t1.product_id = t0.product_id 
>     ) 
> FROM
>     tb_order t0{code}
> to rel
> {code:java}
> LogicalProject(order_id=[$0], order_amt=[$1], order_date=[$2], desc=[$3], 
> buyer_id=[$4], seller_id=[$5], product_id=[$6], express_id=[$7], EXPR$8=[$9])
>   LogicalJoin(condition=[=($6, $8)], joinType=[left])
>     LogicalTableScan(table=[[tb_order]])
>     LogicalAggregate(group=[{0}], EXPR$0=[SUM($1)])
>       LogicalProject(product_id0=[$8], EXPR$0=[$9])
>         LogicalJoin(condition=[true], joinType=[left])
>           LogicalFilter(condition=[IS NOT NULL($6)])
>             LogicalTableScan(table=[[tb_order]])
>           LogicalAggregate(group=[{0}], EXPR$0=[SUM($1)])
>             LogicalProject(product_id=[$6], order_amt=[$1])
>               LogicalFilter(condition=[IS NOT NULL($6)])
>                 LogicalTableScan(table=[[tb_order]]) {code}
> line 6, "LogicalJoin condition=[true]" is going to create a Cartesian product
>  
>  



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