mirror of
https://github.com/apache/datafusion-sqlparser-rs.git
synced 2025-10-19 10:17:12 +00:00
snowflake: PIVOT on derived table factors (#1027)
This commit is contained in:
parent
5a3f19310e
commit
dc2ceedeea
2 changed files with 20 additions and 2 deletions
|
@ -6737,9 +6737,20 @@ impl<'a> Parser<'a> {
|
|||
// `parse_derived_table_factor` below will return success after parsing the
|
||||
// subquery, followed by the closing ')', and the alias of the derived table.
|
||||
// In the example above this is case (3).
|
||||
return_ok_if_some!(
|
||||
if let Some(mut table) =
|
||||
self.maybe_parse(|parser| parser.parse_derived_table_factor(NotLateral))
|
||||
);
|
||||
{
|
||||
while let Some(kw) = self.parse_one_of_keywords(&[Keyword::PIVOT, Keyword::UNPIVOT])
|
||||
{
|
||||
table = match kw {
|
||||
Keyword::PIVOT => self.parse_pivot_table_factor(table)?,
|
||||
Keyword::UNPIVOT => self.parse_unpivot_table_factor(table)?,
|
||||
_ => unreachable!(),
|
||||
}
|
||||
}
|
||||
return Ok(table);
|
||||
}
|
||||
|
||||
// A parsing error from `parse_derived_table_factor` indicates that the '(' we've
|
||||
// recently consumed does not start a derived table (cases 1, 2, or 4).
|
||||
// `maybe_parse` will ignore such an error and rewind to be after the opening '('.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue