You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@calcite.apache.org by "Dmitry Sysolyatin (Jira)" <ji...@apache.org> on 2022/10/07 13:53:00 UTC

[jira] [Commented] (CALCITE-5299) JDBC adapter sometimes adds unnecessary parentheses around SELECT in WITH body

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

Dmitry Sysolyatin commented on CALCITE-5299:
--------------------------------------------

[~4wei] [~libenchao] 
It would be good to mark this task as bug. The following query does not work in Microsoft SQL Server with parentheses, but it works without it:
{code}
WITH "t1" AS (SELECT *
FROM "qa"."test_all_types") SELECT *
FROM "t1" AS var
ORDER BY var."id_type";
{code}

returns correct result.

But 
{code}
WITH "t1" AS (SELECT *
FROM "qa"."test_all_types") (SELECT *
FROM "t1" AS var
ORDER BY var."id_type");
{code}
returns
{code}
Query 1 ERROR: Msg: 156, Line 4, State: 1, Level: 15
Incorrect syntax near the keyword 'ORDER'.
{code}

> JDBC adapter sometimes adds unnecessary parentheses around SELECT in WITH body
> ------------------------------------------------------------------------------
>
>                 Key: CALCITE-5299
>                 URL: https://issues.apache.org/jira/browse/CALCITE-5299
>             Project: Calcite
>          Issue Type: Improvement
>            Reporter: Mou Wu
>            Assignee: Mou Wu
>            Priority: Minor
>
> Note: This issue is related to https://issues.apache.org/jira/browse/CALCITE-5265
> You should view comments in CALCITE-5265 before you view this issue.
> Add a case in SqlParserTest:
>  
> {code:java}
> // code placeholder
> @Test void testWithSelect() {
>   final String sql = "with emp2 as (select * from emp)\n"
>       + "select * from emp2\n";
>   final String expected = "WITH `EMP2` AS (SELECT *\n" +
>       "FROM `EMP`) SELECT *\n" +
>       "FROM `EMP2`";
>   sql(sql).ok(expected);
> } {code}
> will fail, because actual sql is with parentheses.
>  



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