Support Databricks struct literal (#1542)

This commit is contained in:
Ayman Elkfrawy 2024-12-02 07:23:48 -08:00 committed by GitHub
parent 4ab3ab9147
commit bd750dfada
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 71 additions and 9 deletions

View file

@ -278,3 +278,38 @@ fn parse_use() {
);
}
}
#[test]
fn parse_databricks_struct_function() {
assert_eq!(
databricks_and_generic()
.verified_only_select("SELECT STRUCT(1, 'foo')")
.projection[0],
SelectItem::UnnamedExpr(Expr::Struct {
values: vec![
Expr::Value(number("1")),
Expr::Value(Value::SingleQuotedString("foo".to_string()))
],
fields: vec![]
})
);
assert_eq!(
databricks_and_generic()
.verified_only_select("SELECT STRUCT(1 AS one, 'foo' AS foo, false)")
.projection[0],
SelectItem::UnnamedExpr(Expr::Struct {
values: vec![
Expr::Named {
expr: Expr::Value(number("1")).into(),
name: Ident::new("one")
},
Expr::Named {
expr: Expr::Value(Value::SingleQuotedString("foo".to_string())).into(),
name: Ident::new("foo")
},
Expr::Value(Value::Boolean(false))
],
fields: vec![]
})
);
}