mirror of
https://github.com/apache/datafusion-sqlparser-rs.git
synced 2025-10-29 06:17:31 +00:00
Add support for UNION DISTINCT BY NAME syntax (#997)
Co-authored-by: Andrew Lamb <andrew@nerdnetworks.org>
This commit is contained in:
parent
c03586b727
commit
5c10668dbb
3 changed files with 89 additions and 152 deletions
|
|
@ -120,7 +120,8 @@ impl fmt::Display for SetExpr {
|
|||
SetQuantifier::All
|
||||
| SetQuantifier::Distinct
|
||||
| SetQuantifier::ByName
|
||||
| SetQuantifier::AllByName => write!(f, " {set_quantifier}")?,
|
||||
| SetQuantifier::AllByName
|
||||
| SetQuantifier::DistinctByName => write!(f, " {set_quantifier}")?,
|
||||
SetQuantifier::None => write!(f, "{set_quantifier}")?,
|
||||
}
|
||||
write!(f, " {right}")?;
|
||||
|
|
@ -160,6 +161,7 @@ pub enum SetQuantifier {
|
|||
Distinct,
|
||||
ByName,
|
||||
AllByName,
|
||||
DistinctByName,
|
||||
None,
|
||||
}
|
||||
|
||||
|
|
@ -170,6 +172,7 @@ impl fmt::Display for SetQuantifier {
|
|||
SetQuantifier::Distinct => write!(f, "DISTINCT"),
|
||||
SetQuantifier::ByName => write!(f, "BY NAME"),
|
||||
SetQuantifier::AllByName => write!(f, "ALL BY NAME"),
|
||||
SetQuantifier::DistinctByName => write!(f, "DISTINCT BY NAME"),
|
||||
SetQuantifier::None => write!(f, ""),
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5696,7 +5696,9 @@ impl<'a> Parser<'a> {
|
|||
pub fn parse_set_quantifier(&mut self, op: &Option<SetOperator>) -> SetQuantifier {
|
||||
match op {
|
||||
Some(SetOperator::Union) => {
|
||||
if self.parse_keywords(&[Keyword::BY, Keyword::NAME]) {
|
||||
if self.parse_keywords(&[Keyword::DISTINCT, Keyword::BY, Keyword::NAME]) {
|
||||
SetQuantifier::DistinctByName
|
||||
} else if self.parse_keywords(&[Keyword::BY, Keyword::NAME]) {
|
||||
SetQuantifier::ByName
|
||||
} else if self.parse_keyword(Keyword::ALL) {
|
||||
if self.parse_keywords(&[Keyword::BY, Keyword::NAME]) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue