@@ -2936,7 +2936,7 @@ impl<'a> Parser<'a> {
29362936 } else if Token::LBracket == tok {
29372937 if dialect_of!(self is PostgreSqlDialect | DuckDbDialect | GenericDialect) {
29382938 self.parse_subscript(expr)
2939- } else if dialect_of!(self is SnowflakeDialect) {
2939+ } else if dialect_of!(self is SnowflakeDialect) || self.dialect.supports_partiql() {
29402940 self.prev_token();
29412941 self.parse_json_access(expr)
29422942 } else {
@@ -3072,6 +3072,14 @@ impl<'a> Parser<'a> {
30723072 }
30733073
30743074 fn parse_json_access(&mut self, expr: Expr) -> Result<Expr, ParserError> {
3075+ let path = self.parse_json_path()?;
3076+ Ok(Expr::JsonAccess {
3077+ value: Box::new(expr),
3078+ path,
3079+ })
3080+ }
3081+
3082+ fn parse_json_path(&mut self) -> Result<JsonPath, ParserError> {
30753083 let mut path = Vec::new();
30763084 loop {
30773085 match self.next_token().token {
@@ -3095,10 +3103,7 @@ impl<'a> Parser<'a> {
30953103 }
30963104
30973105 debug_assert!(!path.is_empty());
3098- Ok(Expr::JsonAccess {
3099- value: Box::new(expr),
3100- path: JsonPath { path },
3101- })
3106+ Ok(JsonPath { path })
31023107 }
31033108
31043109 pub fn parse_map_access(&mut self, expr: Expr) -> Result<Expr, ParserError> {
@@ -10338,6 +10343,11 @@ impl<'a> Parser<'a> {
1033810343 } else {
1033910344 let name = self.parse_object_name(true)?;
1034010345
10346+ let json_path = match self.peek_token().token {
10347+ Token::LBracket if self.dialect.supports_partiql() => Some(self.parse_json_path()?),
10348+ _ => None,
10349+ };
10350+
1034110351 let partitions: Vec<Ident> = if dialect_of!(self is MySqlDialect | GenericDialect)
1034210352 && self.parse_keyword(Keyword::PARTITION)
1034310353 {
@@ -10380,6 +10390,7 @@ impl<'a> Parser<'a> {
1038010390 version,
1038110391 partitions,
1038210392 with_ordinality,
10393+ json_path,
1038310394 };
1038410395
1038510396 while let Some(kw) = self.parse_one_of_keywords(&[Keyword::PIVOT, Keyword::UNPIVOT]) {
0 commit comments