Skip to content

Commit a89d19a

Browse files
localstack-spiral[bot]spiralsabir-akhadov-localstack
authored
LAV-2522: Support COPY GRANTS for CREATE STREAM (#2967)
* LAV-2522: support COPY GRANTS for streams Co-authored-by: Sabir Akhadov <sabir.akhadov@localstack.cloud> * LAV-2522: reproject copied stream grants to database roles 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 1108ae0 commit a89d19a

2 files changed

Lines changed: 11 additions & 1 deletion

File tree

src/ast/mod.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5100,6 +5100,8 @@ pub enum Statement {
51005100
/// The validated `APPEND_ONLY` property, following the `{ AT | BEFORE }`
51015101
/// clause. `None` when omitted (which Snowflake treats as `FALSE`).
51025102
append_only: Option<bool>,
5103+
/// Whether eligible grants are copied from the replaced or cloned stream.
5104+
copy_grants: bool,
51035105
},
51045106
/// ```sql
51055107
/// ALTER WAREHOUSE [IF EXISTS] [<name>] <operation>
@@ -8546,6 +8548,7 @@ impl fmt::Display for Statement {
85468548
source_table,
85478549
at_before,
85488550
append_only,
8551+
copy_grants,
85498552
} => {
85508553
let source_prefix = if *clone {
85518554
"CLONE ".to_string()
@@ -8568,6 +8571,9 @@ impl fmt::Display for Statement {
85688571
if *append_only { "TRUE" } else { "FALSE" }
85698572
)?;
85708573
}
8574+
if *copy_grants {
8575+
write!(f, " COPY GRANTS")?;
8576+
}
85718577
Ok(())
85728578
}
85738579
Statement::AlterWarehouse {

src/parser/mod.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5705,7 +5705,8 @@ impl<'a> Parser<'a> {
57055705
fn parse_create_stream(&mut self, or_replace: bool) -> Result<Statement, ParserError> {
57065706
let if_not_exists = self.parse_keywords(&[Keyword::IF, Keyword::NOT, Keyword::EXISTS]);
57075707
let name = self.parse_object_name(false)?;
5708-
let clone = self.parse_keyword(Keyword::CLONE);
5708+
let leading_copy_grants = self.parse_keywords(&[Keyword::COPY, Keyword::GRANTS]);
5709+
let clone = !leading_copy_grants && self.parse_keyword(Keyword::CLONE);
57095710
if !clone {
57105711
self.expect_keyword(Keyword::ON)?;
57115712
}
@@ -5717,6 +5718,8 @@ impl<'a> Parser<'a> {
57175718
return self.expected("TABLE or VIEW", self.peek_token());
57185719
};
57195720
let source_table = self.parse_object_name(false)?;
5721+
let copy_grants = leading_copy_grants
5722+
|| self.parse_keywords(&[Keyword::COPY, Keyword::GRANTS]);
57205723
// Optional `{ AT | BEFORE } ( <key> => <expr> )` clause, kept whole as
57215724
// the function-call expression (the same shape `TableVersion::Function`
57225725
// uses for a table-version anchor).
@@ -5748,6 +5751,7 @@ impl<'a> Parser<'a> {
57485751
source_table,
57495752
at_before,
57505753
append_only,
5754+
copy_grants,
57515755
})
57525756
}
57535757

0 commit comments

Comments
 (0)