You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@datafusion.apache.org by "lovasoa (via GitHub)" <gi...@apache.org> on 2025/08/21 23:01:04 UTC
[I] `MERGE` statements inside CTEs [datafusion-sqlparser-rs]
lovasoa opened a new issue, #2010:
URL: https://github.com/apache/datafusion-sqlparser-rs/issues/2010
The following query works in PostgreSQL but returns a parse error in sqlparser:
```sql
WITH merged_row AS (
MERGE INTO users AS cible
USING (
SELECT
'john.doe' AS username,
'password' AS password,
'xxxxxxxxxx' AS uuid,
TRUE as is_active
) AS source
ON cible.uuid = source.uuid
WHEN MATCHED THEN
UPDATE SET
username = source.username,
password = source.password,
uuid = source.uuid,
is_active = source.is_active
WHEN NOT MATCHED THEN
INSERT (username, password, uuid, is_active)
VALUES (source.username, source.password, source.uuid, source.is_active)
RETURNING *
)
SELECT
'debug' AS component,
COUNT(*) AS count
FROM merged_row;
```
The postgres documentation says:
> Each auxiliary statement in a WITH clause can be a SELECT, INSERT, UPDATE, DELETE, **or MERGE**;
>
> -- https://www.postgresql.org/docs/current/queries-with.html
Initially reported in https://github.com/sqlpage/SQLPage/issues/995
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org
Re: [I] `MERGE` statements inside CTEs [datafusion-sqlparser-rs]
Posted by "lovasoa (via GitHub)" <gi...@apache.org>.
lovasoa commented on issue #2010:
URL: https://github.com/apache/datafusion-sqlparser-rs/issues/2010#issuecomment-3213421086
Here is a more minimal reproduction:
```sql
WITH x AS (
MERGE INTO t USING (VALUES (1)) ON true
WHEN MATCHED THEN DELETE
RETURNING *
) SELECT * FROM x
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org
Re: [I] `MERGE` statements inside CTEs [datafusion-sqlparser-rs]
Posted by "iffyio (via GitHub)" <gi...@apache.org>.
iffyio closed issue #2010: `MERGE` statements inside CTEs
URL: https://github.com/apache/datafusion-sqlparser-rs/issues/2010
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org