mirror of
https://github.com/apache/datafusion-sqlparser-rs.git
synced 2025-08-22 06:54:07 +00:00
Support TABLE functions in FROM (#253)
Support `TABLE(...)` syntax in `FROM`, for example: select * from TABLE(SOME_FUNCTION(some_arg)) The ANSI spec allows routine invocations (and some other kinds of expressions we don't currently support) inside TABLE: https://jakewheat.github.io/sql-overview/sql-2016-foundation-grammar.html#PTF-derived-table https://jakewheat.github.io/sql-overview/sql-2016-foundation-grammar.html#table-function-derived-table
This commit is contained in:
parent
a246d5da9a
commit
61431b087d
3 changed files with 59 additions and 9 deletions
|
@ -2066,10 +2066,15 @@ impl Parser {
|
|||
if !self.consume_token(&Token::LParen) {
|
||||
self.expected("subquery after LATERAL", self.peek_token())?;
|
||||
}
|
||||
return self.parse_derived_table_factor(Lateral);
|
||||
}
|
||||
|
||||
if self.consume_token(&Token::LParen) {
|
||||
self.parse_derived_table_factor(Lateral)
|
||||
} else if self.parse_keyword(Keyword::TABLE) {
|
||||
// parse table function (SELECT * FROM TABLE (<expr>) [ AS <alias> ])
|
||||
self.expect_token(&Token::LParen)?;
|
||||
let expr = self.parse_expr()?;
|
||||
self.expect_token(&Token::RParen)?;
|
||||
let alias = self.parse_optional_table_alias(keywords::RESERVED_FOR_TABLE_ALIAS)?;
|
||||
Ok(TableFactor::TableFunction { expr, alias })
|
||||
} else if self.consume_token(&Token::LParen) {
|
||||
// A left paren introduces either a derived table (i.e., a subquery)
|
||||
// or a nested join. It's nearly impossible to determine ahead of
|
||||
// time which it is... so we just try to parse both.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue