Skip to content

Commit 7993384

Browse files
Support date 'key' when using semi structured data (apache#1023)
1 parent b89edaa commit 7993384

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

src/parser/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4726,7 +4726,7 @@ impl<'a> Parser<'a> {
47264726
)?,
47274727
},
47284728
// Case when Snowflake Semi-structured data like key:value
4729-
Keyword::NoKeyword | Keyword::LOCATION | Keyword::TYPE if dialect_of!(self is SnowflakeDialect | GenericDialect) => {
4729+
Keyword::NoKeyword | Keyword::LOCATION | Keyword::TYPE | Keyword::DATE if dialect_of!(self is SnowflakeDialect | GenericDialect) => {
47304730
Ok(Value::UnQuotedString(w.value))
47314731
}
47324732
_ => self.expected(

tests/sqlparser_snowflake.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,17 @@ fn parse_json_using_colon() {
208208
select.projection[0]
209209
);
210210

211+
let sql = "SELECT a:date FROM t";
212+
let select = snowflake().verified_only_select(sql);
213+
assert_eq!(
214+
SelectItem::UnnamedExpr(Expr::JsonAccess {
215+
left: Box::new(Expr::Identifier(Ident::new("a"))),
216+
operator: JsonOperator::Colon,
217+
right: Box::new(Expr::Value(Value::UnQuotedString("date".to_string()))),
218+
}),
219+
select.projection[0]
220+
);
221+
211222
snowflake().one_statement_parses_to("SELECT a:b::int FROM t", "SELECT CAST(a:b AS INT) FROM t");
212223
}
213224

0 commit comments

Comments
 (0)