Table time travel clause support, add visit_table_factor to Visitor (#951)

This commit is contained in:
Marko Grujic 2023-08-22 12:06:32 +02:00 committed by GitHub
parent 9500649c35
commit 1ea8858575
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
15 changed files with 225 additions and 12 deletions

View file

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