Skip to content

feat: support "replace using" for insert DML#7950

Open
nlpersimon wants to merge 2 commits into
tobymao:mainfrom
nlpersimon:feat/replace-using
Open

feat: support "replace using" for insert DML#7950
nlpersimon wants to merge 2 commits into
tobymao:mainfrom
nlpersimon:feat/replace-using

Conversation

@nlpersimon

@nlpersimon nlpersimon commented Jul 25, 2026

Copy link
Copy Markdown

To fix #7949

@geooo109 geooo109 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should always add support for:

REPLACE ON boolean_expression

"REPLACE WHERE c1 > 0 REPLACE USING (c1, c2)",
"REPLACE USING (c1, c2) REPLACE WHERE c1 > 0",
):
with self.subTest(replace=replace), self.assertRaises(ParseError):

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need for ParserError check, let's only focus on validate_identity and preserve the roundtrip.

Comment thread sqlglot/parser.py
Comment on lines +3531 to +3534
if not replace_using:
self.raise_error("Expected at least one column in REPLACE USING", self._prev)
else:
self.raise_error("Expected WHERE or USING after REPLACE")

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is no need to raise here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support REPLACE USING for INSERT

2 participants