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

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

VotersWatch issueWatchersLinkCloneUpdate Comment AuthorReplace String in CommentUpdate Comment VisibilityDelete Comments
    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Critical
    • Resolution: Fixed
    • 1.10.0
    • 1.12.0
    • jdbc-adapter
    • None
    • 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

          This comment will be Viewable by All Users Viewable by All Users
          Cancel

          People

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

            Dates

              Created:
              Updated:
              Resolved:

              Slack

                Issue deployment