iffyio commented on code in PR #2102:
URL: 
https://github.com/apache/datafusion-sqlparser-rs/pull/2102#discussion_r2552356007


##########
src/parser/mod.rs:
##########
@@ -7525,6 +7527,51 @@ impl<'a> Parser<'a> {
         }))
     }
 
+    /// Parse a PostgreSQL-specific [Statement::DropOperator] statement.

Review Comment:
   ```suggestion
       /// Parse a[Statement::DropOperator] statement.
   ```



##########
src/ast/ddl.rs:
##########
@@ -4188,3 +4188,62 @@ impl fmt::Display for OperatorPurpose {
         }
     }
 }
+
+/// DROP OPERATOR statement
+/// See <https://www.postgresql.org/docs/current/sql-dropoperator.html>
+#[derive(Debug, Clone, PartialEq, PartialOrd, Eq, Ord, Hash)]
+#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
+#[cfg_attr(feature = "visitor", derive(Visit, VisitMut))]
+pub struct DropOperator {
+    /// IF EXISTS clause
+    pub if_exists: bool,
+    /// One or more operators to drop with their signatures
+    pub operators: Vec<OperatorSignature>,
+    /// CASCADE or RESTRICT
+    pub drop_behavior: Option<DropBehavior>,
+}
+
+/// Operator signature for DROP OPERATOR
+#[derive(Debug, Clone, PartialEq, PartialOrd, Eq, Ord, Hash)]
+#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
+#[cfg_attr(feature = "visitor", derive(Visit, VisitMut))]
+pub struct OperatorSignature {

Review Comment:
   ```suggestion
   pub struct DropOperatorSignature {
   ```



##########
src/ast/ddl.rs:
##########
@@ -4188,3 +4188,62 @@ impl fmt::Display for OperatorPurpose {
         }
     }
 }
+
+/// DROP OPERATOR statement
+/// See <https://www.postgresql.org/docs/current/sql-dropoperator.html>
+#[derive(Debug, Clone, PartialEq, PartialOrd, Eq, Ord, Hash)]
+#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
+#[cfg_attr(feature = "visitor", derive(Visit, VisitMut))]
+pub struct DropOperator {
+    /// IF EXISTS clause
+    pub if_exists: bool,
+    /// One or more operators to drop with their signatures
+    pub operators: Vec<OperatorSignature>,
+    /// CASCADE or RESTRICT

Review Comment:
   ```suggestion
       /// `CASCADE or RESTRICT`
   ```



##########
src/ast/ddl.rs:
##########
@@ -4188,3 +4188,62 @@ impl fmt::Display for OperatorPurpose {
         }
     }
 }
+
+/// DROP OPERATOR statement
+/// See <https://www.postgresql.org/docs/current/sql-dropoperator.html>
+#[derive(Debug, Clone, PartialEq, PartialOrd, Eq, Ord, Hash)]
+#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
+#[cfg_attr(feature = "visitor", derive(Visit, VisitMut))]
+pub struct DropOperator {
+    /// IF EXISTS clause
+    pub if_exists: bool,
+    /// One or more operators to drop with their signatures
+    pub operators: Vec<OperatorSignature>,
+    /// CASCADE or RESTRICT
+    pub drop_behavior: Option<DropBehavior>,
+}
+
+/// Operator signature for DROP OPERATOR
+#[derive(Debug, Clone, PartialEq, PartialOrd, Eq, Ord, Hash)]
+#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
+#[cfg_attr(feature = "visitor", derive(Visit, VisitMut))]
+pub struct OperatorSignature {
+    /// Operator name (can be schema-qualified)

Review Comment:
   ```suggestion
       /// Operator name
   ```



##########
src/parser/mod.rs:
##########
@@ -7525,6 +7527,51 @@ impl<'a> Parser<'a> {
         }))
     }
 
+    /// Parse a PostgreSQL-specific [Statement::DropOperator] statement.
+    ///
+    /// ```sql
+    /// DROP OPERATOR [ IF EXISTS ] name ( { left_type | NONE } , right_type ) 
[, ...] [ CASCADE | RESTRICT ]
+    /// ```
+    ///
+    /// [PostgreSQL 
Documentation](https://www.postgresql.org/docs/current/sql-dropoperator.html)
+    pub fn parse_drop_operator(&mut self) -> Result<Statement, ParserError> {
+        let if_exists = self.parse_keywords(&[Keyword::IF, Keyword::EXISTS]);
+        let operators = self.parse_comma_separated(|p| 
p.parse_operator_signature())?;
+        let drop_behavior = self.parse_optional_drop_behavior();
+        Ok(Statement::DropOperator(DropOperator {
+            if_exists,
+            operators,
+            drop_behavior,
+        }))
+    }
+
+    /// Parse an operator signature for DROP OPERATOR
+    /// Format: name ( { left_type | NONE } , right_type )

Review Comment:
   ```suggestion
       /// Format: `name ( { left_type | NONE } , right_type )`
   ```



##########
src/ast/ddl.rs:
##########
@@ -4188,3 +4188,62 @@ impl fmt::Display for OperatorPurpose {
         }
     }
 }
+
+/// DROP OPERATOR statement
+/// See <https://www.postgresql.org/docs/current/sql-dropoperator.html>
+#[derive(Debug, Clone, PartialEq, PartialOrd, Eq, Ord, Hash)]
+#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
+#[cfg_attr(feature = "visitor", derive(Visit, VisitMut))]
+pub struct DropOperator {
+    /// IF EXISTS clause

Review Comment:
   ```suggestion
       /// `IF EXISTS` clause
   ```



##########
src/ast/ddl.rs:
##########
@@ -4188,3 +4188,62 @@ impl fmt::Display for OperatorPurpose {
         }
     }
 }
+
+/// DROP OPERATOR statement

Review Comment:
   ```suggestion
   /// `DROP OPERATOR` statement
   ```



##########
src/parser/mod.rs:
##########
@@ -7525,6 +7527,51 @@ impl<'a> Parser<'a> {
         }))
     }
 
+    /// Parse a PostgreSQL-specific [Statement::DropOperator] statement.
+    ///
+    /// ```sql
+    /// DROP OPERATOR [ IF EXISTS ] name ( { left_type | NONE } , right_type ) 
[, ...] [ CASCADE | RESTRICT ]
+    /// ```
+    ///
+    /// [PostgreSQL 
Documentation](https://www.postgresql.org/docs/current/sql-dropoperator.html)
+    pub fn parse_drop_operator(&mut self) -> Result<Statement, ParserError> {
+        let if_exists = self.parse_keywords(&[Keyword::IF, Keyword::EXISTS]);
+        let operators = self.parse_comma_separated(|p| 
p.parse_operator_signature())?;
+        let drop_behavior = self.parse_optional_drop_behavior();
+        Ok(Statement::DropOperator(DropOperator {
+            if_exists,
+            operators,
+            drop_behavior,
+        }))
+    }
+
+    /// Parse an operator signature for DROP OPERATOR
+    /// Format: name ( { left_type | NONE } , right_type )
+    fn parse_operator_signature(&mut self) -> Result<OperatorSignature, 
ParserError> {

Review Comment:
   ```suggestion
       fn parse_drop_operator_signature(&mut self) -> Result<OperatorSignature, 
ParserError> {
   ```



##########
src/parser/mod.rs:
##########
@@ -7525,6 +7527,51 @@ impl<'a> Parser<'a> {
         }))
     }
 
+    /// Parse a PostgreSQL-specific [Statement::DropOperator] statement.
+    ///
+    /// ```sql
+    /// DROP OPERATOR [ IF EXISTS ] name ( { left_type | NONE } , right_type ) 
[, ...] [ CASCADE | RESTRICT ]
+    /// ```
+    ///
+    /// [PostgreSQL 
Documentation](https://www.postgresql.org/docs/current/sql-dropoperator.html)
+    pub fn parse_drop_operator(&mut self) -> Result<Statement, ParserError> {
+        let if_exists = self.parse_keywords(&[Keyword::IF, Keyword::EXISTS]);
+        let operators = self.parse_comma_separated(|p| 
p.parse_operator_signature())?;
+        let drop_behavior = self.parse_optional_drop_behavior();
+        Ok(Statement::DropOperator(DropOperator {
+            if_exists,
+            operators,
+            drop_behavior,
+        }))
+    }
+
+    /// Parse an operator signature for DROP OPERATOR

Review Comment:
   ```suggestion
       /// Parse an operator signature for a [Statement::DropOperator]
   ```



##########
src/ast/ddl.rs:
##########
@@ -4188,3 +4188,62 @@ impl fmt::Display for OperatorPurpose {
         }
     }
 }
+
+/// DROP OPERATOR statement
+/// See <https://www.postgresql.org/docs/current/sql-dropoperator.html>
+#[derive(Debug, Clone, PartialEq, PartialOrd, Eq, Ord, Hash)]
+#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
+#[cfg_attr(feature = "visitor", derive(Visit, VisitMut))]
+pub struct DropOperator {
+    /// IF EXISTS clause
+    pub if_exists: bool,
+    /// One or more operators to drop with their signatures
+    pub operators: Vec<OperatorSignature>,
+    /// CASCADE or RESTRICT
+    pub drop_behavior: Option<DropBehavior>,
+}
+
+/// Operator signature for DROP OPERATOR
+#[derive(Debug, Clone, PartialEq, PartialOrd, Eq, Ord, Hash)]
+#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
+#[cfg_attr(feature = "visitor", derive(Visit, VisitMut))]
+pub struct OperatorSignature {
+    /// Operator name (can be schema-qualified)
+    pub name: ObjectName,
+    /// Left operand type (None for prefix operators)
+    pub left_type: Option<DataType>,
+    /// Right operand type (always required)
+    pub right_type: DataType,

Review Comment:
   ```suggestion
       /// Left operand type
       pub left_type: Option<DataType>,
       /// Right operand type
       pub right_type: DataType,
   ```
   



##########
src/ast/ddl.rs:
##########
@@ -4188,3 +4188,62 @@ impl fmt::Display for OperatorPurpose {
         }
     }
 }
+
+/// DROP OPERATOR statement
+/// See <https://www.postgresql.org/docs/current/sql-dropoperator.html>
+#[derive(Debug, Clone, PartialEq, PartialOrd, Eq, Ord, Hash)]
+#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
+#[cfg_attr(feature = "visitor", derive(Visit, VisitMut))]
+pub struct DropOperator {
+    /// IF EXISTS clause
+    pub if_exists: bool,
+    /// One or more operators to drop with their signatures
+    pub operators: Vec<OperatorSignature>,
+    /// CASCADE or RESTRICT
+    pub drop_behavior: Option<DropBehavior>,
+}
+
+/// Operator signature for DROP OPERATOR

Review Comment:
   ```suggestion
   /// Operator signature for a `DROP OPERATOR` statement
   ```



##########
src/parser/mod.rs:
##########
@@ -7525,6 +7527,51 @@ impl<'a> Parser<'a> {
         }))
     }
 
+    /// Parse a PostgreSQL-specific [Statement::DropOperator] statement.
+    ///
+    /// ```sql
+    /// DROP OPERATOR [ IF EXISTS ] name ( { left_type | NONE } , right_type ) 
[, ...] [ CASCADE | RESTRICT ]
+    /// ```
+    ///
+    /// [PostgreSQL 
Documentation](https://www.postgresql.org/docs/current/sql-dropoperator.html)

Review Comment:
   ```suggestion
   ```
   Thinking since we've already repeated this doc on the statement type, 
linking to the statement type should suffice



-- 
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]

Reply via email to