mirror of
https://github.com/apache/datafusion-sqlparser-rs.git
synced 2025-10-14 07:52:02 +00:00
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:
parent
f74753436a
commit
16af309c74
3 changed files with 46 additions and 0 deletions
|
@ -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)";
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue