Skip to content

Commit a48498f

Browse files
author
Ilson Roberto Balliego Junior
committed
re-add tests in the common tests file
1 parent 4b1219c commit a48498f

File tree

1 file changed

+54
-0
lines changed

1 file changed

+54
-0
lines changed

tests/sqlparser_common.rs

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3429,6 +3429,32 @@ fn parse_create_table_as_table() {
34293429
}
34303430
}
34313431

3432+
#[test]
3433+
fn parse_create_table_on_cluster() {
3434+
let generic = TestedDialects {
3435+
dialects: vec![Box::new(GenericDialect {})],
3436+
options: None,
3437+
};
3438+
3439+
// Using single-quote literal to define current cluster
3440+
let sql = "CREATE TABLE t ON CLUSTER '{cluster}' (a INT, b INT)";
3441+
match generic.verified_stmt(sql) {
3442+
Statement::CreateTable { on_cluster, .. } => {
3443+
assert_eq!(on_cluster.unwrap(), "{cluster}".to_string());
3444+
}
3445+
_ => unreachable!(),
3446+
}
3447+
3448+
// Using explicitly declared cluster name
3449+
let sql = "CREATE TABLE t ON CLUSTER my_cluster (a INT, b INT)";
3450+
match generic.verified_stmt(sql) {
3451+
Statement::CreateTable { on_cluster, .. } => {
3452+
assert_eq!(on_cluster.unwrap(), "my_cluster".to_string());
3453+
}
3454+
_ => unreachable!(),
3455+
}
3456+
}
3457+
34323458
#[test]
34333459
fn parse_create_or_replace_table() {
34343460
let sql = "CREATE OR REPLACE TABLE t (a INT)";
@@ -3472,6 +3498,34 @@ fn parse_create_table_with_on_delete_on_update_2in_any_order() -> Result<(), Par
34723498
Ok(())
34733499
}
34743500

3501+
#[test]
3502+
fn parse_create_table_with_options() {
3503+
let generic = TestedDialects {
3504+
dialects: vec![Box::new(GenericDialect {})],
3505+
options: None,
3506+
};
3507+
3508+
let sql = "CREATE TABLE t (c INT) WITH (foo = 'bar', a = 123)";
3509+
match generic.verified_stmt(sql) {
3510+
Statement::CreateTable { with_options, .. } => {
3511+
assert_eq!(
3512+
vec![
3513+
SqlOption {
3514+
name: "foo".into(),
3515+
value: Expr::Value(Value::SingleQuotedString("bar".into())),
3516+
},
3517+
SqlOption {
3518+
name: "a".into(),
3519+
value: Expr::Value(number("123")),
3520+
},
3521+
],
3522+
with_options
3523+
);
3524+
}
3525+
_ => unreachable!(),
3526+
}
3527+
}
3528+
34753529
#[test]
34763530
fn parse_create_table_clone() {
34773531
let sql = "CREATE OR REPLACE TABLE a CLONE a_tmp";

0 commit comments

Comments
 (0)