Skip to content

Commit aebc60e

Browse files
committed
Add support for optional precission in TIMESTAMP_NTZ
1 parent 9d78029 commit aebc60e

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

src/parser/mod.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9869,7 +9869,12 @@ impl<'a> Parser<'a> {
98699869
self.parse_optional_precision()?,
98709870
TimezoneInfo::Tz,
98719871
)),
9872-
Keyword::TIMESTAMP_NTZ => Ok(DataType::TimestampNtz),
9872+
// Consume optional precision for Snowflake/Databricks TIMESTAMP_NTZ, e.g. TIMESTAMP_NTZ(3)
9873+
// Precision is currently not represented in the AST variant, but we must not error on it.
9874+
Keyword::TIMESTAMP_NTZ => {
9875+
let _ = self.parse_optional_precision()?;
9876+
Ok(DataType::TimestampNtz)
9877+
}
98739878
Keyword::TIME => {
98749879
let precision = self.parse_optional_precision()?;
98759880
let tz = if self.parse_keyword(Keyword::WITH) {

tests/sqlparser_snowflake.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,13 @@ fn test_snowflake_create_table() {
4444
}
4545
}
4646

47+
#[test]
48+
fn test_snowflake_create_table_timestamp_ntz_precision_ctas_values() {
49+
let sql = "CREATE TABLE t (x TIMESTAMP_NTZ(3)) AS SELECT * FROM VALUES ('2025-04-09T21:11:23')";
50+
let canonical = "CREATE TABLE t (x TIMESTAMP_NTZ) AS SELECT * FROM (VALUES ('2025-04-09T21:11:23'))";
51+
snowflake().one_statement_parses_to(sql, canonical);
52+
}
53+
4754
#[test]
4855
fn parse_sf_create_secure_view_and_materialized_view() {
4956
for sql in [

0 commit comments

Comments
 (0)