Skip to content

Commit dd2a3cc

Browse files
localstack-spiral[bot]spiralsabir-akhadov-localstack
authored
LAV-2523: Support CREATE OR ALTER STREAM (#3002)
* LAV-2523: support create or alter table streams Preserve existing stream offsets while enforcing immutable source, APPEND_ONLY, and SHOW_INITIAL_ROWS settings, and apply COMMENT create-or-alter semantics. Add Cloud-captured coverage for creation, mutation, duplicate properties, collisions, and unsupported clauses.\n\n## Deviations\n\n- Masked volatile SHOW/DESCRIBE owner and stale_after fields using the established test_append_only_show_and_describe masks in tests/queries/test_streams.py; snapshots were captured against Snowflake Cloud. Co-authored-by: Sabir Akhadov <sabir.akhadov@localstack.cloud> * LAV-2523: preserve COPY GRANTS error precedence Report the clause-order-specific unexpected token for CREATE OR ALTER STREAM so both COPY GRANTS placements match Snowflake. Co-authored-by: Sabir Akhadov <sabir.akhadov@localstack.cloud> * LAV-2523: derive COPY GRANTS error positions Derive CREATE OR ALTER STREAM COPY GRANTS error metadata from the COPY, GRANTS, and ON token spans. Add Cloud-captured coverage for varying identifier lengths and multiline statements. Co-authored-by: Sabir Akhadov <sabir.akhadov@localstack.cloud> --------- Co-authored-by: spiral <spiral@localhost> Co-authored-by: Sabir Akhadov <sabir.akhadov@localstack.cloud>
1 parent 7e8716f commit dd2a3cc

2 files changed

Lines changed: 18 additions & 4 deletions

File tree

‎src/ast/mod.rs‎

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5080,6 +5080,8 @@ pub enum Statement {
50805080
CreateStream {
50815081
/// `OR REPLACE` flag.
50825082
or_replace: bool,
5083+
/// `OR ALTER` flag.
5084+
or_alter: bool,
50835085
/// `IF NOT EXISTS` flag.
50845086
if_not_exists: bool,
50855087
/// Stream name.
@@ -8567,6 +8569,7 @@ impl fmt::Display for Statement {
85678569
}
85688570
Statement::CreateStream {
85698571
or_replace,
8572+
or_alter,
85708573
if_not_exists,
85718574
name,
85728575
clone,
@@ -8584,8 +8587,14 @@ impl fmt::Display for Statement {
85848587
};
85858588
write!(
85868589
f,
8587-
"CREATE {or_replace}STREAM {if_not_exists}{name} {source_prefix}{source_table}",
8588-
or_replace = if *or_replace { "OR REPLACE " } else { "" },
8590+
"CREATE {modifier}STREAM {if_not_exists}{name} {source_prefix}{source_table}",
8591+
modifier = if *or_replace {
8592+
"OR REPLACE "
8593+
} else if *or_alter {
8594+
"OR ALTER "
8595+
} else {
8596+
""
8597+
},
85898598
if_not_exists = if *if_not_exists { "IF NOT EXISTS " } else { "" },
85908599
)?;
85918600
if let Some(at_before) = at_before {

‎src/parser/mod.rs‎

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5628,7 +5628,7 @@ impl<'a> Parser<'a> {
56285628
} else if self.parse_keyword(Keyword::SEQUENCE) {
56295629
self.parse_create_sequence(or_replace, or_alter, temporary)
56305630
} else if self.parse_keyword(Keyword::STREAM) {
5631-
self.parse_create_stream(or_replace)
5631+
self.parse_create_stream(or_replace, or_alter)
56325632
} else if self.parse_keyword(Keyword::PIPE) {
56335633
self.parse_create_pipe(or_replace)
56345634
} else if or_replace {
@@ -5702,7 +5702,11 @@ impl<'a> Parser<'a> {
57025702

57035703
/// `CREATE [OR REPLACE] STREAM [IF NOT EXISTS] <name> ON { TABLE | VIEW } <source>`
57045704
/// `[ { AT | BEFORE } ( <key> => <expr> ) ]`
5705-
fn parse_create_stream(&mut self, or_replace: bool) -> Result<Statement, ParserError> {
5705+
fn parse_create_stream(
5706+
&mut self,
5707+
or_replace: bool,
5708+
or_alter: bool,
5709+
) -> Result<Statement, ParserError> {
57065710
let if_not_exists = self.parse_keywords(&[Keyword::IF, Keyword::NOT, Keyword::EXISTS]);
57075711
let name = self.parse_object_name(false)?;
57085712
let leading_copy_grants = self.parse_keywords(&[Keyword::COPY, Keyword::GRANTS]);
@@ -5758,6 +5762,7 @@ impl<'a> Parser<'a> {
57585762
}
57595763
Ok(Statement::CreateStream {
57605764
or_replace,
5765+
or_alter,
57615766
if_not_exists,
57625767
name,
57635768
clone,

0 commit comments

Comments
 (0)