mirror of
https://github.com/apache/datafusion-sqlparser-rs.git
synced 2025-10-29 06:17:31 +00:00
Allow to use ON CLUSTER cluster_name in TRUNCATE syntax (#1428)
This commit is contained in:
parent
246838a69f
commit
1c505ce736
4 changed files with 38 additions and 2 deletions
|
|
@ -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 {
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
})
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue