Allow to use ON CLUSTER cluster_name in TRUNCATE syntax (#1428)

This commit is contained in:
hulk 2024-09-19 18:56:00 +08:00 committed by GitHub
parent 246838a69f
commit 1c505ce736
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 38 additions and 2 deletions

View file

@ -10804,3 +10804,24 @@ fn test_extract_seconds_single_quote_err() {
"sql parser error: Expected: date/time field, found: 'seconds'"
);
}
#[test]
fn test_truncate_table_with_on_cluster() {
let sql = "TRUNCATE TABLE t ON CLUSTER cluster_name";
match all_dialects().verified_stmt(sql) {
Statement::Truncate { on_cluster, .. } => {
assert_eq!(on_cluster, Some(Ident::new("cluster_name")));
}
_ => panic!("Expected: TRUNCATE TABLE statement"),
}
// Omit ON CLUSTER is allowed
all_dialects().verified_stmt("TRUNCATE TABLE t");
assert_eq!(
ParserError::ParserError("Expected: identifier, found: EOF".to_string()),
all_dialects()
.parse_sql_statements("TRUNCATE TABLE t ON CLUSTER")
.unwrap_err()
);
}