Skip to content

Commit 781170a

Browse files
committed
snowflake: qualify
1 parent 9d5f9fb commit 781170a

3 files changed

Lines changed: 13 additions & 0 deletions

File tree

src/ast/query.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,8 @@ pub struct Select {
132132
pub group_by: Vec<Expr>,
133133
/// HAVING
134134
pub having: Option<Expr>,
135+
/// QUALIFY https://docs.snowflake.com/en/sql-reference/constructs/qualify.html
136+
pub qualify: Option<Expr>,
135137
}
136138

137139
impl fmt::Display for Select {
@@ -153,6 +155,9 @@ impl fmt::Display for Select {
153155
if let Some(ref having) = self.having {
154156
write!(f, " HAVING {}", having)?;
155157
}
158+
if let Some(ref qualify) = self.qualify {
159+
write!(f, " QUALIFY {}", qualify)?;
160+
}
156161
Ok(())
157162
}
158163
}

src/dialect/keywords.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -332,6 +332,7 @@ define_keywords!(
332332
PREPARE,
333333
PRIMARY,
334334
PROCEDURE,
335+
QUALIFY,
335336
QUARTER,
336337
RANGE,
337338
RANK,

src/parser.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2057,6 +2057,12 @@ impl<'a> Parser<'a> {
20572057
None
20582058
};
20592059

2060+
let qualify = if self.parse_keyword(Keyword::QUALIFY) {
2061+
Some(self.parse_expr()?)
2062+
} else {
2063+
None
2064+
};
2065+
20602066
Ok(Select {
20612067
distinct,
20622068
top,
@@ -2065,6 +2071,7 @@ impl<'a> Parser<'a> {
20652071
selection,
20662072
group_by,
20672073
having,
2074+
qualify,
20682075
})
20692076
}
20702077

0 commit comments

Comments
 (0)