-
Notifications
You must be signed in to change notification settings - Fork 669
Add PostgreSQL Operator DDL Support #2096
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Add PostgreSQL Operator DDL Support #2096
Conversation
iffyio
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Left some comments, a bit worried that its a lot of code and seems to be lacking test coverage, I tried to point out a few of them but would be good that we do a full pass to ensure code coverage in the PR
|
|
||
| /// Helper function to parse an operator name (which can contain special characters) | ||
| /// Operator names can be schema-qualified (e.g., schema.operator) | ||
| fn parse_operator_name(&mut self) -> Result<ObjectName, ParserError> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
does this differ from parse_object_name?
| let func_name = self.parse_object_name(false)?; | ||
| join = Some(func_name); | ||
| } | ||
| _ => unreachable!("unexpected keyword in CREATE OPERATOR"), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we return an error here instead of crashing in the case of a bug?
| let family = if self.parse_keyword(Keyword::FAMILY) { | ||
| Some(self.parse_object_name(false)?) | ||
| } else { | ||
| None |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we add a test case for a statement without a family?
| self.expect_token(&Token::RParen)?; | ||
| types | ||
| } else { | ||
| vec![] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we add test coverage for this block?
| } else if self.parse_keyword(Keyword::STORAGE) { | ||
| let storage_type = self.parse_data_type()?; | ||
| items.push(OperatorClassItem::Storage { storage_type }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do we have tests for this part of the syntax?
| // Parse the operator name (can be schema-qualified) | ||
| // Operators can contain special characters like +, -, *, /, <, >, =, ~, !, @, #, %, ^, &, |, `, ? | ||
| // See https://www.postgresql.org/docs/current/sql-createoperator.html | ||
| let name = self.parse_operator_name()?; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we add test cases that use qualified operator names where applicable?
|
|
||
| // Check if this is a flag (HASHES or MERGES) - no '=' expected | ||
| match keyword { | ||
| Keyword::HASHES => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think since we're only expecting one of each clause, we might need to add guards to the match clauses - e.g. Keyword::Hashes if !hashes => {...} Keyword::LEFTARG if left_arg.is_none() => {...}
it would be good to add negative tests that exercise such behavior.
|
|
||
| // Check if this is a flag (HASHES or MERGES) - no '=' expected | ||
| match keyword { | ||
| Keyword::HASHES => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we add test coverage for hashes, merges etc? we can do a pass through the clauses to ensure that they're properly covered
Co-authored-by: Ifeanyi Ubah <ify1992@yahoo.com>
Co-authored-by: Ifeanyi Ubah <ify1992@yahoo.com>
Adds support for
CREATE OPERATOR,CREATE OPERATOR FAMILY, andCREATE OPERATOR CLASSstatements.Examples