iffyio commented on code in PR #1687:
URL:
https://github.com/apache/datafusion-sqlparser-rs/pull/1687#discussion_r1934243820
##########
src/parser/mod.rs:
##########
@@ -8866,6 +8873,24 @@ impl<'a> Parser<'a> {
Ok((data, trailing_bracket))
}
+ fn parse_returns_table_column(&mut self) -> Result<ColumnDef, ParserError>
{
+ let name = self.parse_identifier()?;
+ let data_type = self.parse_data_type()?;
+ Ok(ColumnDef {
+ name,
+ data_type,
+ collation: None,
+ options: Vec::new(), // No constraints expected here
+ })
+ }
+
+ fn parse_parenthesized_columns(&mut self) -> Result<Vec<ColumnDef>,
ParserError> {
Review Comment:
```suggestion
fn parse_returns_table_columns(&mut self) -> Result<Vec<ColumnDef>,
ParserError> {
```
##########
src/parser/mod.rs:
##########
@@ -4535,7 +4535,14 @@ impl<'a> Parser<'a> {
self.expect_token(&Token::RParen)?;
let return_type = if self.parse_keyword(Keyword::RETURNS) {
- Some(self.parse_data_type()?)
+ if dialect_of!(self is PostgreSqlDialect | GenericDialect)
+ && self.parse_keyword(Keyword::TABLE)
+ {
+ let columns = self.parse_parenthesized_columns()?;
+ Some(DataType::Table(columns))
+ } else {
+ Some(self.parse_data_type()?)
Review Comment:
I'm thinking the behavior here could be a bit misleading, given the variant
`DataType::Table`, the expectation is that `self.parse_data_type()` can parse
that variant. Would that be reasonable to do here instead (i.e. the table type
logic is moved into `parse_data_type()` and this part becomes unchanged [likely
no need to guard by dialect either since the syntax doesn't conflict] I imagine
as a result)?
--
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]