Uploaded image for project: 'Calcite'
  1. Calcite
  2. CALCITE-7335

RelToSqlConverter generate sql containing Scala subqueries includes redundant parentheses

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • None
    • 1.42.0
    • None

    Description

      The UT in RelToSqlConverterTest:

      @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);
      } 
      (((SELECT COUNT(*)\nFROM \"foodmart\".\"employee\"\nWHERE \"product\".\"product_id\" >= 2)))
      

      should be:

      (SELECT COUNT(*)\nFROM \"foodmart\".\"employee\"\nWHERE \"product\".\"product_id\" >= 2)

      The result with redundant parentheses is correct but not sufficiently standardized.

      Attachments

        Issue Links

          Activity

            People

              jensen Zhen Chen
              nobigo xiong duan
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: