Snowflake ALTER TABLE clustering options (#1579)

This commit is contained in:
Yoav Cohen 2024-12-06 10:41:01 +01:00 committed by GitHub
parent 7b50ac31c3
commit d0fcc06652
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 123 additions and 15 deletions

View file

@ -1411,6 +1411,42 @@ fn test_alter_table_swap_with() {
};
}
#[test]
fn test_alter_table_clustering() {
let sql = r#"ALTER TABLE tab CLUSTER BY (c1, "c2", TO_DATE(c3))"#;
match alter_table_op(snowflake_and_generic().verified_stmt(sql)) {
AlterTableOperation::ClusterBy { exprs } => {
assert_eq!(
exprs,
[
Expr::Identifier(Ident::new("c1")),
Expr::Identifier(Ident::with_quote('"', "c2")),
Expr::Function(Function {
name: ObjectName(vec![Ident::new("TO_DATE")]),
parameters: FunctionArguments::None,
args: FunctionArguments::List(FunctionArgumentList {
args: vec![FunctionArg::Unnamed(FunctionArgExpr::Expr(
Expr::Identifier(Ident::new("c3"))
))],
duplicate_treatment: None,
clauses: vec![],
}),
filter: None,
null_treatment: None,
over: None,
within_group: vec![]
})
],
);
}
_ => unreachable!(),
}
snowflake_and_generic().verified_stmt("ALTER TABLE tbl DROP CLUSTERING KEY");
snowflake_and_generic().verified_stmt("ALTER TABLE tbl SUSPEND RECLUSTER");
snowflake_and_generic().verified_stmt("ALTER TABLE tbl RESUME RECLUSTER");
}
#[test]
fn test_drop_stage() {
match snowflake_and_generic().verified_stmt("DROP STAGE s1") {