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

JDBC adapter generates wrong SQL if UNION has more than two inputs

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Critical
    • Resolution: Fixed
    • Affects Version/s: 1.10.0
    • Fix Version/s: 1.12.0
    • Component/s: jdbc-adapter
    • Labels:
      None
    • Environment:

      NA

      Description

      JDBC adapter generates wrong SQL if set operation (UNION, INTERSECT or MINUS) has more than two inputs. In union example, after UnionMergeRule, the union input is convert to three input, and rel-to-sql convert result is wrong.

      input sql

       SELECT *
      FROM (SELECT \"product_id\"
      FROM \"foodmart\".\"product\"
      UNION ALL
      SELECT \"product_id\"
      FROM \"foodmart\".\"sales_fact_1997\")
      UNION ALL
      SELECT \"product_class_id\" AS \"PRODUCT_ID\"
      FROM \"foodmart\".\"product_class\"
       

      output sql

      SELECT \"product_id\"
      FROM \"foodmart\".\"product\"
      UNION ALL
      SELECT \"product_id\"
      FROM \"foodmart\".\"sales_fact_1997\"
       

      the last union query is lost.

        Attachments

          Activity

            People

            • Assignee:
              julianhyde Julian Hyde
              Reporter:
              ransom Zhiqiang He
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: