From 0575f4228b7e87ac8bbe5aa704ddfd1417a4fb7c Mon Sep 17 00:00:00 2001 From: Yuval Shkolar Date: Tue, 24 Oct 2023 11:15:32 +0300 Subject: [PATCH 1/2] add support in date --- src/parser/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/parser/mod.rs b/src/parser/mod.rs index 0065f7987..d17fee51f 100644 --- a/src/parser/mod.rs +++ b/src/parser/mod.rs @@ -4659,7 +4659,7 @@ impl<'a> Parser<'a> { )?, }, // Case when Snowflake Semi-structured data like key:value - Keyword::NoKeyword | Keyword::LOCATION | Keyword::TYPE if dialect_of!(self is SnowflakeDialect | GenericDialect) => { + Keyword::NoKeyword | Keyword::LOCATION | Keyword::TYPE | Keyword::DATE if dialect_of!(self is SnowflakeDialect | GenericDialect) => { Ok(Value::UnQuotedString(w.value)) } _ => self.expected( From 4df18bc4606d18dbbdf37e78d506520b9759e563 Mon Sep 17 00:00:00 2001 From: Yuval Shkolar Date: Tue, 24 Oct 2023 21:28:16 +0300 Subject: [PATCH 2/2] add test --- tests/sqlparser_snowflake.rs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/tests/sqlparser_snowflake.rs b/tests/sqlparser_snowflake.rs index bb988665d..6a02b3586 100644 --- a/tests/sqlparser_snowflake.rs +++ b/tests/sqlparser_snowflake.rs @@ -208,6 +208,17 @@ fn parse_json_using_colon() { select.projection[0] ); + let sql = "SELECT a:date 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("date".to_string()))), + }), + select.projection[0] + ); + snowflake().one_statement_parses_to("SELECT a:b::int FROM t", "SELECT CAST(a:b AS INT) FROM t"); }