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


##########
src/parser/mod.rs:
##########
@@ -10224,17 +10224,32 @@ impl<'a> Parser<'a> {
     /// Parse the body of a `CREATE FUNCTION` specified as a string.
     /// e.g. `CREATE FUNCTION ... AS $$ body $$`.
     fn parse_create_function_body_string(&mut self) -> Result<Expr, 
ParserError> {
-        let peek_token = self.peek_token();
-        let span = peek_token.span;
-        match peek_token.token {
-            Token::DollarQuotedString(s) if dialect_of!(self is 
PostgreSqlDialect | GenericDialect) =>
-            {
-                self.next_token();
-                Ok(Expr::Value(Value::DollarQuotedString(s).with_span(span)))
+        // Helper closure to parse a single string value (quoted or 
dollar-quoted)
+        let parse_string_expr = |parser: &mut Parser| -> Result<Expr, 
ParserError> {
+            let peek_token = parser.peek_token();
+            let span = peek_token.span;
+            match peek_token.token {
+                Token::DollarQuotedString(s) if dialect_of!(parser is 
PostgreSqlDialect | GenericDialect) =>
+                {
+                    parser.next_token();
+                    
Ok(Expr::Value(Value::DollarQuotedString(s).with_span(span)))
+                }
+                _ => Ok(Expr::Value(
+                    
Value::SingleQuotedString(parser.parse_literal_string()?).with_span(span),
+                )),
             }
-            _ => Ok(Expr::Value(
-                
Value::SingleQuotedString(self.parse_literal_string()?).with_span(span),
-            )),
+        };
+
+        let first_expr = parse_string_expr(self)?;
+
+        // Check if there's a comma, indicating multiple strings (e.g., AS 
'obj_file', 'link_symbol')
+        // This is used for C language functions: AS 'MODULE_PATHNAME', 
'link_symbol'
+        if self.consume_token(&Token::Comma) {
+            let mut exprs = vec![first_expr];
+            exprs.extend(self.parse_comma_separated(parse_string_expr)?);
+            Ok(Expr::Tuple(exprs))

Review Comment:
   Ah simply the following happens:
   
   ```rust
   if let Some(CreateFunctionBody::AsBeforeOptions(function_body)) = 
&self.function_body {
           write!(f, " AS ")?;
           // Special handling for tuple expressions to format without 
parentheses
           // PostgreSQL C functions use: AS 'obj_file', 'link_symbol'
           // rather than: AS ('obj_file', 'link_symbol')
           if let Expr::Tuple(exprs) = function_body {
               write!(f, "{}", display_comma_separated(exprs))?;
           } else {
               write!(f, "{function_body}")?;
           }
       }
   ```



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