Skip to content

Commit 9b76400

Browse files
authored
Revert "Sync with base repo 03.02.2025"
This reverts commit 1a63a42.
1 parent 1a63a42 commit 9b76400

File tree

2 files changed

+143
-1
lines changed

2 files changed

+143
-1
lines changed

src/ast/mod.rs

Lines changed: 143 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2577,6 +2577,35 @@ pub enum Statement {
25772577
/// CREATE TABLE
25782578
/// ```
25792579
CreateTable(CreateTable),
2580+
/// ``` sql
2581+
/// CREATE ICEBERG TABLE
2582+
/// Snowflake-specific statement
2583+
/// <https://docs.snowflake.com/en/sql-reference/sql/create-iceberg-table>
2584+
/// ```
2585+
CreateIcebergTable {
2586+
or_replace: bool,
2587+
if_not_exists: bool,
2588+
/// Table name
2589+
#[cfg_attr(feature = "visitor", visit(with = "visit_relation"))]
2590+
name: ObjectName,
2591+
columns: Vec<ColumnDef>,
2592+
constraints: Vec<TableConstraint>,
2593+
with_options: Vec<SqlOption>,
2594+
comment: Option<CommentDef>,
2595+
cluster_by: Option<WrappedCollection<Vec<Ident>>>,
2596+
external_volume: Option<String>,
2597+
catalog: Option<String>,
2598+
base_location: String,
2599+
catalog_sync: Option<String>,
2600+
storage_serialization_policy: Option<StorageSerializationPolicy>,
2601+
data_retention_time_in_days: Option<u64>,
2602+
max_data_extension_time_in_days: Option<u64>,
2603+
change_tracking: Option<bool>,
2604+
copy_grants: bool,
2605+
with_aggregation_policy: Option<ObjectName>,
2606+
with_row_access_policy: Option<RowAccessPolicy>,
2607+
with_tags: Option<Vec<Tag>>,
2608+
},
25802609
/// ```sql
25812610
/// CREATE VIRTUAL TABLE .. USING <module_name> (<module_args>)`
25822611
/// ```
@@ -4149,6 +4178,120 @@ impl fmt::Display for Statement {
41494178
}
41504179
Ok(())
41514180
}
4181+
Statement::CreateIcebergTable {
4182+
or_replace,
4183+
if_not_exists,
4184+
name,
4185+
columns,
4186+
constraints,
4187+
with_options,
4188+
comment,
4189+
cluster_by,
4190+
external_volume,
4191+
catalog,
4192+
base_location,
4193+
catalog_sync,
4194+
storage_serialization_policy,
4195+
data_retention_time_in_days,
4196+
max_data_extension_time_in_days,
4197+
change_tracking,
4198+
copy_grants,
4199+
with_row_access_policy,
4200+
with_aggregation_policy,
4201+
with_tags,
4202+
} => {
4203+
write!(
4204+
f,
4205+
"CREATE {or_replace}ICEBERG TABLE {if_not_exists}{name}",
4206+
if_not_exists = if *if_not_exists { "IF NOT EXISTS" } else { "" },
4207+
or_replace = if *or_replace { "OR REPLACE " } else { "" }
4208+
)?;
4209+
if !columns.is_empty() || !constraints.is_empty() {
4210+
write!(f, " ({}", display_comma_separated(columns))?;
4211+
if !columns.is_empty() && !constraints.is_empty() {
4212+
write!(f, ", ")?;
4213+
}
4214+
write!(f, "{})", display_comma_separated(&constraints))?;
4215+
}
4216+
if !with_options.is_empty() {
4217+
write!(f, " WITH ({})", display_comma_separated(&with_options))?;
4218+
}
4219+
if let Some(comment_def) = &comment {
4220+
match comment_def {
4221+
CommentDef::WithEq(comment) => {
4222+
write!(f, " COMMENT = '{comment}'")?;
4223+
}
4224+
CommentDef::WithoutEq(comment) => {
4225+
write!(f, " COMMENT '{comment}'")?;
4226+
}
4227+
// For CommentDef::AfterColumnDefsWithoutEq will be displayed after column definition
4228+
CommentDef::AfterColumnDefsWithoutEq(_) => (),
4229+
}
4230+
}
4231+
if let Some(cluster_by) = cluster_by {
4232+
write!(f, " CLUSTER BY {cluster_by}")?;
4233+
}
4234+
if let Some(external_volume) = external_volume {
4235+
write!(f, " EXTERNAL_VOLUME = '{external_volume}'")?;
4236+
}
4237+
4238+
if let Some(catalog) = catalog {
4239+
write!(f, " CATALOG = '{catalog}'")?;
4240+
}
4241+
4242+
write!(f, " BASE_LOCATION = '{base_location}'")?;
4243+
4244+
if let Some(catalog_sync) = catalog_sync {
4245+
write!(f, " CATALOG_SYNC = '{catalog_sync}'")?;
4246+
}
4247+
4248+
if let Some(storage_serialization_policy) = storage_serialization_policy {
4249+
write!(
4250+
f,
4251+
" STORAGE_SERIALIZATION_POLICY = {storage_serialization_policy}"
4252+
)?;
4253+
}
4254+
4255+
if *copy_grants {
4256+
write!(f, " COPY GRANTS")?;
4257+
}
4258+
4259+
if let Some(is_enabled) = change_tracking {
4260+
write!(
4261+
f,
4262+
" CHANGE_TRACKING = {}",
4263+
if *is_enabled { "TRUE" } else { "FALSE" }
4264+
)?;
4265+
}
4266+
4267+
if let Some(data_retention_time_in_days) = data_retention_time_in_days {
4268+
write!(
4269+
f,
4270+
" DATA_RETENTION_TIME_IN_DAYS = {data_retention_time_in_days}",
4271+
)?;
4272+
}
4273+
4274+
if let Some(max_data_extension_time_in_days) = max_data_extension_time_in_days {
4275+
write!(
4276+
f,
4277+
" MAX_DATA_EXTENSION_TIME_IN_DAYS = {max_data_extension_time_in_days}",
4278+
)?;
4279+
}
4280+
4281+
if let Some(with_aggregation_policy) = with_aggregation_policy {
4282+
write!(f, " WITH AGGREGATION POLICY {with_aggregation_policy}",)?;
4283+
}
4284+
4285+
if let Some(row_access_policy) = with_row_access_policy {
4286+
write!(f, " {row_access_policy}",)?;
4287+
}
4288+
4289+
if let Some(tag) = with_tags {
4290+
write!(f, " WITH TAG ({})", display_comma_separated(tag.as_slice()))?;
4291+
}
4292+
4293+
Ok(())
4294+
}
41524295
Statement::CreateVirtualTable {
41534296
name,
41544297
if_not_exists,

src/ast/spans.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -490,7 +490,6 @@ impl Spanned for Statement {
490490
Statement::DropPolicy { .. } => Span::empty(),
491491
Statement::ShowDatabases { .. } => Span::empty(),
492492
Statement::ShowSchemas { .. } => Span::empty(),
493-
Statement::ShowObjects { .. } => Span::empty(),
494493
Statement::ShowViews { .. } => Span::empty(),
495494
Statement::LISTEN { .. } => Span::empty(),
496495
Statement::NOTIFY { .. } => Span::empty(),

0 commit comments

Comments
 (0)