mirror of
https://github.com/apache/datafusion-sqlparser-rs.git
synced 2025-07-07 17:04:59 +00:00
Fix incorrect parsing of JsonAccess bracket notation after cast in Snowflake (#1708)
This commit is contained in:
parent
0b8ba91156
commit
86abbd6028
6 changed files with 53 additions and 10 deletions
|
@ -1256,6 +1256,32 @@ fn parse_semi_structured_data_traversal() {
|
|||
.to_string(),
|
||||
"sql parser error: Expected: variant object key name, found: 42"
|
||||
);
|
||||
|
||||
// casting a json access and accessing an array element
|
||||
assert_eq!(
|
||||
snowflake().verified_expr("a:b::ARRAY[1]"),
|
||||
Expr::JsonAccess {
|
||||
value: Box::new(Expr::Cast {
|
||||
kind: CastKind::DoubleColon,
|
||||
data_type: DataType::Array(ArrayElemTypeDef::None),
|
||||
format: None,
|
||||
expr: Box::new(Expr::JsonAccess {
|
||||
value: Box::new(Expr::Identifier(Ident::new("a"))),
|
||||
path: JsonPath {
|
||||
path: vec![JsonPathElem::Dot {
|
||||
key: "b".to_string(),
|
||||
quoted: false
|
||||
}]
|
||||
}
|
||||
})
|
||||
}),
|
||||
path: JsonPath {
|
||||
path: vec![JsonPathElem::Bracket {
|
||||
key: Expr::Value(number("1"))
|
||||
}]
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue