ClickHouse: create view with fields and data types (#1292)

This commit is contained in:
Aleksei Piianin 2024-05-30 18:24:12 +02:00 committed by GitHub
parent 029a999645
commit 375742d1fa
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 60 additions and 2 deletions

View file

@ -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(