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

Rui Wang commented on CALCITE-4033:
-----------------------------------

Calcite parser recognizes only UNNEST with extra parenthesis.  So it seems to 
be a problem when there is LATERAL.

> SqlNode.toSqlString generates wrong query for syntax "literal(select * from 
> unnest(...))"
> -----------------------------------------------------------------------------------------
>
>                 Key: CALCITE-4033
>                 URL: https://issues.apache.org/jira/browse/CALCITE-4033
>             Project: Calcite
>          Issue Type: Bug
>            Reporter: Rui Wang
>            Priority: Major
>
> Reported from: https://issues.apache.org/jira/browse/DRILL-7722
> If use this query 
> {code:sql}
> SELECT
>   item.name,
>   relations.*
> FROM dfs.tmp item
> JOIN LATERAL(
>   SELECT * FROM UNNEST(item.related) i(rels)
> ) relations
> ON TRUE
> {code}
> Then SqlNode.toSqlString() generates 
> {code:sql}
> SELECT `ITEM`.`NAME`, `RELATIONS`.*
>     FROM `DFS`.`TMP` AS `ITEM`
>     INNER JOIN LATERAL (SELECT *
>     FROM (UNNEST(`ITEM`.`RELATED`)) AS `I` (`RELS`)) AS `RELATIONS` ON TRUE");
> {code}
> Note that there are extra parentheses around the UNNEST, and make the 
> generated query unparsable.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to