Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
parkma99 committed Jul 18, 2023
1 parent 9b27ed5 commit b8e304f
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 15 deletions.
19 changes: 8 additions & 11 deletions src/ast/query.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,9 +110,10 @@ impl fmt::Display for SetExpr {
} => {
write!(f, "{left} {op}")?;
match set_quantifier {
SetQuantifier::All | SetQuantifier::Distinct | SetQuantifier::ByName(_) => {
write!(f, " {set_quantifier}")?
}
SetQuantifier::All
| SetQuantifier::Distinct
| SetQuantifier::ByName
| SetQuantifier::AllByName => write!(f, " {set_quantifier}")?,
SetQuantifier::None => write!(f, "{set_quantifier}")?,
}
write!(f, " {right}")?;
Expand Down Expand Up @@ -150,7 +151,8 @@ impl fmt::Display for SetOperator {
pub enum SetQuantifier {
All,
Distinct,
ByName(bool),
ByName,
AllByName,
None,
}

Expand All @@ -159,13 +161,8 @@ impl fmt::Display for SetQuantifier {
match self {
SetQuantifier::All => write!(f, "ALL"),
SetQuantifier::Distinct => write!(f, "DISTINCT"),
SetQuantifier::ByName(is_all) => {
if *is_all {
write!(f, "ALL BY NAME")
} else {
write!(f, "BY NAME")
}
}
SetQuantifier::ByName => write!(f, "BY NAME"),
SetQuantifier::AllByName => write!(f, "ALL BY NAME"),
SetQuantifier::None => write!(f, ""),
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5332,10 +5332,10 @@ impl<'a> Parser<'a> {
match op {
Some(SetOperator::Union) => {
if self.parse_keywords(&[Keyword::BY, Keyword::NAME]) {
SetQuantifier::ByName(false)
SetQuantifier::ByName
} else if self.parse_keyword(Keyword::ALL) {
if self.parse_keywords(&[Keyword::BY, Keyword::NAME]) {
SetQuantifier::ByName(true)
SetQuantifier::AllByName
} else {
SetQuantifier::All
}
Expand Down
4 changes: 2 additions & 2 deletions tests/sqlparser_duckdb.rs
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ fn test_select_union_by_name() {
let ast = duckdb().verified_query("SELECT * FROM capitals UNION BY NAME SELECT * FROM weather");
let expected = Box::<SetExpr>::new(SetExpr::SetOperation {
op: SetOperator::Union,
set_quantifier: SetQuantifier::ByName(false),
set_quantifier: SetQuantifier::ByName,
left: Box::<SetExpr>::new(SetExpr::Select(Box::new(Select {
distinct: None,
top: None,
Expand Down Expand Up @@ -214,7 +214,7 @@ fn test_select_union_by_name() {
duckdb().verified_query("SELECT * FROM capitals UNION ALL BY NAME SELECT * FROM weather");
let expected = Box::<SetExpr>::new(SetExpr::SetOperation {
op: SetOperator::Union,
set_quantifier: SetQuantifier::ByName(true),
set_quantifier: SetQuantifier::AllByName,
left: Box::<SetExpr>::new(SetExpr::Select(Box::new(Select {
distinct: None,
top: None,
Expand Down

0 comments on commit b8e304f

Please sign in to comment.