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

@ -2172,6 +2172,11 @@ pub enum Statement {
/// Postgres-specific option
/// [ CASCADE | RESTRICT ]
cascade: Option<TruncateCascadeOption>,
/// ClickHouse-specific option
/// [ ON CLUSTER cluster_name ]
///
/// [ClickHouse](https://clickhouse.com/docs/en/sql-reference/statements/truncate/)
on_cluster: Option<Ident>,
},
/// ```sql
/// MSCK
@ -3293,6 +3298,7 @@ impl fmt::Display for Statement {
only,
identity,
cascade,
on_cluster,
} => {
let table = if *table { "TABLE " } else { "" };
let only = if *only { "ONLY " } else { "" };
@ -3321,6 +3327,9 @@ impl fmt::Display for Statement {
write!(f, " PARTITION ({})", display_comma_separated(parts))?;
}
}
if let Some(on_cluster) = on_cluster {
write!(f, " ON CLUSTER {on_cluster}")?;
}
Ok(())
}
Statement::AttachDatabase {

View file

@ -708,6 +708,8 @@ impl<'a> Parser<'a> {
};
};
let on_cluster = self.parse_optional_on_cluster()?;
Ok(Statement::Truncate {
table_names,
partitions,
@ -715,6 +717,7 @@ impl<'a> Parser<'a> {
only,
identity,
cascade,
on_cluster,
})
}