[ 
https://issues.apache.org/jira/browse/CALCITE-6983?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Roman Churganov updated CALCITE-6983:
-------------------------------------
    Description: 
An issue in `SortJoinTransposeRule` same as in `SortUnionTransposeRule ` been 
fixed in CALCITE-6647 , now can be reproduced with a query like 
{code:sql}
           SELECT t5.fn1, t8.m_fn FROM (
                                                       SELECT id AS fn1 FROM 
foo WHERE sd = ?
                                        UNION   SELECT id FROM bar  WHERE d = ?
                                        UNION   SELECT id  FROM baz  WHERE id  
=  ?  ) AS t5
                                LEFT JOIN (SELECT id AS m_fn FROM (
                                                        SELECT id, aoguid FROM 
foo2
                                                            WHERE EXISTS 
(SELECT 1 FROM (
                                                                        SELECT 
buildnum AS fn2 FROM v1_dhouse) AS t7 WHERE aoguid = t7.fn2 ) ) AS t ) AS t8 ON 
t5.fn1 = t8.m_fn 
                                FETCH NEXT ? ROWS ONLY
{code}
which hangs on building  a plan, with a debug log can see growing plans, 
eventually it fails with StackOverflow..., 


  was:
An issue in `SortJoinTransposeRule` same as in `SortUnionTransposeRule ` has 
fixed in CALCITE-6647 , can be reproduced with a query like 
{code:sql}
           SELECT x.c11 FROM ( 
                     SELECT tt1.c11 FROM (
                                   SELECT c11 FROM sch1.foo as cp1 LIMIT ?
                     ) AS tt1 
                     UNION ALL
                     SELECT tt2.c11 FROM (
                                   SELECT c11 FROM sch1.foo as cp2 LIMIT ?
                      ) AS tt2
            ) AS x    LIMIT ?  
{code}
which hangs on building  a plan, with a debug log can see growing plans, 
eventually it fails with StackOverflow..., 



> SortJoinTransposeRule should not push SORT past a UNION when SORT's fetch is 
> DynamicParam
> -----------------------------------------------------------------------------------------
>
>                 Key: CALCITE-6983
>                 URL: https://issues.apache.org/jira/browse/CALCITE-6983
>             Project: Calcite
>          Issue Type: Bug
>          Components: core
>    Affects Versions: 1.39.0
>            Reporter: Roman Churganov
>            Priority: Blocker
>
> An issue in `SortJoinTransposeRule` same as in `SortUnionTransposeRule ` been 
> fixed in CALCITE-6647 , now can be reproduced with a query like 
> {code:sql}
>            SELECT t5.fn1, t8.m_fn FROM (
>                                                        SELECT id AS fn1 FROM 
> foo WHERE sd = ?
>                                         UNION   SELECT id FROM bar  WHERE d = 
> ?
>                                         UNION   SELECT id  FROM baz  WHERE id 
>  =  ?  ) AS t5
>                                 LEFT JOIN (SELECT id AS m_fn FROM (
>                                                         SELECT id, aoguid 
> FROM foo2
>                                                             WHERE EXISTS 
> (SELECT 1 FROM (
>                                                                         
> SELECT buildnum AS fn2 FROM v1_dhouse) AS t7 WHERE aoguid = t7.fn2 ) ) AS t ) 
> AS t8 ON t5.fn1 = t8.m_fn 
>                                 FETCH NEXT ? ROWS ONLY
> {code}
> which hangs on building  a plan, with a debug log can see growing plans, 
> eventually it fails with StackOverflow..., 



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

Reply via email to