mirror of
https://github.com/apache/datafusion-sqlparser-rs.git
synced 2025-08-19 05:30:19 +00:00
Support for ClickHouse array types (e.g. [1,2,3]) (#429)
This commit is contained in:
parent
994b86a45c
commit
3f5619446f
4 changed files with 55 additions and 14 deletions
|
@ -420,7 +420,7 @@ impl<'a> Parser<'a> {
|
|||
Keyword::TRIM => self.parse_trim_expr(),
|
||||
Keyword::INTERVAL => self.parse_literal_interval(),
|
||||
Keyword::LISTAGG => self.parse_listagg_expr(),
|
||||
Keyword::ARRAY => self.parse_array_expr(),
|
||||
Keyword::ARRAY => self.parse_array_expr(true),
|
||||
Keyword::NOT => Ok(Expr::UnaryOp {
|
||||
op: UnaryOperator::Not,
|
||||
expr: Box::new(self.parse_subexpr(Self::UNARY_NOT_PREC)?),
|
||||
|
@ -450,6 +450,7 @@ impl<'a> Parser<'a> {
|
|||
_ => Ok(Expr::Identifier(w.to_ident())),
|
||||
},
|
||||
}, // End of Token::Word
|
||||
Token::LBracket => self.parse_array_expr(false),
|
||||
tok @ Token::Minus | tok @ Token::Plus => {
|
||||
let op = if tok == Token::Plus {
|
||||
UnaryOperator::Plus
|
||||
|
@ -825,11 +826,13 @@ impl<'a> Parser<'a> {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn parse_array_expr(&mut self) -> Result<Expr, ParserError> {
|
||||
self.expect_token(&Token::LBracket)?;
|
||||
pub fn parse_array_expr(&mut self, named: bool) -> Result<Expr, ParserError> {
|
||||
if named {
|
||||
self.expect_token(&Token::LBracket)?;
|
||||
}
|
||||
let exprs = self.parse_comma_separated(Parser::parse_expr)?;
|
||||
self.expect_token(&Token::RBracket)?;
|
||||
Ok(Expr::Array(exprs))
|
||||
Ok(Expr::Array(Array { elem: exprs, named }))
|
||||
}
|
||||
|
||||
/// Parse a SQL LISTAGG expression, e.g. `LISTAGG(...) WITHIN GROUP (ORDER BY ...)`.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue