Skip to content

Commit 6686fcb

Browse files
authored
Revert "Add support for Create Iceberg Table statement for Snowflake parser (apache#1664)"
This reverts commit 5194266.
1 parent 439386f commit 6686fcb

File tree

8 files changed

+316
-295
lines changed

8 files changed

+316
-295
lines changed

src/ast/dml.rs

Lines changed: 2 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,7 @@ use super::{
3636
CommentDef, Expr, FileFormat, FromTable, HiveDistributionStyle, HiveFormat, HiveIOFormat,
3737
HiveRowFormat, Ident, InsertAliases, MysqlInsertPriority, ObjectName, OnCommit, OnInsert,
3838
OneOrManyWithParens, OrderByExpr, Query, RowAccessPolicy, SelectItem, Setting, SqlOption,
39-
SqliteOnConflict, StorageSerializationPolicy, TableEngine, TableObject, TableWithJoins, Tag,
40-
WrappedCollection,
39+
SqliteOnConflict, TableEngine, TableObject, TableWithJoins, Tag, WrappedCollection,
4140
};
4241

4342
/// CREATE INDEX statement.
@@ -118,7 +117,6 @@ pub struct CreateTable {
118117
pub if_not_exists: bool,
119118
pub transient: bool,
120119
pub volatile: bool,
121-
pub iceberg: bool,
122120
/// Table name
123121
#[cfg_attr(feature = "visitor", visit(with = "visit_relation"))]
124122
pub name: ObjectName,
@@ -194,21 +192,6 @@ pub struct CreateTable {
194192
/// Snowflake "WITH TAG" clause
195193
/// <https://docs.snowflake.com/en/sql-reference/sql/create-table>
196194
pub with_tags: Option<Vec<Tag>>,
197-
/// Snowflake "EXTERNAL_VOLUME" clause for Iceberg tables
198-
/// <https://docs.snowflake.com/en/sql-reference/sql/create-iceberg-table>
199-
pub external_volume: Option<String>,
200-
/// Snowflake "BASE_LOCATION" clause for Iceberg tables
201-
/// <https://docs.snowflake.com/en/sql-reference/sql/create-iceberg-table>
202-
pub base_location: Option<String>,
203-
/// Snowflake "CATALOG" clause for Iceberg tables
204-
/// <https://docs.snowflake.com/en/sql-reference/sql/create-iceberg-table>
205-
pub catalog: Option<String>,
206-
/// Snowflake "CATALOG_SYNC" clause for Iceberg tables
207-
/// <https://docs.snowflake.com/en/sql-reference/sql/create-iceberg-table>
208-
pub catalog_sync: Option<String>,
209-
/// Snowflake "STORAGE_SERIALIZATION_POLICY" clause for Iceberg tables
210-
/// <https://docs.snowflake.com/en/sql-reference/sql/create-iceberg-table>
211-
pub storage_serialization_policy: Option<StorageSerializationPolicy>,
212195
}
213196

214197
impl Display for CreateTable {
@@ -222,7 +205,7 @@ impl Display for CreateTable {
222205
// `CREATE TABLE t (a INT) AS SELECT a from t2`
223206
write!(
224207
f,
225-
"CREATE {or_replace}{external}{global}{temporary}{transient}{volatile}{iceberg}TABLE {if_not_exists}{name}",
208+
"CREATE {or_replace}{external}{global}{temporary}{transient}{volatile}TABLE {if_not_exists}{name}",
226209
or_replace = if self.or_replace { "OR REPLACE " } else { "" },
227210
external = if self.external { "EXTERNAL " } else { "" },
228211
global = self.global
@@ -238,8 +221,6 @@ impl Display for CreateTable {
238221
temporary = if self.temporary { "TEMPORARY " } else { "" },
239222
transient = if self.transient { "TRANSIENT " } else { "" },
240223
volatile = if self.volatile { "VOLATILE " } else { "" },
241-
// Only for Snowflake
242-
iceberg = if self.iceberg { "ICEBERG " } else { "" },
243224
name = self.name,
244225
)?;
245226
if let Some(on_cluster) = &self.on_cluster {
@@ -401,31 +382,6 @@ impl Display for CreateTable {
401382
)?;
402383
}
403384

404-
if let Some(external_volume) = self.external_volume.as_ref() {
405-
write!(f, " EXTERNAL_VOLUME = '{external_volume}'")?;
406-
}
407-
408-
if let Some(catalog) = self.catalog.as_ref() {
409-
write!(f, " CATALOG = '{catalog}'")?;
410-
}
411-
412-
if self.iceberg {
413-
if let Some(base_location) = self.base_location.as_ref() {
414-
write!(f, " BASE_LOCATION = '{base_location}'")?;
415-
}
416-
}
417-
418-
if let Some(catalog_sync) = self.catalog_sync.as_ref() {
419-
write!(f, " CATALOG_SYNC = '{catalog_sync}'")?;
420-
}
421-
422-
if let Some(storage_serialization_policy) = self.storage_serialization_policy.as_ref() {
423-
write!(
424-
f,
425-
" STORAGE_SERIALIZATION_POLICY = {storage_serialization_policy}"
426-
)?;
427-
}
428-
429385
if self.copy_grants {
430386
write!(f, " COPY GRANTS")?;
431387
}

src/ast/helpers/stmt_create_table.rs

Lines changed: 1 addition & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ use super::super::dml::CreateTable;
2828
use crate::ast::{
2929
ClusteredBy, ColumnDef, CommentDef, Expr, FileFormat, HiveDistributionStyle, HiveFormat, Ident,
3030
ObjectName, OnCommit, OneOrManyWithParens, Query, RowAccessPolicy, SqlOption, Statement,
31-
StorageSerializationPolicy, TableConstraint, TableEngine, Tag, WrappedCollection,
31+
TableConstraint, TableEngine, Tag, WrappedCollection,
3232
};
3333
use crate::parser::ParserError;
3434

@@ -71,7 +71,6 @@ pub struct CreateTableBuilder {
7171
pub if_not_exists: bool,
7272
pub transient: bool,
7373
pub volatile: bool,
74-
pub iceberg: bool,
7574
pub name: ObjectName,
7675
pub columns: Vec<ColumnDef>,
7776
pub constraints: Vec<TableConstraint>,
@@ -108,11 +107,6 @@ pub struct CreateTableBuilder {
108107
pub with_aggregation_policy: Option<ObjectName>,
109108
pub with_row_access_policy: Option<RowAccessPolicy>,
110109
pub with_tags: Option<Vec<Tag>>,
111-
pub base_location: Option<String>,
112-
pub external_volume: Option<String>,
113-
pub catalog: Option<String>,
114-
pub catalog_sync: Option<String>,
115-
pub storage_serialization_policy: Option<StorageSerializationPolicy>,
116110
}
117111

118112
impl CreateTableBuilder {
@@ -125,7 +119,6 @@ impl CreateTableBuilder {
125119
if_not_exists: false,
126120
transient: false,
127121
volatile: false,
128-
iceberg: false,
129122
name,
130123
columns: vec![],
131124
constraints: vec![],
@@ -162,11 +155,6 @@ impl CreateTableBuilder {
162155
with_aggregation_policy: None,
163156
with_row_access_policy: None,
164157
with_tags: None,
165-
base_location: None,
166-
external_volume: None,
167-
catalog: None,
168-
catalog_sync: None,
169-
storage_serialization_policy: None,
170158
}
171159
}
172160
pub fn or_replace(mut self, or_replace: bool) -> Self {
@@ -204,11 +192,6 @@ impl CreateTableBuilder {
204192
self
205193
}
206194

207-
pub fn iceberg(mut self, iceberg: bool) -> Self {
208-
self.iceberg = iceberg;
209-
self
210-
}
211-
212195
pub fn columns(mut self, columns: Vec<ColumnDef>) -> Self {
213196
self.columns = columns;
214197
self
@@ -388,34 +371,6 @@ impl CreateTableBuilder {
388371
self
389372
}
390373

391-
pub fn base_location(mut self, base_location: Option<String>) -> Self {
392-
self.base_location = base_location;
393-
self
394-
}
395-
396-
pub fn external_volume(mut self, external_volume: Option<String>) -> Self {
397-
self.external_volume = external_volume;
398-
self
399-
}
400-
401-
pub fn catalog(mut self, catalog: Option<String>) -> Self {
402-
self.catalog = catalog;
403-
self
404-
}
405-
406-
pub fn catalog_sync(mut self, catalog_sync: Option<String>) -> Self {
407-
self.catalog_sync = catalog_sync;
408-
self
409-
}
410-
411-
pub fn storage_serialization_policy(
412-
mut self,
413-
storage_serialization_policy: Option<StorageSerializationPolicy>,
414-
) -> Self {
415-
self.storage_serialization_policy = storage_serialization_policy;
416-
self
417-
}
418-
419374
pub fn build(self) -> Statement {
420375
Statement::CreateTable(CreateTable {
421376
or_replace: self.or_replace,
@@ -425,7 +380,6 @@ impl CreateTableBuilder {
425380
if_not_exists: self.if_not_exists,
426381
transient: self.transient,
427382
volatile: self.volatile,
428-
iceberg: self.iceberg,
429383
name: self.name,
430384
columns: self.columns,
431385
constraints: self.constraints,
@@ -462,11 +416,6 @@ impl CreateTableBuilder {
462416
with_aggregation_policy: self.with_aggregation_policy,
463417
with_row_access_policy: self.with_row_access_policy,
464418
with_tags: self.with_tags,
465-
base_location: self.base_location,
466-
external_volume: self.external_volume,
467-
catalog: self.catalog,
468-
catalog_sync: self.catalog_sync,
469-
storage_serialization_policy: self.storage_serialization_policy,
470419
})
471420
}
472421
}
@@ -486,7 +435,6 @@ impl TryFrom<Statement> for CreateTableBuilder {
486435
if_not_exists,
487436
transient,
488437
volatile,
489-
iceberg,
490438
name,
491439
columns,
492440
constraints,
@@ -523,11 +471,6 @@ impl TryFrom<Statement> for CreateTableBuilder {
523471
with_aggregation_policy,
524472
with_row_access_policy,
525473
with_tags,
526-
base_location,
527-
external_volume,
528-
catalog,
529-
catalog_sync,
530-
storage_serialization_policy,
531474
}) => Ok(Self {
532475
or_replace,
533476
temporary,
@@ -562,7 +505,6 @@ impl TryFrom<Statement> for CreateTableBuilder {
562505
clustered_by,
563506
options,
564507
strict,
565-
iceberg,
566508
copy_grants,
567509
enable_schema_evolution,
568510
change_tracking,
@@ -573,11 +515,6 @@ impl TryFrom<Statement> for CreateTableBuilder {
573515
with_row_access_policy,
574516
with_tags,
575517
volatile,
576-
base_location,
577-
external_volume,
578-
catalog,
579-
catalog_sync,
580-
storage_serialization_policy,
581518
}),
582519
_ => Err(ParserError::ParserError(format!(
583520
"Expected create table statement, but received: {stmt}"

src/ast/spans.rs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -559,7 +559,6 @@ impl Spanned for CreateTable {
559559
if_not_exists: _, // bool
560560
transient: _, // bool
561561
volatile: _, // bool
562-
iceberg: _, // bool, Snowflake specific
563562
name,
564563
columns,
565564
constraints,
@@ -596,11 +595,6 @@ impl Spanned for CreateTable {
596595
with_aggregation_policy: _, // todo, Snowflake specific
597596
with_row_access_policy: _, // todo, Snowflake specific
598597
with_tags: _, // todo, Snowflake specific
599-
external_volume: _, // todo, Snowflake specific
600-
base_location: _, // todo, Snowflake specific
601-
catalog: _, // todo, Snowflake specific
602-
catalog_sync: _, // todo, Snowflake specific
603-
storage_serialization_policy: _, // todo, Snowflake specific
604598
} = self;
605599

606600
union_spans(

0 commit comments

Comments
 (0)