mirror of
https://github.com/apache/datafusion-sqlparser-rs.git
synced 2025-07-16 04:54:59 +00:00
Add support for CREATE TYPE (AS) statements (#888)
Co-authored-by: Andrew Lamb <andrew@nerdnetworks.org>
This commit is contained in:
parent
e8cad6ab65
commit
2b37e4ae6e
4 changed files with 120 additions and 0 deletions
|
@ -7092,3 +7092,29 @@ fn parse_trailing_comma() {
|
|||
|
||||
trailing_commas.verified_stmt("SELECT DISTINCT ON (album_id) name FROM track");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn parse_create_type() {
|
||||
let create_type =
|
||||
verified_stmt("CREATE TYPE db.type_name AS (foo INT, bar TEXT COLLATE \"de_DE\")");
|
||||
assert_eq!(
|
||||
Statement::CreateType {
|
||||
name: ObjectName(vec![Ident::new("db"), Ident::new("type_name")]),
|
||||
representation: UserDefinedTypeRepresentation::Composite {
|
||||
attributes: vec![
|
||||
UserDefinedTypeCompositeAttributeDef {
|
||||
name: Ident::new("foo"),
|
||||
data_type: DataType::Int(None),
|
||||
collation: None,
|
||||
},
|
||||
UserDefinedTypeCompositeAttributeDef {
|
||||
name: Ident::new("bar"),
|
||||
data_type: DataType::Text,
|
||||
collation: Some(ObjectName(vec![Ident::with_quote('\"', "de_DE")])),
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
create_type
|
||||
);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue