You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@calcite.apache.org by "xiong duan (Jira)" <ji...@apache.org> on 2025/12/15 03:12:00 UTC

[jira] [Created] (CALCITE-7335) RelToSqlConverter generate sql containing Scala subqueries includes redundant parentheses

xiong duan created CALCITE-7335:
-----------------------------------

             Summary: RelToSqlConverter generate sql containing Scala subqueries includes redundant parentheses
                 Key: CALCITE-7335
                 URL: https://issues.apache.org/jira/browse/CALCITE-7335
             Project: Calcite
          Issue Type: Bug
            Reporter: xiong duan


The UT in RelToSqlConverterTest:
{code:java}
@Test void testScalarSubqueryInSelectList() {
  final String sql2 = "" +
      "select\n" +
      "        (SELECT\n" +
      "          COUNT(*)\n" +
      "        FROM\n" +
      "           \"employee\"" +
      "        WHERE\n" +
      "           v.\"product_id\" >= 2), 3\n" +
      "from \"product\" as v";
  final String expected = "SELECT (((SELECT COUNT(*)\nFROM \"foodmart\".\"employee\"\nWHERE \"product\".\"product_id\" >= 2))), 3\n" +
      "FROM \"foodmart\".\"product\"";
  sql(sql2).ok(expected);
} {code}
{code:java}
(((SELECT COUNT(*)\nFROM \"foodmart\".\"employee\"\nWHERE \"product\".\"product_id\" >= 2)))
{code}
should be:
{code:java}
(SELECT COUNT(*)\nFROM \"foodmart\".\"employee\"\nWHERE \"product\".\"product_id\" >= 2){code}
The result with redundant parentheses is correct but not sufficiently standardized.



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