Skip to content

Commit ccf903c

Browse files
parse SET ( storage_parameters )
1 parent 6506814 commit ccf903c

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
@@ -8920,17 +8920,23 @@ impl<'a> Parser<'a> {
89208920
let name = self.parse_identifier()?;
89218921
AlterTableOperation::ValidateConstraint { name }
89228922
} else {
8923-
let options: Vec<SqlOption> =
8924-
self.parse_options_with_keywords(&[Keyword::SET, Keyword::TBLPROPERTIES])?;
8925-
if !options.is_empty() {
8926-
AlterTableOperation::SetTblProperties {
8927-
table_properties: options,
8923+
let maybe_options = self.maybe_parse_options(Keyword::SET)?;
8924+
if let Some(options) = maybe_options {
8925+
AlterTableOperation::SetStorageParameters {
8926+
storage_parameters: options,
89288927
}
89298928
} else {
8930-
return self.expected(
8931-
"ADD, RENAME, PARTITION, SWAP, DROP, REPLICA IDENTITY, or SET TBLPROPERTIES after ALTER TABLE",
8929+
let options: Vec<SqlOption> = self.parse_options(Keyword::TBLPROPERTIES)?;
8930+
if !options.is_empty() {
8931+
AlterTableOperation::SetTblProperties {
8932+
table_properties: options,
8933+
}
8934+
} else {
8935+
return self.expected(
8936+
"ADD, RENAME, PARTITION, SWAP, DROP, REPLICA IDENTITY, SET, or SET TBLPROPERTIES after ALTER TABLE",
89328937
self.peek_token(),
8933-
);
8938+
);
8939+
}
89348940
}
89358941
};
89368942
Ok(operation)

0 commit comments

Comments
 (0)