aharpervc commented on code in PR #1839:
URL: 
https://github.com/apache/datafusion-sqlparser-rs/pull/1839#discussion_r2081901411


##########
src/parser/mod.rs:
##########
@@ -5203,19 +5203,73 @@ impl<'a> Parser<'a> {
         let (name, args) = self.parse_create_function_name_and_params()?;
 
         self.expect_keyword(Keyword::RETURNS)?;
-        let return_type = Some(self.parse_data_type()?);
 
-        self.expect_keyword_is(Keyword::AS)?;
+        let return_table = self.maybe_parse(|p| {
+            let return_table_name = p.parse_identifier()?;
+            let table_column_defs = if p.peek_keyword(Keyword::TABLE) {
+                match p.parse_data_type()? {
+                    DataType::Table(t) => t,
+                    _ => parser_err!(
+                        "Expected table data type after TABLE keyword",
+                        p.peek_token().span.start
+                    )?,
+                }
+            } else {
+                parser_err!(
+                    "Expected TABLE keyword after return type",
+                    p.peek_token().span.start
+                )?
+            };
+            Ok(DataType::NamedTable(
+                
ObjectName(vec![ObjectNamePart::Identifier(return_table_name)]),
+                table_column_defs.clone(),
+            ))
+        })?;
+
+        let return_type = if return_table.is_some() {
+            return_table
+        } else {
+            Some(self.parse_data_type()?)
+        };

Review Comment:
   Hm, I don't see how that would be done. The use of maybe_parse is to get the 
table name & other parts, but if we don't have that then we should rewind and 
just parse a typical data type. Do you mean like having another maybe_parse 
inside the first maybe_parse? 



-- 
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: github-unsubscr...@datafusion.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscr...@datafusion.apache.org
For additional commands, e-mail: github-h...@datafusion.apache.org

Reply via email to