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


##########
src/parser/mod.rs:
##########
@@ -10521,19 +10522,33 @@ 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)))
+    fn parse_create_function_body_string(&mut self) -> 
Result<CreateFunctionBody, ParserError> {
+        // Helper closure to parse a single string value (quoted or 
dollar-quoted)

Review Comment:
   ```suggestion
   ```



##########
src/ast/mod.rs:
##########
@@ -9099,8 +9099,19 @@ pub enum CreateFunctionBody {
     /// OPTIONS(description="desc");
     /// ```
     ///
+    /// For PostgreSQL C functions with object file and link symbol:
+    /// ```sql
+    /// CREATE FUNCTION cas_in(input cstring) RETURNS cas
+    /// AS 'MODULE_PATHNAME', 'cas_in_wrapper'
+    /// ```
+    ///
     /// [BigQuery]: 
https://cloud.google.com/bigquery/docs/reference/standard-sql/data-definition-language#syntax_11
-    AsBeforeOptions(Expr),
+    AsBeforeOptions {
+        /// The primary expression (object file path for C functions, or 
regular expression)
+        body: Expr,
+        /// Optional link symbol for C language functions
+        link_symbol: Option<Expr>,

Review Comment:
   ```suggestion
      /// [BigQuery]: 
https://cloud.google.com/bigquery/docs/reference/standard-sql/data-definition-language#syntax_11
       /// [PostgreSQL]: 
https://www.postgresql.org/docs/current/sql-createfunction.html
       AsBeforeOptions {
           /// The primary expression.
           body: Expr,
           /// Link symbol if the primary expression contains the name of 
shared library file.
           ///
           /// Example:
           /// ```sql
           /// CREATE FUNCTION cas_in(input cstring) RETURNS cas
           /// AS 'MODULE_PATHNAME', 'cas_in_wrapper'
           /// ```
           /// [PostgreSQL]: 
https://www.postgresql.org/docs/current/sql-createfunction.html
           link_symbol: Option<Expr>,
   ```



##########
src/parser/mod.rs:
##########
@@ -10521,19 +10522,33 @@ 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)))
+    fn parse_create_function_body_string(&mut self) -> 
Result<CreateFunctionBody, ParserError> {
+        // 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),
-            )),
-        }
+        };
+
+        // 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'

Review Comment:
   ```suggestion
   ```
   I think we can remove this comment since its mostly describing what the code 
is doing, (the link_symbol feature is already described in the enum variant



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