Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 2 additions & 57 deletions src/ast/ddl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3067,20 +3067,6 @@ pub struct CreateTable {
/// Redshift `BACKUP` option: `BACKUP { YES | NO }`
/// <https://docs.aws.amazon.com/redshift/latest/dg/r_CREATE_TABLE_NEW.html>
pub backup: Option<bool>,
/// `MULTISET | SET` table-kind prefix.
/// `Some(true)` => `MULTISET`, `Some(false)` => `SET`.
///
/// [Teradata](https://docs.teradata.com/r/Enterprise_IntelliFlex_VMware/SQL-Data-Definition-Language-Syntax-and-Examples/Table-Statements/CREATE-TABLE-and-CREATE-TABLE-AS/Syntax-Elements/MULTISET-or-SET)
pub multiset: Option<bool>,
/// `FALLBACK` clause.
/// `Some(true)` => `FALLBACK`, `Some(false)` => `NO FALLBACK`
///
/// [Teradata](https://docs.teradata.com/r/Enterprise_IntelliFlex_VMware/SQL-Data-Definition-Language-Syntax-and-Examples/Table-Statements/CREATE-TABLE-and-CREATE-TABLE-AS/Syntax-Elements/FALLBACK-or-NO-FALLBACK)
pub fallback: Option<bool>,
/// `WITH DATA` clause on a `CREATE TABLE ... AS` statement.
///
/// [Teradata](https://docs.teradata.com/r/Enterprise_IntelliFlex_VMware/SQL-Data-Definition-Language-Syntax-and-Examples/Table-Statements/CREATE-TABLE-and-CREATE-TABLE-AS/Syntax-Elements/AS_clause/WITH-Clause-Phrase)
pub with_data: Option<WithData>,
}

impl fmt::Display for CreateTable {
Expand All @@ -3094,7 +3080,7 @@ impl fmt::Display for CreateTable {
// `CREATE TABLE t (a INT) AS SELECT a from t2`
write!(
f,
"CREATE {or_replace}{external}{global}{multiset}{temporary}{transient}{volatile}{dynamic}{iceberg}{snapshot}TABLE {if_not_exists}{name}",
"CREATE {or_replace}{external}{global}{temporary}{transient}{volatile}{dynamic}{iceberg}{snapshot}TABLE {if_not_exists}{name}",
or_replace = if self.or_replace { "OR REPLACE " } else { "" },
external = if self.external { "EXTERNAL " } else { "" },
snapshot = if self.snapshot { "SNAPSHOT " } else { "" },
Expand All @@ -3108,20 +3094,14 @@ impl fmt::Display for CreateTable {
})
.unwrap_or(""),
if_not_exists = if self.if_not_exists { "IF NOT EXISTS " } else { "" },
multiset = self
.multiset
.map(|m| if m { "MULTISET " } else { "SET " })
.unwrap_or(""),
temporary = if self.temporary { "TEMPORARY " } else { "" },
transient = if self.transient { "TRANSIENT " } else { "" },
volatile = if self.volatile { "VOLATILE " } else { "" },
// Only for Snowflake
iceberg = if self.iceberg { "ICEBERG " } else { "" },
dynamic = if self.dynamic { "DYNAMIC " } else { "" },
name = self.name,
)?;
if let Some(fallback) = self.fallback {
write!(f, ", {}", if fallback { "FALLBACK" } else { "NO FALLBACK" })?;
}
if let Some(partition_of) = &self.partition_of {
write!(f, " PARTITION OF {partition_of}")?;
}
Expand Down Expand Up @@ -3409,41 +3389,6 @@ impl fmt::Display for CreateTable {
if let Some(query) = &self.query {
write!(f, " AS {query}")?;
}
if let Some(with_data) = &self.with_data {
write!(f, " {with_data}")?;
}
Ok(())
}
}

/// `WITH DATA` clause on `CREATE TABLE ... AS` statement.
///
/// [Teradata](https://docs.teradata.com/r/Enterprise_IntelliFlex_VMware/SQL-Data-Definition-Language-Syntax-and-Examples/Table-Statements/CREATE-TABLE-and-CREATE-TABLE-AS/Syntax-Elements/AS_clause/WITH-Clause-Phrase)
#[derive(Debug, Clone, Copy, PartialEq, PartialOrd, Eq, Ord, Hash)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
#[cfg_attr(feature = "visitor", derive(Visit, VisitMut))]
pub struct WithData {
/// `true` for `WITH DATA`, `false` for `WITH NO DATA`.
pub data: bool,
/// `Some(true)` for `AND STATISTICS`, `Some(false)` for `AND NO STATISTICS`,
/// `None` if the `AND [NO] STATISTICS` sub-clause is omitted.
pub statistics: Option<bool>,
}

impl fmt::Display for WithData {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
f.write_str("WITH ")?;
if !self.data {
f.write_str("NO ")?;
}
f.write_str("DATA")?;
if let Some(stats) = self.statistics {
f.write_str(" AND ")?;
if !stats {
f.write_str("NO ")?;
}
f.write_str("STATISTICS")?;
}
Ok(())
}
}
Expand Down
33 changes: 1 addition & 32 deletions src/ast/helpers/stmt_create_table.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ use crate::ast::{
DistStyle, Expr, FileFormat, ForValues, HiveDistributionStyle, HiveFormat, Ident,
InitializeKind, ObjectName, OnCommit, OneOrManyWithParens, Query, RefreshModeKind,
RowAccessPolicy, Statement, StorageLifecyclePolicy, StorageSerializationPolicy,
TableConstraint, TableVersion, Tag, WithData, WrappedCollection,
TableConstraint, TableVersion, Tag, WrappedCollection,
};

use crate::parser::ParserError;
Expand Down Expand Up @@ -186,12 +186,6 @@ pub struct CreateTableBuilder {
pub sortkey: Option<Vec<Expr>>,
/// Redshift `BACKUP` option.
pub backup: Option<bool>,
/// `MULTISET | SET` table-kind prefix.
pub multiset: Option<bool>,
/// `FALLBACK` clause.
pub fallback: Option<bool>,
/// `WITH DATA` clause.
pub with_data: Option<WithData>,
}

impl CreateTableBuilder {
Expand Down Expand Up @@ -258,9 +252,6 @@ impl CreateTableBuilder {
distkey: None,
sortkey: None,
backup: None,
multiset: None,
fallback: None,
with_data: None,
}
}
/// Set `OR REPLACE` for the CREATE TABLE statement.
Expand Down Expand Up @@ -574,22 +565,6 @@ impl CreateTableBuilder {
self.backup = backup;
self
}
/// Set `MULTISET | SET` table-kind prefix.
/// Some(true) => `MULTISET`, Some(false) => `SET`.
pub fn multiset(mut self, multiset: Option<bool>) -> Self {
self.multiset = multiset;
self
}
/// Set `FALLBACK` / `NO FALLBACK` flag.
pub fn fallback(mut self, fallback: Option<bool>) -> Self {
self.fallback = fallback;
self
}
/// Set `WITH DATA` clause.
pub fn with_data(mut self, with_data: Option<WithData>) -> Self {
self.with_data = with_data;
self
}
/// Consume the builder and produce a `CreateTable`.
pub fn build(self) -> CreateTable {
CreateTable {
Expand Down Expand Up @@ -653,9 +628,6 @@ impl CreateTableBuilder {
distkey: self.distkey,
sortkey: self.sortkey,
backup: self.backup,
multiset: self.multiset,
fallback: self.fallback,
with_data: self.with_data,
}
}
}
Expand Down Expand Up @@ -738,9 +710,6 @@ impl From<CreateTable> for CreateTableBuilder {
distkey: table.distkey,
sortkey: table.sortkey,
backup: table.backup,
multiset: table.multiset,
fallback: table.fallback,
with_data: table.with_data,
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/ast/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ pub use self::ddl::{
ReplicaIdentity, TagsColumnOption, TextSearchObjectType, TriggerObjectKind, Truncate,
UserDefinedTypeCompositeAttributeDef, UserDefinedTypeInternalLength,
UserDefinedTypeRangeOption, UserDefinedTypeRepresentation, UserDefinedTypeSqlDefinitionOption,
UserDefinedTypeStorage, ViewColumnDef, WithData,
UserDefinedTypeStorage, ViewColumnDef,
};
pub use self::dml::{
Delete, Insert, Merge, MergeAction, MergeClause, MergeClauseKind, MergeInsertExpr,
Expand Down
3 changes: 0 additions & 3 deletions src/ast/spans.rs
Original file line number Diff line number Diff line change
Expand Up @@ -609,9 +609,6 @@ impl Spanned for CreateTable {
distkey: _,
sortkey: _,
backup: _,
multiset: _,
fallback: _,
with_data: _,
} = self;

union_spans(
Expand Down
15 changes: 0 additions & 15 deletions src/dialect/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ mod redshift;
mod snowflake;
mod spark;
mod sqlite;
mod teradata;

use core::any::{Any, TypeId};
use core::fmt::Debug;
Expand All @@ -55,7 +54,6 @@ pub use self::snowflake::parse_snowflake_stage_name;
pub use self::snowflake::SnowflakeDialect;
pub use self::spark::SparkSqlDialect;
pub use self::sqlite::SQLiteDialect;
pub use self::teradata::TeradataDialect;

/// Macro for streamlining the creation of derived `Dialect` objects.
/// The generated struct includes `new()` and `default()` constructors.
Expand Down Expand Up @@ -1226,16 +1224,6 @@ pub trait Dialect: Debug + Any {
false
}

/// Returns true if the dialect accepts a comma-separated list of table-level
/// options placed between the table name and the column-list parenthesis, e.g.
///
/// ```sql
/// CREATE TABLE foo, NO FALLBACK, NO BEFORE JOURNAL (col INTEGER)
/// ```
fn supports_leading_comma_before_table_options(&self) -> bool {
false
}

/// Returns true if the dialect supports PartiQL for querying semi-structured data
/// <https://partiql.org/index.html>
fn supports_partiql(&self) -> bool {
Expand Down Expand Up @@ -1886,7 +1874,6 @@ pub fn dialect_from_str(dialect_name: impl AsRef<str>) -> Option<Box<dyn Dialect
"databricks" => Some(Box::new(DatabricksDialect {})),
"spark" | "sparksql" => Some(Box::new(SparkSqlDialect {})),
"oracle" => Some(Box::new(OracleDialect {})),
"teradata" => Some(Box::new(TeradataDialect {})),
_ => None,
}
}
Expand Down Expand Up @@ -1940,8 +1927,6 @@ mod tests {
assert!(parse_dialect("DuckDb").is::<DuckDbDialect>());
assert!(parse_dialect("DataBricks").is::<DatabricksDialect>());
assert!(parse_dialect("databricks").is::<DatabricksDialect>());
assert!(parse_dialect("teradata").is::<TeradataDialect>());
assert!(parse_dialect("Teradata").is::<TeradataDialect>());

// error cases
assert!(dialect_from_str("Unknown").is_none());
Expand Down
97 changes: 0 additions & 97 deletions src/dialect/teradata.rs

This file was deleted.

1 change: 0 additions & 1 deletion src/keywords.rs
Original file line number Diff line number Diff line change
Expand Up @@ -417,7 +417,6 @@ define_keywords!(
FACTS,
FAIL,
FAILOVER,
FALLBACK,
FALSE,
FAMILY,
FETCH,
Expand Down
Loading
Loading