Add support for Databricks TIMESTAMP_NTZ. (#1781)

Co-authored-by: Roman Borschel <roman@cluvio.com>
This commit is contained in:
Roman Borschel 2025-03-31 17:51:55 +02:00 committed by GitHub
parent 95d7b86da5
commit 91327bb0c0
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 47 additions and 0 deletions

View file

@ -317,3 +317,43 @@ fn parse_databricks_struct_function() {
})
);
}
#[test]
fn data_type_timestamp_ntz() {
// Literal
assert_eq!(
databricks().verified_expr("TIMESTAMP_NTZ '2025-03-29T18:52:00'"),
Expr::TypedString {
data_type: DataType::TimestampNtz,
value: Value::SingleQuotedString("2025-03-29T18:52:00".to_owned())
}
);
// Cast
assert_eq!(
databricks().verified_expr("(created_at)::TIMESTAMP_NTZ"),
Expr::Cast {
kind: CastKind::DoubleColon,
expr: Box::new(Expr::Nested(Box::new(Expr::Identifier(
"created_at".into()
)))),
data_type: DataType::TimestampNtz,
format: None
}
);
// Column definition
match databricks().verified_stmt("CREATE TABLE foo (x TIMESTAMP_NTZ)") {
Statement::CreateTable(CreateTable { columns, .. }) => {
assert_eq!(
columns,
vec![ColumnDef {
name: "x".into(),
data_type: DataType::TimestampNtz,
options: vec![],
}]
);
}
s => panic!("Unexpected statement: {:?}", s),
}
}