According to Sql Merge definition
<https://en.wikipedia.org/wiki/Merge_(SQL)> (at least on wikipedia), the
insert part is a classical insert statement :

WHEN NOT MATCHED THEN    INSERT (column1 [, column2 ...]) VALUES
(value1 [, value2 ...]);

The SqlMerge class, on toSqlString; add extra parenthesis before VALUES

INSERT (column1 [, column2 ...]) *(*VALUES (value1 [, value2 ...])*)*

And it's confirm by unit test
<https://github.com/apache/calcite/blob/main/testkit/src/main/java/org/apache/calcite/sql/parser/SqlParserTest.java#L4651-L4652>

Which expect

+ "WHEN NOT MATCHED THEN INSERT (`NAME`, `DEPT`, `SALARY`) "

+ "(VALUES (ROW(`T`.`NAME`, 10, (`T`.`SALARY` * 0.15))))";

When i try to run thus kind of generated MERGE statement with H2SqlDialect,
it does not work (*JdbcSQLSyntaxErrorException: Syntax error in SQL
statement*) until i remove this extra parenthesis manually (on step by step
debug).
As i'm a newbie at calcite, i don't know if it's me who using calcite
wrongly or if it's a bug ?

Regards,
Christophe.

Reply via email to