mirror of
https://github.com/apache/datafusion-sqlparser-rs.git
synced 2025-12-09 22:11:04 +00:00
Support the type key (#750)
This commit is contained in:
parent
bda8268e56
commit
01fd20f0a3
2 changed files with 23 additions and 1 deletions
|
|
@ -3822,7 +3822,7 @@ impl<'a> Parser<'a> {
|
|||
)?,
|
||||
},
|
||||
// Case when Snowflake Semi-structured data like key:value
|
||||
Keyword::NoKeyword | Keyword::LOCATION if dialect_of!(self is SnowflakeDialect | GenericDialect) => {
|
||||
Keyword::NoKeyword | Keyword::LOCATION | Keyword::TYPE if dialect_of!(self is SnowflakeDialect | GenericDialect) => {
|
||||
Ok(Value::UnQuotedString(w.value))
|
||||
}
|
||||
_ => self.expected(
|
||||
|
|
|
|||
|
|
@ -169,6 +169,28 @@ fn parse_json_using_colon() {
|
|||
select.projection[0]
|
||||
);
|
||||
|
||||
let sql = "SELECT a:type FROM t";
|
||||
let select = snowflake().verified_only_select(sql);
|
||||
assert_eq!(
|
||||
SelectItem::UnnamedExpr(Expr::JsonAccess {
|
||||
left: Box::new(Expr::Identifier(Ident::new("a"))),
|
||||
operator: JsonOperator::Colon,
|
||||
right: Box::new(Expr::Value(Value::UnQuotedString("type".to_string()))),
|
||||
}),
|
||||
select.projection[0]
|
||||
);
|
||||
|
||||
let sql = "SELECT a:location FROM t";
|
||||
let select = snowflake().verified_only_select(sql);
|
||||
assert_eq!(
|
||||
SelectItem::UnnamedExpr(Expr::JsonAccess {
|
||||
left: Box::new(Expr::Identifier(Ident::new("a"))),
|
||||
operator: JsonOperator::Colon,
|
||||
right: Box::new(Expr::Value(Value::UnQuotedString("location".to_string()))),
|
||||
}),
|
||||
select.projection[0]
|
||||
);
|
||||
|
||||
snowflake().one_statement_parses_to("SELECT a:b::int FROM t", "SELECT CAST(a:b AS INT) FROM t");
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue