Skip to content

Commit d7c6483

Browse files
committed
snowflake: minus set operator
1 parent 3709d42 commit d7c6483

3 files changed

Lines changed: 7 additions & 1 deletion

File tree

src/ast/query.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ impl fmt::Display for SetExpr {
9999
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
100100
pub enum SetOperator {
101101
Union,
102+
Minus,
102103
Except,
103104
Intersect,
104105
}
@@ -107,6 +108,7 @@ impl fmt::Display for SetOperator {
107108
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
108109
f.write_str(match self {
109110
SetOperator::Union => "UNION",
111+
SetOperator::Minus => "MINUS",
110112
SetOperator::Except => "EXCEPT",
111113
SetOperator::Intersect => "INTERSECT",
112114
})

src/dialect/keywords.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -274,6 +274,7 @@ define_keywords!(
274274
MERGE,
275275
METHOD,
276276
MIN,
277+
MINUS,
277278
MINUTE,
278279
MOD,
279280
MODIFIES,

src/parser.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2040,7 +2040,9 @@ impl<'a> Parser<'a> {
20402040
let op = self.parse_set_operator(&self.peek_token());
20412041
let next_precedence = match op {
20422042
// UNION and EXCEPT have the same binding power and evaluate left-to-right
2043-
Some(SetOperator::Union) | Some(SetOperator::Except) => 10,
2043+
Some(SetOperator::Union) | Some(SetOperator::Except) | Some(SetOperator::Minus) => {
2044+
10
2045+
}
20442046
// INTERSECT has higher precedence than UNION/EXCEPT
20452047
Some(SetOperator::Intersect) => 20,
20462048
// Unexpected token or EOF => stop parsing the query body
@@ -2064,6 +2066,7 @@ impl<'a> Parser<'a> {
20642066
fn parse_set_operator(&mut self, token: &Token) -> Option<SetOperator> {
20652067
match token {
20662068
Token::Word(w) if w.keyword == Keyword::UNION => Some(SetOperator::Union),
2069+
Token::Word(w) if w.keyword == Keyword::MINUS => Some(SetOperator::Union),
20672070
Token::Word(w) if w.keyword == Keyword::EXCEPT => Some(SetOperator::Except),
20682071
Token::Word(w) if w.keyword == Keyword::INTERSECT => Some(SetOperator::Intersect),
20692072
_ => None,

0 commit comments

Comments
 (0)