@@ -9336,18 +9336,45 @@ impl<'a> Parser<'a> {
9336
9336
})
9337
9337
}
9338
9338
9339
- /// Parse a parenthesized comma-separated list of unqualified, possibly quoted identifiers
9339
+ /// Parses a parenthesized comma-separated list of unqualified, possibly quoted identifiers.
9340
+ /// For example: `(col1, "col 2", ...)`
9340
9341
pub fn parse_parenthesized_column_list(
9341
9342
&mut self,
9342
9343
optional: IsOptional,
9343
9344
allow_empty: bool,
9344
9345
) -> Result<Vec<Ident>, ParserError> {
9346
+ self.parse_parenthesized_column_list_inner(optional, allow_empty, |p| p.parse_identifier())
9347
+ }
9348
+
9349
+ /// Parses a parenthesized comma-separated list of qualified, possibly quoted identifiers.
9350
+ /// For example: `(db1.sc1.tbl1.col1, db1.sc1.tbl1."col 2", ...)`
9351
+ pub fn parse_parenthesized_qualified_column_list(
9352
+ &mut self,
9353
+ optional: IsOptional,
9354
+ allow_empty: bool,
9355
+ ) -> Result<Vec<ObjectName>, ParserError> {
9356
+ self.parse_parenthesized_column_list_inner(optional, allow_empty, |p| {
9357
+ p.parse_object_name(true)
9358
+ })
9359
+ }
9360
+
9361
+ /// Parses a parenthesized comma-separated list of columns using
9362
+ /// the provided function to parse each element.
9363
+ fn parse_parenthesized_column_list_inner<F, T>(
9364
+ &mut self,
9365
+ optional: IsOptional,
9366
+ allow_empty: bool,
9367
+ mut f: F,
9368
+ ) -> Result<Vec<T>, ParserError>
9369
+ where
9370
+ F: FnMut(&mut Parser) -> Result<T, ParserError>,
9371
+ {
9345
9372
if self.consume_token(&Token::LParen) {
9346
9373
if allow_empty && self.peek_token().token == Token::RParen {
9347
9374
self.next_token();
9348
9375
Ok(vec![])
9349
9376
} else {
9350
- let cols = self.parse_comma_separated(|p| p.parse_identifier( ))?;
9377
+ let cols = self.parse_comma_separated(|p| f(p ))?;
9351
9378
self.expect_token(&Token::RParen)?;
9352
9379
Ok(cols)
9353
9380
}
@@ -9358,7 +9385,7 @@ impl<'a> Parser<'a> {
9358
9385
}
9359
9386
}
9360
9387
9361
- /// Parse a parenthesized comma-separated list of table alias column definitions.
9388
+ /// Parses a parenthesized comma-separated list of table alias column definitions.
9362
9389
fn parse_table_alias_column_defs(&mut self) -> Result<Vec<TableAliasColumnDef>, ParserError> {
9363
9390
if self.consume_token(&Token::LParen) {
9364
9391
let cols = self.parse_comma_separated(|p| {
@@ -11853,7 +11880,7 @@ impl<'a> Parser<'a> {
11853
11880
let constraint = self.parse_expr()?;
11854
11881
Ok(JoinConstraint::On(constraint))
11855
11882
} else if self.parse_keyword(Keyword::USING) {
11856
- let columns = self.parse_parenthesized_column_list (Mandatory, false)?;
11883
+ let columns = self.parse_parenthesized_qualified_column_list (Mandatory, false)?;
11857
11884
Ok(JoinConstraint::Using(columns))
11858
11885
} else {
11859
11886
Ok(JoinConstraint::None)
0 commit comments