zvonimir-dd opened a new pull request, #2627:
URL: https://github.com/apache/datafusion-sqlparser-rs/pull/2627
<!-- comma separated, or `none` -->
Dialects: PostgreSQL
Closes #2625.
In PostgreSQL a column-list `ON CONFLICT` target may end with `WHERE
index_predicate`, which lets a partial unique index be inferred as the arbiter:
```sql
INSERT INTO t (a, b) VALUES (1, 2) ON CONFLICT (a) WHERE b > 0 DO NOTHING
```
- Adds `OnConflict::conflict_target_predicate: Option<Expr>`, parsed after
the column list and before `DO`, and printed back after the target.
- Accepted only after a column list, as in PostgreSQL's grammar. `ON
CONSTRAINT … WHERE` and a `WHERE` with no target are still rejected.
- Separate from the action's `DO UPDATE SET … WHERE condition` (#733, #735).
A statement can carry both; the tests check that.
- The predicate is a regular `Expr` field, so visitors see the columns it
names.
Shape: I went with a new field on `OnConflict` because it is the smaller API
change. The other option from #2625 was a struct variant
`ConflictTarget::Columns { columns, predicate }`, which would also suit the `(
index_expression )` form requested in #1977. I'm happy to switch if you prefer
that.
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]