You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Snowflake MERGE statement does not require parentheses around the ON statement #1315
Describe the bug
The Snowflake MERGE statement does not require the ON statement to be wrapped in parantheses.
To Reproduce
Steps to reproduce the behavior:
Example SQL
MERGE INTO CONSULTANT T USING (
SELECT
*
from
CONSULTANT
) S ON S.ID = T.ID
WHEN MATCHED THEN
UPDATE
SET
T.RESOURCE = S.RESOURCE
WHEN NOT MATCHED THEN
INSERT
(ID, RESOURCE)
values
(S.ID, S.RESOURCE);
Parsing this SQL using JSqlParser with these statements
String text = """
MERGE INTO CONSULTANT T USING (
SELECT
*
from
CONSULTANT
) S ON S.ID = T.ID
WHEN MATCHED THEN
UPDATE
SET
T.RESOURCE = S.RESOURCE
WHEN NOT MATCHED THEN
INSERT
(ID, RESOURCE)
values
(S.ID, S.RESOURCE);
"""
Statement query = CCJSqlParserUtil.parse(text)
Exception
net.sf.jsqlparser.JSQLParserException: Encountered unexpected token: "S" <S_IDENTIFIER>
at line 7, column 8.
Was expecting:
"("
Expected behavior
When the parentheses are included around the ON, this works:
String text = """
MERGE INTO CONSULTANT T USING (
SELECT
*
from
CONSULTANT
) S ON (S.ID = T.ID)
WHEN MATCHED THEN
UPDATE
SET
T.RESOURCE = S.RESOURCE
WHEN NOT MATCHED THEN
INSERT
(ID, RESOURCE)
values
(S.ID, S.RESOURCE);
"""
Statement query = CCJSqlParserUtil.parse(text)
Most RDBMS require the brackets around the ON condition and JSQLParser does not support the Snowflake specific syntax yet. But you could send a PR implementing it.
Activity
manticore-projects commentedon Aug 26, 2021
Greetings.
Most RDBMS require the brackets around the
ONcondition and JSQLParser does not support the Snowflake specific syntax yet. But you could send a PR implementing it.stewartbryson commentedon Aug 27, 2021
Sure... I'll take a look. I'd take any advice or pointers on where to look.
manticore-projects commentedon Aug 27, 2021
Greetings.
toString()