mirror of
https://github.com/apache/datafusion-sqlparser-rs.git
synced 2025-10-09 21:42:05 +00:00
ClickHouse: create view with fields and data types (#1292)
This commit is contained in:
parent
029a999645
commit
375742d1fa
5 changed files with 60 additions and 2 deletions
|
@ -220,6 +220,47 @@ fn parse_create_table() {
|
|||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn parse_create_view_with_fields_data_types() {
|
||||
match clickhouse().verified_stmt(r#"CREATE VIEW v (i "int", f "String") AS SELECT * FROM t"#) {
|
||||
Statement::CreateView { name, columns, .. } => {
|
||||
assert_eq!(name, ObjectName(vec!["v".into()]));
|
||||
assert_eq!(
|
||||
columns,
|
||||
vec![
|
||||
ViewColumnDef {
|
||||
name: "i".into(),
|
||||
data_type: Some(DataType::Custom(
|
||||
ObjectName(vec![Ident {
|
||||
value: "int".into(),
|
||||
quote_style: Some('"')
|
||||
}]),
|
||||
vec![]
|
||||
)),
|
||||
options: None
|
||||
},
|
||||
ViewColumnDef {
|
||||
name: "f".into(),
|
||||
data_type: Some(DataType::Custom(
|
||||
ObjectName(vec![Ident {
|
||||
value: "String".into(),
|
||||
quote_style: Some('"')
|
||||
}]),
|
||||
vec![]
|
||||
)),
|
||||
options: None
|
||||
},
|
||||
]
|
||||
);
|
||||
}
|
||||
_ => unreachable!(),
|
||||
}
|
||||
|
||||
clickhouse()
|
||||
.parse_sql_statements(r#"CREATE VIEW v (i, f) AS SELECT * FROM t"#)
|
||||
.expect_err("CREATE VIEW with fields and without data types should be invalid");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn parse_double_equal() {
|
||||
clickhouse().one_statement_parses_to(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue