mirror of
https://github.com/apache/datafusion-sqlparser-rs.git
synced 2025-10-11 06:22:04 +00:00
Table time travel clause support, add visit_table_factor
to Visitor (#951)
This commit is contained in:
parent
9500649c35
commit
1ea8858575
15 changed files with 225 additions and 12 deletions
|
@ -6210,6 +6210,9 @@ impl<'a> Parser<'a> {
|
|||
} else {
|
||||
let name = self.parse_object_name()?;
|
||||
|
||||
// Parse potential version qualifier
|
||||
let version = self.parse_table_version()?;
|
||||
|
||||
// Postgres, MSSQL: table-valued functions:
|
||||
let args = if self.consume_token(&Token::LParen) {
|
||||
Some(self.parse_optional_args()?)
|
||||
|
@ -6240,10 +6243,25 @@ impl<'a> Parser<'a> {
|
|||
alias,
|
||||
args,
|
||||
with_hints,
|
||||
version,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
/// Parse a given table version specifier.
|
||||
///
|
||||
/// For now it only supports timestamp versioning for BigQuery and MSSQL dialects.
|
||||
pub fn parse_table_version(&mut self) -> Result<Option<TableVersion>, ParserError> {
|
||||
if dialect_of!(self is BigQueryDialect | MsSqlDialect)
|
||||
&& self.parse_keywords(&[Keyword::FOR, Keyword::SYSTEM_TIME, Keyword::AS, Keyword::OF])
|
||||
{
|
||||
let expr = self.parse_expr()?;
|
||||
Ok(Some(TableVersion::ForSystemTimeAsOf(expr)))
|
||||
} else {
|
||||
Ok(None)
|
||||
}
|
||||
}
|
||||
|
||||
pub fn parse_derived_table_factor(
|
||||
&mut self,
|
||||
lateral: IsLateral,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue