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

SqlMerge generate extra bracket on toSqlString

    XMLWordPrintableJSON

Details

    Description

      Following this mails exchange, i build this JIRA about SQL Merge.
      Using SQLMerge on this unit test SqlMergeTest.java i tried to generate SQL Merge SQL code.
      this generate

      MERGE INTO "OUT_TABLE" AS "Target"
      USING "IN_TABLE" AS "Source"
      ON "TARGET"."ID" = "SOURCE"."IDENT"
      WHEN MATCHED THEN UPDATE SET "TARGET"."FIELD1" = "SOURCE"."F1", "TARGET"."FIELD2" = "SOURCE"."F2"
      WHEN NOT MATCHED THEN INSERT ("TARGET"."ID", "TARGET"."FIELD1", "TARGET"."FIELD2") (VALUES ("SOURCE"."IDENT", "SOURCE"."F1", "SOURCE"."F2"))
      

      that doesn't work because of the bracket before VALUES on last line.

      just removing brackets

      WHEN NOT MATCHED THEN INSERT ("TARGET"."ID", "TARGET"."FIELD1", "TARGET"."FIELD2") VALUES ("SOURCE"."IDENT", "SOURCE"."F1", "SOURCE"."F2")
      

      make the query work.

      Attachments

        1. SqlMergeTest.java
          3 kB
          Christophe Le Saec

        Issue Links

          Activity

            People

              Unassigned Unassigned
              clesaec Christophe Le Saec
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0h
                  0h
                  Logged:
                  Time Spent - 20m
                  20m