Skip to content

Commit 0ac1fa0

Browse files
authored
Revert "Add support for qualified column names in JOIN ... USING (apache#1663)"
This reverts commit e01f55a.
1 parent e77ecbc commit 0ac1fa0

File tree

4 files changed

+7
-35
lines changed

4 files changed

+7
-35
lines changed

src/ast/query.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2050,7 +2050,7 @@ pub enum JoinOperator {
20502050
#[cfg_attr(feature = "visitor", derive(Visit, VisitMut))]
20512051
pub enum JoinConstraint {
20522052
On(Expr),
2053-
Using(Vec<ObjectName>),
2053+
Using(Vec<Ident>),
20542054
Natural,
20552055
None,
20562056
}

src/ast/spans.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2035,7 +2035,7 @@ impl Spanned for JoinConstraint {
20352035
fn span(&self) -> Span {
20362036
match self {
20372037
JoinConstraint::On(expr) => expr.span(),
2038-
JoinConstraint::Using(vec) => union_spans(vec.iter().map(|i| i.span())),
2038+
JoinConstraint::Using(vec) => union_spans(vec.iter().map(|i| i.span)),
20392039
JoinConstraint::Natural => Span::empty(),
20402040
JoinConstraint::None => Span::empty(),
20412041
}

src/parser/mod.rs

Lines changed: 4 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -9336,45 +9336,18 @@ impl<'a> Parser<'a> {
93369336
})
93379337
}
93389338

9339-
/// Parses a parenthesized comma-separated list of unqualified, possibly quoted identifiers.
9340-
/// For example: `(col1, "col 2", ...)`
9339+
/// Parse a parenthesized comma-separated list of unqualified, possibly quoted identifiers
93419340
pub fn parse_parenthesized_column_list(
93429341
&mut self,
93439342
optional: IsOptional,
93449343
allow_empty: bool,
93459344
) -> 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-
{
93729345
if self.consume_token(&Token::LParen) {
93739346
if allow_empty && self.peek_token().token == Token::RParen {
93749347
self.next_token();
93759348
Ok(vec![])
93769349
} else {
9377-
let cols = self.parse_comma_separated(|p| f(p))?;
9350+
let cols = self.parse_comma_separated(|p| p.parse_identifier())?;
93789351
self.expect_token(&Token::RParen)?;
93799352
Ok(cols)
93809353
}
@@ -9385,7 +9358,7 @@ impl<'a> Parser<'a> {
93859358
}
93869359
}
93879360

9388-
/// Parses a parenthesized comma-separated list of table alias column definitions.
9361+
/// Parse a parenthesized comma-separated list of table alias column definitions.
93899362
fn parse_table_alias_column_defs(&mut self) -> Result<Vec<TableAliasColumnDef>, ParserError> {
93909363
if self.consume_token(&Token::LParen) {
93919364
let cols = self.parse_comma_separated(|p| {
@@ -11880,7 +11853,7 @@ impl<'a> Parser<'a> {
1188011853
let constraint = self.parse_expr()?;
1188111854
Ok(JoinConstraint::On(constraint))
1188211855
} else if self.parse_keyword(Keyword::USING) {
11883-
let columns = self.parse_parenthesized_qualified_column_list(Mandatory, false)?;
11856+
let columns = self.parse_parenthesized_column_list(Mandatory, false)?;
1188411857
Ok(JoinConstraint::Using(columns))
1188511858
} else {
1188611859
Ok(JoinConstraint::None)

tests/sqlparser_common.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6541,7 +6541,7 @@ fn parse_joins_using() {
65416541
sample: None,
65426542
},
65436543
global: false,
6544-
join_operator: f(JoinConstraint::Using(vec![ObjectName(vec!["c1".into()])])),
6544+
join_operator: f(JoinConstraint::Using(vec!["c1".into()])),
65456545
}
65466546
}
65476547
// Test parsing of aliases
@@ -6598,7 +6598,6 @@ fn parse_joins_using() {
65986598
only(&verified_only_select("SELECT * FROM t1 FULL JOIN t2 USING(c1)").from).joins,
65996599
vec![join_with_constraint("t2", None, JoinOperator::FullOuter)]
66006600
);
6601-
verified_stmt("SELECT * FROM tbl1 AS t1 JOIN tbl2 AS t2 USING(t2.col1)");
66026601
}
66036602

66046603
#[test]

0 commit comments

Comments
 (0)