mirror of
https://github.com/apache/datafusion-sqlparser-rs.git
synced 2025-07-08 01:15:00 +00:00
feat: support pg type alias (#933)
This commit is contained in:
parent
53593f1982
commit
0ddb853410
4 changed files with 163 additions and 2 deletions
|
@ -2945,3 +2945,74 @@ fn parse_truncate() {
|
|||
truncate
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn parse_create_table_with_alias() {
|
||||
let sql = "CREATE TABLE public.datatype_aliases
|
||||
(
|
||||
int8_col INT8,
|
||||
int4_col INT4,
|
||||
int2_col INT2,
|
||||
float8_col FLOAT8,
|
||||
float4_col FLOAT4,
|
||||
bool_col BOOL,
|
||||
);";
|
||||
match pg_and_generic().one_statement_parses_to(sql, "") {
|
||||
Statement::CreateTable {
|
||||
name,
|
||||
columns,
|
||||
constraints,
|
||||
with_options: _with_options,
|
||||
if_not_exists: false,
|
||||
external: false,
|
||||
file_format: None,
|
||||
location: None,
|
||||
..
|
||||
} => {
|
||||
assert_eq!("public.datatype_aliases", name.to_string());
|
||||
assert_eq!(
|
||||
columns,
|
||||
vec![
|
||||
ColumnDef {
|
||||
name: "int8_col".into(),
|
||||
data_type: DataType::Int8(None),
|
||||
collation: None,
|
||||
options: vec![]
|
||||
},
|
||||
ColumnDef {
|
||||
name: "int4_col".into(),
|
||||
data_type: DataType::Int4(None),
|
||||
collation: None,
|
||||
options: vec![]
|
||||
},
|
||||
ColumnDef {
|
||||
name: "int2_col".into(),
|
||||
data_type: DataType::Int2(None),
|
||||
collation: None,
|
||||
options: vec![]
|
||||
},
|
||||
ColumnDef {
|
||||
name: "float8_col".into(),
|
||||
data_type: DataType::FLOAT8,
|
||||
collation: None,
|
||||
options: vec![]
|
||||
},
|
||||
ColumnDef {
|
||||
name: "float4_col".into(),
|
||||
data_type: DataType::FLOAT4,
|
||||
collation: None,
|
||||
options: vec![]
|
||||
},
|
||||
ColumnDef {
|
||||
name: "bool_col".into(),
|
||||
data_type: DataType::Bool,
|
||||
collation: None,
|
||||
options: vec![]
|
||||
},
|
||||
]
|
||||
);
|
||||
assert!(constraints.is_empty());
|
||||
}
|
||||
_ => unreachable!(),
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue