Add support for ClickHouse DDL query syntax (on cluster) (#527)

* Add on_cluster to Statement::CreateTable

* Add printing of on_cluster

* Update src/ast/mod.rs

Co-authored-by: Andrew Lamb <andrew@nerdnetworks.org>

* Fix fmt + nostd

* Remove unintended diff

Co-authored-by: Andrew Lamb <andrew@nerdnetworks.org>
This commit is contained in:
Andy Richardson 2022-07-28 19:44:05 +01:00 committed by GitHub
parent f74753436a
commit 16af309c74
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 46 additions and 0 deletions

View file

@ -1995,6 +1995,27 @@ fn parse_create_table_as() {
}
}
#[test]
fn parse_create_table_on_cluster() {
// Using single-quote literal to define current cluster
let sql = "CREATE TABLE t ON CLUSTER '{cluster}' (a INT, b INT)";
match verified_stmt(sql) {
Statement::CreateTable { on_cluster, .. } => {
assert_eq!(on_cluster.unwrap(), "{cluster}".to_string());
}
_ => unreachable!(),
}
// Using explicitly declared cluster name
let sql = "CREATE TABLE t ON CLUSTER my_cluster (a INT, b INT)";
match verified_stmt(sql) {
Statement::CreateTable { on_cluster, .. } => {
assert_eq!(on_cluster.unwrap(), "my_cluster".to_string());
}
_ => unreachable!(),
}
}
#[test]
fn parse_create_or_replace_table() {
let sql = "CREATE OR REPLACE TABLE t (a INT)";