mirror of
https://github.com/apache/datafusion-sqlparser-rs.git
synced 2025-08-20 14:10:15 +00:00
Enable map access for function, add ClickHouse dialect (#382)
* 1 Add ClickHouse dialects. 2 Enable map access for function. * 1 Fixed compilation errors. 2 Modify the code according to @alamb's comments. * Fixed compilation errors.
This commit is contained in:
parent
9569d1b215
commit
60ad78dafc
6 changed files with 105 additions and 16 deletions
|
@ -1072,7 +1072,7 @@ impl<'a> Parser<'a> {
|
|||
let key = self.parse_map_key()?;
|
||||
let tok = self.consume_token(&Token::RBracket);
|
||||
debug!("Tok: {}", tok);
|
||||
let mut key_parts: Vec<Value> = vec![key];
|
||||
let mut key_parts: Vec<Expr> = vec![key];
|
||||
while self.consume_token(&Token::LBracket) {
|
||||
let key = self.parse_map_key()?;
|
||||
let tok = self.consume_token(&Token::RBracket);
|
||||
|
@ -2175,17 +2175,20 @@ impl<'a> Parser<'a> {
|
|||
}
|
||||
|
||||
/// Parse a map key string
|
||||
pub fn parse_map_key(&mut self) -> Result<Value, ParserError> {
|
||||
pub fn parse_map_key(&mut self) -> Result<Expr, ParserError> {
|
||||
match self.next_token() {
|
||||
Token::Word(Word { value, keyword, .. }) if keyword == Keyword::NoKeyword => {
|
||||
Ok(Value::SingleQuotedString(value))
|
||||
if self.peek_token() == Token::LParen {
|
||||
return self.parse_function(ObjectName(vec![Ident::new(value)]));
|
||||
}
|
||||
Ok(Expr::Value(Value::SingleQuotedString(value)))
|
||||
}
|
||||
Token::SingleQuotedString(s) => Ok(Value::SingleQuotedString(s)),
|
||||
Token::SingleQuotedString(s) => Ok(Expr::Value(Value::SingleQuotedString(s))),
|
||||
#[cfg(not(feature = "bigdecimal"))]
|
||||
Token::Number(s, _) => Ok(Value::Number(s, false)),
|
||||
Token::Number(s, _) => Ok(Expr::Value(Value::Number(s, false))),
|
||||
#[cfg(feature = "bigdecimal")]
|
||||
Token::Number(s, _) => Ok(Value::Number(s.parse().unwrap(), false)),
|
||||
unexpected => self.expected("literal string or number", unexpected),
|
||||
Token::Number(s, _) => Ok(Expr::Value(Value::Number(s.parse().unwrap(), false))),
|
||||
unexpected => self.expected("literal string, number or function", unexpected),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue