guan404ming commented on code in PR #2213:
URL:
https://github.com/apache/datafusion-sqlparser-rs/pull/2213#discussion_r2822498279
##########
src/parser/mod.rs:
##########
@@ -9375,6 +9391,22 @@ impl<'a> Parser<'a> {
// after `PRIMARY` always stay `KEY`
self.expect_keyword_is(Keyword::KEY)?;
+ // PostgreSQL: PRIMARY KEY USING INDEX index_name
+ // https://www.postgresql.org/docs/current/sql-altertable.html
+ if self.parse_keywords(&[Keyword::USING, Keyword::INDEX]) {
+ let index_name = self.parse_identifier()?;
+ let characteristics =
self.parse_constraint_characteristics()?;
+ return Ok(Some(
+ ConstraintUsingIndex {
+ name,
+ is_primary_key: true,
+ index_name,
+ characteristics,
+ }
+ .into(),
+ ));
+ }
Review Comment:
Yes, thanks for the nice suggestions. I just updated with
1. Split enum variant: TableConstraint::ConstraintUsingIndex into
PrimaryKeyUsingIndex and UniqueUsingIndex, removing the is_primary_key bool
from the struct.
2. Extracted helper: Created parse_constraint_using_index() to deduplicate
the parsing logic used by both UNIQUE USING INDEX and PRIMARY KEY USING INDEX.
--
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]