You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@datafusion.apache.org by "amaksimo (via GitHub)" <gi...@apache.org> on 2026/06/05 23:20:00 UTC
[PR] PostgreSQL: accept CREATE SEQUENCE options in any clause order [datafusion-sqlparser-rs]
amaksimo opened a new pull request, #2367:
URL: https://github.com/apache/datafusion-sqlparser-rs/pull/2367
## Summary
PostgreSQL allows the `CREATE SEQUENCE` option clauses (`INCREMENT`, `MINVALUE`, `MAXVALUE`, `START`, `CACHE`, `CYCLE`) to appear in any order, per the [docs][docs]. The previous parser was positional and rejected pg_dump output, which emits `START` before `INCREMENT`:
```sql
CREATE SEQUENCE public.t_id_seq
AS integer
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
```
[docs]: https://www.postgresql.org/docs/current/sql-createsequence.html
## Changes
- Wrap the option-matching arms of `parse_create_sequence_options` in a loop that breaks only when no clause matches the next token. The AST vector preserves whatever order the source used.
- Add a doc-comment note on `Statement::CreateSequence` pointing to the PG docs.
No performance impact; the per-clause work is unchanged.
## Tests
In `tests/sqlparser_common.rs` (the syntax is standard PostgreSQL also accepted by `GenericDialect`):
- A pg_dump-shaped input parses to its canonical form.
- Two reorderings of the same clauses both round-trip with order preserved (verifies the AST vector reflects source order).
- A duplicate-clause case is pinned as characterization (current permissive behavior, not a contract).
- The original `INCREMENT`-first ordering still round-trips, guarding regression.
`cargo test --all-features`, `cargo fmt --all`, and `cargo clippy --all-targets --all-features -- -D warnings` all pass locally.
## History
Re-pitch of #2043 (closed by stale-bot after the author was unavailable for two weeks). Addresses the review feedback from that PR:
- pure `else if … else break` loop without a bool sentinel
- `verified_stmt` round-trip tests in common
- duplicate-clause test case
--
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: [PR] PostgreSQL: accept CREATE SEQUENCE options in any clause order [datafusion-sqlparser-rs]
Posted by "LucaCappelletti94 (via GitHub)" <gi...@apache.org>.
LucaCappelletti94 commented on PR #2367:
URL: https://github.com/apache/datafusion-sqlparser-rs/pull/2367#issuecomment-6382180315
Closing as completed by https://github.com/apache/datafusion-sqlparser-rs/pull/2414
--
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: [PR] PostgreSQL: accept CREATE SEQUENCE options in any clause order [datafusion-sqlparser-rs]
Posted by "LucaCappelletti94 (via GitHub)" <gi...@apache.org>.
LucaCappelletti94 commented on PR #2367:
URL: https://github.com/apache/datafusion-sqlparser-rs/pull/2367#issuecomment-5134902532
I have handled this problem in the more general case in #2414
--
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: [PR] PostgreSQL: accept CREATE SEQUENCE options in any clause order [datafusion-sqlparser-rs]
Posted by "iffyio (via GitHub)" <gi...@apache.org>.
iffyio commented on code in PR #2367:
URL: https://github.com/apache/datafusion-sqlparser-rs/pull/2367#discussion_r3681574756
##########
tests/sqlparser_common.rs:
##########
@@ -3883,6 +3883,96 @@ fn parse_negative_value() {
);
}
+#[test]
+fn parse_create_sequence_clause_order_independent() {
Review Comment:
I think the tests can be simplified by
- using the canonical input and calling verified_stmt instead (no point in testing that `integer` input comes out as `INTEGER`)
- Dropping the AST assertions, the changes don't introduce any AST changes so I don't think the AST check provides much coverage to warrant it
- Merge the tests scenarios into the same function, better yet we can inline them into an existing `CREATE SEQUENCE` if present
--
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: [PR] PostgreSQL: accept CREATE SEQUENCE options in any clause order [datafusion-sqlparser-rs]
Posted by "LucaCappelletti94 (via GitHub)" <gi...@apache.org>.
LucaCappelletti94 closed pull request #2367: PostgreSQL: accept CREATE SEQUENCE options in any clause order
URL: https://github.com/apache/datafusion-sqlparser-rs/pull/2367
--
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