diff --git a/src/ast/query.rs b/src/ast/query.rs index 2e44d2b79..5f4c289dc 100644 --- a/src/ast/query.rs +++ b/src/ast/query.rs @@ -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}")?; @@ -150,7 +151,8 @@ impl fmt::Display for SetOperator { pub enum SetQuantifier { All, Distinct, - ByName(bool), + ByName, + AllByName, None, } @@ -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, ""), } } diff --git a/src/parser.rs b/src/parser.rs index caf8c1580..4d331ce07 100644 --- a/src/parser.rs +++ b/src/parser.rs @@ -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 } diff --git a/tests/sqlparser_duckdb.rs b/tests/sqlparser_duckdb.rs index d13c06a89..580a4ec01 100644 --- a/tests/sqlparser_duckdb.rs +++ b/tests/sqlparser_duckdb.rs @@ -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::::new(SetExpr::SetOperation { op: SetOperator::Union, - set_quantifier: SetQuantifier::ByName(false), + set_quantifier: SetQuantifier::ByName, left: Box::::new(SetExpr::Select(Box::new(Select { distinct: None, top: None, @@ -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::::new(SetExpr::SetOperation { op: SetOperator::Union, - set_quantifier: SetQuantifier::ByName(true), + set_quantifier: SetQuantifier::AllByName, left: Box::::new(SetExpr::Select(Box::new(Select { distinct: None, top: None,