Skip to content

Commit bbfea03

Browse files
committed
snowflake: nested exprs can be lists
1 parent ba66a66 commit bbfea03

2 files changed

Lines changed: 12 additions & 3 deletions

File tree

src/ast/mod.rs

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,8 @@ pub enum Expr {
222222
index_expr: Box<Expr>,
223223
},
224224
/// Nested expression e.g. `(foo > bar)` or `(1)`
225-
Nested(Box<Expr>),
225+
/// Snowflake allows multiple comma-separated expressions here
226+
Nested(Vec<Expr>),
226227
/// A literal value, such as string, number, date or NULL
227228
Value(Value),
228229
/// A constant of form `<data_type> 'value'`.
@@ -339,7 +340,15 @@ impl fmt::Display for Expr {
339340
Expr::Extract { field, expr } => write!(f, "EXTRACT({} FROM {})", field, expr),
340341
Expr::Collate { expr, collation } => write!(f, "{} COLLATE {}", expr, collation),
341342
Expr::Index { expr, index_expr } => write!(f, "{}[{}]", expr, index_expr),
342-
Expr::Nested(ast) => write!(f, "({})", ast),
343+
Expr::Nested(exprs) => {
344+
write!(f, "(")?;
345+
let mut delim = "";
346+
for expr in exprs {
347+
write!(f, "{}{}", delim, expr)?;
348+
delim = ", ";
349+
}
350+
write!(f, ")")
351+
}
343352
Expr::Value(v) => write!(f, "{}", v),
344353
Expr::TypedString { data_type, value } => {
345354
write!(f, "{}", data_type)?;

src/parser.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -334,7 +334,7 @@ impl<'a> Parser<'a> {
334334
self.prev_token();
335335
Expr::Subquery(Box::new(self.parse_query()?))
336336
} else {
337-
Expr::Nested(Box::new(self.parse_expr()?))
337+
Expr::Nested(self.parse_comma_separated(Parser::parse_expr)?)
338338
};
339339
self.expect_token(&Token::RParen)?;
340340
Ok(expr)

0 commit comments

Comments
 (0)