Christophe Le Saec created CALCITE-5326:
-------------------------------------------

             Summary: SqlMerge generate extra bracket on toSqlString
                 Key: CALCITE-5326
                 URL: https://issues.apache.org/jira/browse/CALCITE-5326
             Project: Calcite
          Issue Type: Bug
          Components: core
            Reporter: Christophe Le Saec
         Attachments: SqlMergeTest.java

Following this [mails 
exchange|https://lists.apache.org/thread/pgycm37ld6v92llv1t6bdmk80wylcspj], i 
build this JIRA about SQL Merge.
Using SQLMerge on this unit test [^SqlMergeTest.java] i tried to generate [SQL 
Merge SQL code|https://en.wikipedia.org/wiki/Merge_(SQL)].
this generate
{code:sql}
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"))
{code}
that doesn't work because of the bracket before VALUES on last line.

just removing brackets
{code:sql}
WHEN NOT MATCHED THEN INSERT ("TARGET"."ID", "TARGET"."FIELD1", 
"TARGET"."FIELD2") VALUES ("SOURCE"."IDENT", "SOURCE"."F1", "SOURCE"."F2")
{code}
make the query work.



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

Reply via email to