@@ -9346,18 +9346,45 @@ impl<'a> Parser<'a> {
9346
9346
})
9347
9347
}
9348
9348
9349
- /// Parse a parenthesized comma-separated list of unqualified, possibly quoted identifiers
9349
+ /// Parses a parenthesized comma-separated list of unqualified, possibly quoted identifiers.
9350
+ /// For example: `(col1, "col 2", ...)`
9350
9351
pub fn parse_parenthesized_column_list(
9351
9352
&mut self,
9352
9353
optional: IsOptional,
9353
9354
allow_empty: bool,
9354
9355
) -> Result<Vec<Ident>, ParserError> {
9356
+ self.parse_parenthesized_column_list_inner(optional, allow_empty, |p| p.parse_identifier())
9357
+ }
9358
+
9359
+ /// Parses a parenthesized comma-separated list of qualified, possibly quoted identifiers.
9360
+ /// For example: `(db1.sc1.tbl1.col1, db1.sc1.tbl1."col 2", ...)`
9361
+ pub fn parse_parenthesized_qualified_column_list(
9362
+ &mut self,
9363
+ optional: IsOptional,
9364
+ allow_empty: bool,
9365
+ ) -> Result<Vec<ObjectName>, ParserError> {
9366
+ self.parse_parenthesized_column_list_inner(optional, allow_empty, |p| {
9367
+ p.parse_object_name(true)
9368
+ })
9369
+ }
9370
+
9371
+ /// Parses a parenthesized comma-separated list of columns using
9372
+ /// the provided function to parse each element.
9373
+ fn parse_parenthesized_column_list_inner<F, T>(
9374
+ &mut self,
9375
+ optional: IsOptional,
9376
+ allow_empty: bool,
9377
+ mut f: F,
9378
+ ) -> Result<Vec<T>, ParserError>
9379
+ where
9380
+ F: FnMut(&mut Parser) -> Result<T, ParserError>,
9381
+ {
9355
9382
if self.consume_token(&Token::LParen) {
9356
9383
if allow_empty && self.peek_token().token == Token::RParen {
9357
9384
self.next_token();
9358
9385
Ok(vec![])
9359
9386
} else {
9360
- let cols = self.parse_comma_separated(|p| p.parse_identifier( ))?;
9387
+ let cols = self.parse_comma_separated(|p| f(p ))?;
9361
9388
self.expect_token(&Token::RParen)?;
9362
9389
Ok(cols)
9363
9390
}
@@ -9368,7 +9395,7 @@ impl<'a> Parser<'a> {
9368
9395
}
9369
9396
}
9370
9397
9371
- /// Parse a parenthesized comma-separated list of table alias column definitions.
9398
+ /// Parses a parenthesized comma-separated list of table alias column definitions.
9372
9399
fn parse_table_alias_column_defs(&mut self) -> Result<Vec<TableAliasColumnDef>, ParserError> {
9373
9400
if self.consume_token(&Token::LParen) {
9374
9401
let cols = self.parse_comma_separated(|p| {
@@ -11863,7 +11890,7 @@ impl<'a> Parser<'a> {
11863
11890
let constraint = self.parse_expr()?;
11864
11891
Ok(JoinConstraint::On(constraint))
11865
11892
} else if self.parse_keyword(Keyword::USING) {
11866
- let columns = self.parse_parenthesized_column_list (Mandatory, false)?;
11893
+ let columns = self.parse_parenthesized_qualified_column_list (Mandatory, false)?;
11867
11894
Ok(JoinConstraint::Using(columns))
11868
11895
} else {
11869
11896
Ok(JoinConstraint::None)
0 commit comments