mirror of
https://github.com/apache/datafusion-sqlparser-rs.git
synced 2025-10-12 15:02:07 +00:00
Add support for MYSQL's RENAME TABLE
(#1616)
Co-authored-by: Ifeanyi Ubah <ify1992@yahoo.com>
This commit is contained in:
parent
3bad04e9e8
commit
94ea20628f
4 changed files with 104 additions and 0 deletions
|
@ -3413,6 +3413,13 @@ pub enum Statement {
|
|||
partitioned: Option<Vec<Expr>>,
|
||||
table_format: Option<HiveLoadDataFormat>,
|
||||
},
|
||||
/// ```sql
|
||||
/// Rename TABLE tbl_name TO new_tbl_name[, tbl_name2 TO new_tbl_name2] ...
|
||||
/// ```
|
||||
/// Renames one or more tables
|
||||
///
|
||||
/// See Mysql <https://dev.mysql.com/doc/refman/9.1/en/rename-table.html>
|
||||
RenameTable(Vec<RenameTable>),
|
||||
}
|
||||
|
||||
impl fmt::Display for Statement {
|
||||
|
@ -4970,6 +4977,9 @@ impl fmt::Display for Statement {
|
|||
}
|
||||
Ok(())
|
||||
}
|
||||
Statement::RenameTable(rename_tables) => {
|
||||
write!(f, "RENAME TABLE {}", display_comma_separated(rename_tables))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -7672,6 +7682,22 @@ impl Display for JsonNullClause {
|
|||
}
|
||||
}
|
||||
|
||||
/// rename object definition
|
||||
#[derive(Debug, Clone, PartialEq, PartialOrd, Eq, Ord, Hash)]
|
||||
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
|
||||
#[cfg_attr(feature = "visitor", derive(Visit, VisitMut))]
|
||||
pub struct RenameTable {
|
||||
pub old_name: ObjectName,
|
||||
pub new_name: ObjectName,
|
||||
}
|
||||
|
||||
impl fmt::Display for RenameTable {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
write!(f, "{} TO {}", self.old_name, self.new_name)?;
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue