Redshift: CREATE TABLE ... (LIKE ..) (#1967)
Some checks failed
license / Release Audit Tool (RAT) (push) Has been cancelled
Rust / codestyle (push) Has been cancelled
Rust / lint (push) Has been cancelled
Rust / benchmark-lint (push) Has been cancelled
Rust / compile (push) Has been cancelled
Rust / docs (push) Has been cancelled
Rust / compile-no-std (push) Has been cancelled
Rust / test (beta) (push) Has been cancelled
Rust / test (nightly) (push) Has been cancelled
Rust / test (stable) (push) Has been cancelled

This commit is contained in:
Yoav Cohen 2025-08-16 08:34:23 +02:00 committed by GitHub
parent 60a5c8d42a
commit b660a3b1ea
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
10 changed files with 224 additions and 29 deletions

View file

@ -10465,6 +10465,62 @@ impl fmt::Display for CreateUser {
}
}
/// Specifies how to create a new table based on an existing table's schema.
/// '''sql
/// CREATE TABLE new LIKE old ...
/// '''
#[derive(Debug, Clone, PartialEq, PartialOrd, Eq, Ord, Hash)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
#[cfg_attr(feature = "visitor", derive(Visit, VisitMut))]
pub enum CreateTableLikeKind {
/// '''sql
/// CREATE TABLE new (LIKE old ...)
/// '''
/// [Redshift](https://docs.aws.amazon.com/redshift/latest/dg/r_CREATE_TABLE_NEW.html)
Parenthesized(CreateTableLike),
/// '''sql
/// CREATE TABLE new LIKE old ...
/// '''
/// [Snowflake](https://docs.snowflake.com/en/sql-reference/sql/create-table#label-create-table-like)
/// [BigQuery](https://cloud.google.com/bigquery/docs/reference/standard-sql/data-definition-language#create_table_like)
Plain(CreateTableLike),
}
#[derive(Debug, Copy, Clone, PartialEq, PartialOrd, Eq, Ord, Hash)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
#[cfg_attr(feature = "visitor", derive(Visit, VisitMut))]
pub enum CreateTableLikeDefaults {
Including,
Excluding,
}
impl fmt::Display for CreateTableLikeDefaults {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match self {
CreateTableLikeDefaults::Including => write!(f, "INCLUDING DEFAULTS"),
CreateTableLikeDefaults::Excluding => write!(f, "EXCLUDING DEFAULTS"),
}
}
}
#[derive(Debug, Clone, PartialEq, PartialOrd, Eq, Ord, Hash)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
#[cfg_attr(feature = "visitor", derive(Visit, VisitMut))]
pub struct CreateTableLike {
pub name: ObjectName,
pub defaults: Option<CreateTableLikeDefaults>,
}
impl fmt::Display for CreateTableLike {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "LIKE {}", self.name)?;
if let Some(defaults) = &self.defaults {
write!(f, " {defaults}")?;
}
Ok(())
}
}
#[cfg(test)]
mod tests {
use crate::tokenizer::Location;