mirror of
https://github.com/apache/datafusion-sqlparser-rs.git
synced 2025-09-04 05:00:34 +00:00
Support redshift's columns definition list for system information functions (#769)
* parsing of redshift's column definition list for pg_get_late_binding_view_cols pg_get_cols pg_get_grantee_by_iam_role pg_get_iam_role_by_user * Renamed ColsDefinition to TableAliasDefinition added generic dialect * Tests fixed * Visitor for IdentPair * Parsing redshift table alias based on indentifier and parentheses instead of function name * fix clippy --------- Co-authored-by: Maciej Skrzypkowski <maciej.skrzypkowski@satoricyber.com> Co-authored-by: Andrew Lamb <andrew@nerdnetworks.org>
This commit is contained in:
parent
a2fea10f89
commit
c35dcc93a7
14 changed files with 194 additions and 0 deletions
|
@ -5649,6 +5649,7 @@ impl<'a> Parser<'a> {
|
|||
} else {
|
||||
None
|
||||
};
|
||||
let columns_definition = self.parse_redshift_columns_definition_list()?;
|
||||
let alias = self.parse_optional_table_alias(keywords::RESERVED_FOR_TABLE_ALIAS)?;
|
||||
// MSSQL-specific table hints:
|
||||
let mut with_hints = vec![];
|
||||
|
@ -5665,11 +5666,56 @@ impl<'a> Parser<'a> {
|
|||
name,
|
||||
alias,
|
||||
args,
|
||||
columns_definition,
|
||||
with_hints,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
fn parse_redshift_columns_definition_list(
|
||||
&mut self,
|
||||
) -> Result<Option<TableAliasDefinition>, ParserError> {
|
||||
if !dialect_of!(self is RedshiftSqlDialect | GenericDialect) {
|
||||
return Ok(None);
|
||||
}
|
||||
|
||||
if let Some(col_definition_list_name) = self.parse_optional_columns_definition_list_alias()
|
||||
{
|
||||
if self.consume_token(&Token::LParen) {
|
||||
let names = self.parse_comma_separated(Parser::parse_ident_pair)?;
|
||||
self.expect_token(&Token::RParen)?;
|
||||
Ok(Some(TableAliasDefinition {
|
||||
name: col_definition_list_name,
|
||||
args: names,
|
||||
}))
|
||||
} else {
|
||||
self.prev_token();
|
||||
Ok(None)
|
||||
}
|
||||
} else {
|
||||
Ok(None)
|
||||
}
|
||||
}
|
||||
|
||||
fn parse_optional_columns_definition_list_alias(&mut self) -> Option<Ident> {
|
||||
match self.next_token().token {
|
||||
Token::Word(w) if !keywords::RESERVED_FOR_TABLE_ALIAS.contains(&w.keyword) => {
|
||||
Some(w.to_ident())
|
||||
}
|
||||
_ => {
|
||||
self.prev_token();
|
||||
None
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn parse_ident_pair(&mut self) -> Result<IdentPair, ParserError> {
|
||||
Ok(IdentPair(
|
||||
self.parse_identifier()?,
|
||||
self.parse_identifier()?,
|
||||
))
|
||||
}
|
||||
|
||||
pub fn parse_derived_table_factor(
|
||||
&mut self,
|
||||
lateral: IsLateral,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue