@@ -16172,6 +16172,15 @@ impl<'a> Parser<'a> {
1617216172 Ok(ExprWithAlias { expr, alias })
1617316173 }
1617416174
16175+ /// Parse an expression followed by an optional alias; Unlike
16176+ /// [Self::parse_expr_with_alias] the "AS" keyword between the expression
16177+ /// and the alias is optional.
16178+ fn parse_expr_with_alias_optional_as_keyword(&mut self) -> Result<ExprWithAlias, ParserError> {
16179+ let expr = self.parse_expr()?;
16180+ let alias = self.parse_identifier_optional_alias()?;
16181+ Ok(ExprWithAlias { expr, alias })
16182+ }
16183+
1617516184 /// Parse a PIVOT table factor (ClickHouse/Oracle style pivot), returning a TableFactor.
1617616185 pub fn parse_pivot_table_factor(
1617716186 &mut self,
@@ -16200,7 +16209,9 @@ impl<'a> Parser<'a> {
1620016209 } else if self.peek_sub_query() {
1620116210 PivotValueSource::Subquery(self.parse_query()?)
1620216211 } else {
16203- PivotValueSource::List(self.parse_comma_separated(Self::parse_expr_with_alias)?)
16212+ PivotValueSource::List(
16213+ self.parse_comma_separated(Self::parse_expr_with_alias_optional_as_keyword)?,
16214+ )
1620416215 };
1620516216 self.expect_token(&Token::RParen)?;
1620616217
@@ -16246,7 +16257,7 @@ impl<'a> Parser<'a> {
1624616257 let name = self.parse_identifier()?;
1624716258 self.expect_keyword_is(Keyword::IN)?;
1624816259 let columns = self.parse_parenthesized_column_list_inner(Mandatory, false, |p| {
16249- p.parse_expr_with_alias ()
16260+ p.parse_expr_with_alias_optional_as_keyword ()
1625016261 })?;
1625116262 self.expect_token(&Token::RParen)?;
1625216263 let alias = self.maybe_parse_table_alias()?;
0 commit comments