Skip to content

Commit f2e3ea5

Browse files
parse SET ( storage_parameters )
1 parent 23f40cd commit f2e3ea5

File tree

3 files changed

+24
-8
lines changed

3 files changed

+24
-8
lines changed

src/ast/ddl.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -351,6 +351,10 @@ pub enum AlterTableOperation {
351351
ValidateConstraint {
352352
name: Ident,
353353
},
354+
/// `SET ( storage_parameter [= value] [, ... ] )`
355+
SetStorageParameters {
356+
storage_parameters: Vec<SqlOption>,
357+
},
354358
}
355359

356360
/// An `ALTER Policy` (`Statement::AlterPolicy`) operation
@@ -791,6 +795,9 @@ impl fmt::Display for AlterTableOperation {
791795
AlterTableOperation::ValidateConstraint { name } => {
792796
write!(f, "VALIDATE CONSTRAINT {name}")
793797
}
798+
AlterTableOperation::SetStorageParameters { storage_parameters } => {
799+
write!(f, "SET ({})", display_comma_separated(storage_parameters))
800+
}
794801
}
795802
}
796803
}

src/ast/spans.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1201,6 +1201,9 @@ impl Spanned for AlterTableOperation {
12011201
AlterTableOperation::Lock { .. } => Span::empty(),
12021202
AlterTableOperation::ReplicaIdentity { .. } => Span::empty(),
12031203
AlterTableOperation::ValidateConstraint { name } => name.span,
1204+
AlterTableOperation::SetStorageParameters { storage_parameters } => {
1205+
union_spans(storage_parameters.iter().map(|i| i.span()))
1206+
}
12041207
}
12051208
}
12061209
}

src/parser/mod.rs

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8938,17 +8938,23 @@ impl<'a> Parser<'a> {
89388938
let name = self.parse_identifier()?;
89398939
AlterTableOperation::ValidateConstraint { name }
89408940
} else {
8941-
let options: Vec<SqlOption> =
8942-
self.parse_options_with_keywords(&[Keyword::SET, Keyword::TBLPROPERTIES])?;
8943-
if !options.is_empty() {
8944-
AlterTableOperation::SetTblProperties {
8945-
table_properties: options,
8941+
let maybe_options = self.maybe_parse_options(Keyword::SET)?;
8942+
if let Some(options) = maybe_options {
8943+
AlterTableOperation::SetStorageParameters {
8944+
storage_parameters: options,
89468945
}
89478946
} else {
8948-
return self.expected(
8949-
"ADD, RENAME, PARTITION, SWAP, DROP, REPLICA IDENTITY, or SET TBLPROPERTIES after ALTER TABLE",
8947+
let options: Vec<SqlOption> = self.parse_options(Keyword::TBLPROPERTIES)?;
8948+
if !options.is_empty() {
8949+
AlterTableOperation::SetTblProperties {
8950+
table_properties: options,
8951+
}
8952+
} else {
8953+
return self.expected(
8954+
"ADD, RENAME, PARTITION, SWAP, DROP, REPLICA IDENTITY, SET, or SET TBLPROPERTIES after ALTER TABLE",
89508955
self.peek_token(),
8951-
);
8956+
);
8957+
}
89528958
}
89538959
};
89548960
Ok(operation)

0 commit comments

Comments
 (0)