-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Snowflake MERGE statement does not require parentheses around the ON statement #1315
Copy link
Copy link
Closed
Description
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)
System
- Database you are using: Snowflake
- Java Version: 11
- JSqlParser version: 4.1
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels