mirror of
https://github.com/apache/datafusion-sqlparser-rs.git
synced 2025-12-23 11:12:51 +00:00
PartiQL queries in Redshift (#1534)
This commit is contained in:
parent
10519003ed
commit
62fa8604af
17 changed files with 254 additions and 10 deletions
|
|
@ -2936,7 +2936,7 @@ impl<'a> Parser<'a> {
|
|||
} else if Token::LBracket == tok {
|
||||
if dialect_of!(self is PostgreSqlDialect | DuckDbDialect | GenericDialect) {
|
||||
self.parse_subscript(expr)
|
||||
} else if dialect_of!(self is SnowflakeDialect) {
|
||||
} else if dialect_of!(self is SnowflakeDialect) || self.dialect.supports_partiql() {
|
||||
self.prev_token();
|
||||
self.parse_json_access(expr)
|
||||
} else {
|
||||
|
|
@ -3072,6 +3072,14 @@ impl<'a> Parser<'a> {
|
|||
}
|
||||
|
||||
fn parse_json_access(&mut self, expr: Expr) -> Result<Expr, ParserError> {
|
||||
let path = self.parse_json_path()?;
|
||||
Ok(Expr::JsonAccess {
|
||||
value: Box::new(expr),
|
||||
path,
|
||||
})
|
||||
}
|
||||
|
||||
fn parse_json_path(&mut self) -> Result<JsonPath, ParserError> {
|
||||
let mut path = Vec::new();
|
||||
loop {
|
||||
match self.next_token().token {
|
||||
|
|
@ -3095,10 +3103,7 @@ impl<'a> Parser<'a> {
|
|||
}
|
||||
|
||||
debug_assert!(!path.is_empty());
|
||||
Ok(Expr::JsonAccess {
|
||||
value: Box::new(expr),
|
||||
path: JsonPath { path },
|
||||
})
|
||||
Ok(JsonPath { path })
|
||||
}
|
||||
|
||||
pub fn parse_map_access(&mut self, expr: Expr) -> Result<Expr, ParserError> {
|
||||
|
|
@ -10338,6 +10343,11 @@ impl<'a> Parser<'a> {
|
|||
} else {
|
||||
let name = self.parse_object_name(true)?;
|
||||
|
||||
let json_path = match self.peek_token().token {
|
||||
Token::LBracket if self.dialect.supports_partiql() => Some(self.parse_json_path()?),
|
||||
_ => None,
|
||||
};
|
||||
|
||||
let partitions: Vec<Ident> = if dialect_of!(self is MySqlDialect | GenericDialect)
|
||||
&& self.parse_keyword(Keyword::PARTITION)
|
||||
{
|
||||
|
|
@ -10380,6 +10390,7 @@ impl<'a> Parser<'a> {
|
|||
version,
|
||||
partitions,
|
||||
with_ordinality,
|
||||
json_path,
|
||||
};
|
||||
|
||||
while let Some(kw) = self.parse_one_of_keywords(&[Keyword::PIVOT, Keyword::UNPIVOT]) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue