[
https://issues.apache.org/jira/browse/CALCITE-5042?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17506759#comment-17506759
]
Roman Churganov edited comment on CALCITE-5042 at 3/15/22, 11:06 AM:
---------------------------------------------------------------------
So it won't solve the same problem with outer joins, then it doesn't worth an
effort, I think outer joins same popular to us. Would be better to have an
option to prepare subquery with a sub-query in join clause instead of grouping
parantheses, for example instead of
{code:sql}
SELECT t1.ID FROM (SELECT ID FROM BAZ) AS t
INNER JOIN (
(SELECT ID FROM FOO WHERE ID = '0') AS
t1
LEFT JOIN (SELECT ID FROM BAR) AS
t2
ON t1.ID = t2.ID
) ON t.ID = t2.ID
{code}
we would have
{code:sql}
SELECT t3.ID1 FROM (SELECT ID FROM BAZ) AS t
INNER JOIN (
SELECT t1.ID AS ID1, t2.ID AS ID2 FROM
(SELECT ID FROM FOO WHERE ID = '0') AS
t1
LEFT JOIN (SELECT ID FROM BAR) AS
t2
ON t1.ID = t2.ID
) t3 ON t.ID = t3.ID2
{code}
which is parsible by Calcite
was (Author: rrrrrr111):
So it won't solve the same problem with outer joins, then it doesn't worth an
effort, I think outer joins same popular to us
> Incorrect syntax in sub-query
> -----------------------------
>
> Key: CALCITE-5042
> URL: https://issues.apache.org/jira/browse/CALCITE-5042
> Project: Calcite
> Issue Type: Bug
> Components: core
> Affects Versions: 1.29.0
> Reporter: Roman Churganov
> Priority: Blocker
>
> Execute query like:
> {code:sql}
> SELECT f.id FROM sch1.foo as f
> JOIN sch1.foo br ON br.id = f.id
> JOIN sch1.baz bz ON bz.id = br.id
> WHERE f.id = '0'
> {code}
> {{Calcite prepares SQL using JDBC adapter like: }}
> {code:sql}
> SELECT "t1"."ID" FROM ( SELECT "ID" FROM "BAZ" ) AS "t"
> INNER JOIN (
> ( SELECT "ID" FROM "FOO" WHERE "ID" = '0') AS "t1"
> INNER JOIN (SELECT "ID" FROM "FOO") AS "t2"
> ON "t1"."ID" = "t2"."ID"
> ) ON "t"."ID" = "t2"."ID"
> {code}
> though most of the databases can execute it, but Caclite itself cannot parse
> and gives error like:
> {noformat}
> Caused by: org.apache.calcite.sql.parser.impl.ParseException: Encountered
> "AS" at line 3, column 88.
> Was expecting one of:
> "EXCEPT" ...
> "FETCH" ...
> "INTERSECT" ...
> "LIMIT" ...
> "OFFSET" ...
> "ORDER" ...
> "MINUS" ...
> "UNION" ...
> ")" ...
> "." ...
> "NOT" ...
> "IN" ...
> {noformat}
> {{see example [https://www.db-fiddle.com/f/oCr3VKkT2QmKgWro54Wzfc/4] }}
>
--
This message was sent by Atlassian Jira
(v8.20.1#820001)