LucaCappelletti94 commented on code in PR #2246:
URL: 
https://github.com/apache/datafusion-sqlparser-rs/pull/2246#discussion_r2878298432


##########
src/parser/mod.rs:
##########
@@ -18096,23 +18110,76 @@ impl<'a> Parser<'a> {
         Ok((
             OrderByExpr {
                 expr,
+                using_operator,
                 options,
                 with_fill,
             },
             operator_class,
         ))
     }
 
-    fn parse_order_by_options(&mut self) -> Result<OrderByOptions, 
ParserError> {
-        let asc = self.parse_asc_desc();
+    fn parse_order_by_using_operator(&mut self) -> Result<ObjectName, 
ParserError> {
+        if self.parse_keyword(Keyword::OPERATOR) {
+            self.expect_token(&Token::LParen)?;
+            let operator_name = self.parse_operator_name()?;
+            let Some(last_part) = operator_name.0.last() else {
+                return self.expected_ref("an operator name", 
self.peek_token_ref());
+            };
+            let operator = last_part.to_string();
+            if !Self::is_valid_order_by_using_operator_symbol(&operator) {
+                return self.expected_ref("an operator name", 
self.peek_token_ref());
+            }
+            self.expect_token(&Token::RParen)?;
+            return Ok(operator_name);
+        }
 
-        let nulls_first = if self.parse_keywords(&[Keyword::NULLS, 
Keyword::FIRST]) {
+        let token = self.next_token();
+        let operator = token.token.to_string();
+        if Self::is_valid_order_by_using_operator_symbol(&operator) {
+            Ok(ObjectName::from(vec![Ident::new(operator)]))
+        } else {
+            self.expected_ref("an ordering operator after USING", &token)
+        }
+    }
+
+    fn is_valid_order_by_using_operator_symbol(symbol: &str) -> bool {

Review Comment:
   Removed, `parse_order_by_using_operator` now uses 
`dialect.is_custom_operator_part(...)` directly. No separate symbol-check 
helper anymore. I wasn't aware there was a dialect helper method.



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